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

Re: [pygame] Tentative patch for "metrics" font method



Brian Fisher wrote:
Hey Guillame,

Thank you;  apparently, the stuff i needed does not work as expected
(on Windows at least).
I will try out on Linux. Thanks a ton!

That's a shame that the metrics stuff doesn't detect what you want,
there might be a way you can work around it though...

On 1/19/07, Guillaume Proux <gproux@xxxxxxxxx> wrote:
?  ... Why does it display garbage then in Freevo?! I guess I need to
make a couple of test cases.

When it displays garbage it's a square box, yeah? Basically with a
font there are 2 sets of things, one is the glyphs/outlines used to
make the images, the other is the mapping table that goes from some
char set (like unicode) to a glyph. Most fonts have mapping tables set
up to have stuff they don't have glyphs for point to the "I don't have
an image for that" glyph, which is usually a specific square box.

I've actually found that some characters fail to render with pygame's
font stuff for specific fonts (the render call throws an exception),
which I assume is cause the mapping table doesn't have anything for
that char. I'll try and dig up a case of that and send it later...

--
So anyways, even though there doesn't seem to be a way to directly
detect that there is no glyph or image designed for a given character
through SDL_ttf, you might be able to indirectly figure it out by
detecting that the font rendered the box... it would be really slow,
but it oughta work

...Also, I think the metrics thing would be a cool addition anyways -
since the chars over-render with empty space in order to get their
spacing correct now, it would be great to have that metrics info in
pygame. Also, if you were going to do some kind of square box char not
found detection stuff, the metrics stuff could be a quick early
rejection test (I'm sure that (1, 5, 0, 12, 5) must be the metrics for
the square box for chars with no glyph)

I finally loaded kochi-gothic.ttf into a pygame application and tried some text. It has ascii characters, which confirms what the Window's font browser showed me. And it has Hiragana characters. For unknown characters it shows a small, solid square.

--
Lenard Lindstrom
<len-l@xxxxxxxxx>