@@ -68,8 +68,7 @@ def write(self, msg):
68
68
print ("Stderr: %s\n \r " % msg )
69
69
70
70
71
- # the True dots per inch on the screen; should be display dependent
72
- # see
71
+ # the True dots per inch on the screen; should be display dependent; see
73
72
# http://groups.google.com/groups?q=screen+dpi+x11&hl=en&lr=&ie=UTF-8&oe=UTF-8&safe=off&selm=7077.26e81ad5%40swift.cs.tcd.ie&rnum=5
74
73
# for some info about screen dpi
75
74
PIXELS_PER_INCH = 75
@@ -343,38 +342,19 @@ def get_gc(self):
343
342
return self .gc
344
343
345
344
def get_wx_font (self , s , prop ):
346
- """
347
- Return a wx font. Cache instances in a font dictionary for
348
- efficiency
349
- """
345
+ """Return a wx font. Cache font instances for efficiency."""
350
346
_log .debug ("%s - get_wx_font()" , type (self ))
351
-
352
347
key = hash (prop )
353
- fontprop = prop
354
- fontname = fontprop .get_name ()
355
-
356
348
font = self .fontd .get (key )
357
349
if font is not None :
358
350
return font
359
-
360
- # Allow use of platform independent and dependent font names
361
- wxFontname = self .fontnames .get (fontname , wx .ROMAN )
362
- wxFacename = '' # Empty => wxPython chooses based on wx_fontname
363
-
364
351
# Font colour is determined by the active wx.Pen
365
352
# TODO: It may be wise to cache font information
366
- size = self .points_to_pixels (fontprop .get_size_in_points ())
367
-
368
- font = wx .Font (int (size + 0.5 ), # Size
369
- wxFontname , # 'Generic' name
370
- self .fontangles [fontprop .get_style ()], # Angle
371
- self .fontweights [fontprop .get_weight ()], # Weight
372
- False , # Underline
373
- wxFacename ) # Platform font name
374
-
375
- # cache the font and gc and return it
376
- self .fontd [key ] = font
377
-
353
+ self .fontd [key ] = font = wx .Font ( # Cache the font and gc.
354
+ pointSize = self .points_to_pixels (prop .get_size_in_points ()),
355
+ family = self .fontnames .get (prop .get_name (), wx .ROMAN ),
356
+ style = self .fontangles [prop .get_style ()],
357
+ weight = self .fontweights [prop .get_weight ()])
378
358
return font
379
359
380
360
def points_to_pixels (self , points ):
0 commit comments