[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Monospaced fonts are meant to be mono-spaced, right?



On Mon, May 28, 2012 at 12:27 PM, Sam Bull <sam.hacking@xxxxxxxx> wrote:
> OK, so I registered a bug on this, and it's possible that it is a bug
> with the rendering library. Can anybody who knows anything about the
> pygame.font module, look at the bug report and see if you can add any
> information to this?
>
> https://bugs.launchpad.net/ubuntu/+source/ttf-freefont/+bug/1001033

I don't have time to investigate further, but I had a quick look:

1. I could reproduce the behaviour you saw on Windows but not a Ubuntu
VM (but it is old, certainly not 12.04).
2. I tried replacing the version of FreeType used by Pygame on Windows
with one from here http://www.gtk.org/download/win32.php and got your
expected behaviour - everything the same width.
3. I note that the Font object has a metrics() method that returns
metrics for a glyph, as explained in this diagram:
http://www.libsdl.org/projects/SDL_ttf/docs/SDL_ttf.html#SEC38
4. Based on that diagram, I'd expect "advance" to be constant for a
monospaced font, but that min and max x might vary. Metrics shows that
advance varies for the glyphs you have the problem with.
5. I also note that the description of metrics in the Pygame docs
appears to be wrong:
http://www.pygame.org/docs/ref/font.html#Font.metrics It describes the
advance as "bearing plus width", but this is not necessarily the case,
as shown in the SDL diagram.

I might have a look this evening, and if I do, I'll post a test script
and follow up on your launchpad bug. It looks like different versions
of FreeType might have subtly different behaviour, but I wouldn't like
to hazard a guess whether any of the font, FreeType, SDL or pygame
actually has a bug at this stage. I'm not in any way affiliated with
any of these projects, just curious.