Return a wx font. Cache font instances for efficiency.
(self, s, prop)
| 260 | return self.gc |
| 261 | |
| 262 | def get_wx_font(self, s, prop): |
| 263 | """Return a wx font. Cache font instances for efficiency.""" |
| 264 | _log.debug("%s - get_wx_font()", type(self)) |
| 265 | key = hash(prop) |
| 266 | font = self.fontd.get(key) |
| 267 | if font is not None: |
| 268 | return font |
| 269 | size = self.points_to_pixels(prop.get_size_in_points()) |
| 270 | # Font colour is determined by the active wx.Pen |
| 271 | # TODO: It may be wise to cache font information |
| 272 | self.fontd[key] = font = wx.Font( # Cache the font and gc. |
| 273 | pointSize=round(size), |
| 274 | family=self.fontnames.get(prop.get_name(), wx.ROMAN), |
| 275 | style=self.fontangles[prop.get_style()], |
| 276 | weight=self.fontweights[prop.get_weight()]) |
| 277 | return font |
| 278 | |
| 279 | def points_to_pixels(self, points): |
| 280 | # docstring inherited |
no test coverage detected