Comment 21 for bug 1001033

Revision history for this message
Steve White (stevan-white) wrote :

Another experiment with pygame's font API. Looks very strange.

Printed out the width (in pixels, presumably) of a string of 100 letter 'x' rendered at different point sizes.

Now FreeMono is 1000 units high and 600 wide.
The point size is the height, and a point is 72 pt/in.
My screen's x-resolution is 125 DPI (from /var/log/Xorg.0.log)

s = "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
for fontsize in range( 5, 25 ):
        m = pygame.font.SysFont("FreeMono", fontsize)
        print "(", fontsize, "pt) ", m.render(s, False, (0,0,0)).get_size()[0]

I would expect a number more like 1042px at 10 pt:
100 * 10 pt high * (0.6 FreeMono width/height) * (125 px/in ) / (72 pt/in)

But see below.
Totally don't understand the numbers I get.

I also looked at the "height" measure returned by get_size()... it gives at 10 pt
   13
while
   10 pt * (119 px/in Y-DPI) / (72 pt/in) = 16.52 px
These units are not pixels, I guess. I wonder what they are.
This and, maybe my arithmetic isn't right.

Widths of 100 x's at a range of point sizes.
----------------------------------------------------------
FreeMono:
( 5 pt ) 300
( 6 pt ) 400
( 7 pt ) 400
( 8 pt ) 500
( 9 pt ) 500
( 10 pt ) 600
( 11 pt ) 700
( 12 pt ) 700
( 13 pt ) 800
( 14 pt ) 800
( 15 pt ) 900
( 16 pt ) 1000
( 17 pt ) 1000
( 18 pt ) 1100
( 19 pt ) 1100
( 20 pt ) 1200
( 21 pt ) 1300
( 22 pt ) 1300
( 23 pt ) 1400
( 24 pt ) 1400

DejaVu Sans Mono:
( 5 pt) 301
( 6 pt) 400
( 7 pt) 400
( 8 pt) 500
( 9 pt) 500
( 10 pt) 600
( 11 pt) 700
( 12 pt) 700
( 13 pt) 800
( 14 pt) 800
( 15 pt) 900
( 16 pt) 1000
( 17 pt) 1000
( 18 pt) 1100
( 19 pt) 1100
( 20 pt) 1200
( 21 pt) 1300
( 22 pt) 1300
( 23 pt) 1400
( 24 pt) 1400