Comment 3 for bug 1001033

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

Hi Sam,

FreeMono is tested on multiple OSs, with several applications which work only with monospace fonts, as well as with scripts that specifically look for any variations in glyph width. I can assure you, FreeMono is monospaced.

The problem you posted on pygame-users (appended here for completness) is coming from intermediate rendering software. You are talking about width of glyphs in terms of rendered pixels: this is a far cry from how wide the glyphs are, as described by the font.

Some of the responses to your post state that pygame.font.SysFont is unreliable for this sort of thing, and suggest using other interfaces. Did you try that?

Cheers!

Original posting describing the problem:
---------------------------------
Before I go and file a bug against Ubuntu, can somebody confirm I'm not
being stupid.

For my input boxes, the cursor position depends on a monospaced font.
This means I check the length of a rendered letter ("e") using the font,
and then set the cursor position as a multiple of this length.

This worked fine before, but in Ubuntu 12.04, it no longer seems to be
monospaced. Getting the length of the character "e" on my system gives
me 9 pixels, but it seems that some characters, such as "h", are 10
pixels, which starts offsetting my cursor position and messing up my
input box.

The line I use to load the font is:
        pygame.font.SysFont("FreeMono, Monospace", 16)

That should definitely return a monospaced font, right?

And, the line used for getting the width is:
        mono_font.render("e", False, (0,0,0)).get_size()[0]

Is this a bug, or am I doing something stupid?
---------------------------------