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

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



Guillaume Proux wrote:
Hi Lenard,

Thank you for helping.

I have NO knowledge of programming for Python/C interface. I tried
just to copy paste from above methods....
I guess I should try to learn a bit before writing patches. I also
need to set up a dev system.

Only one sytax error. Not bad. As for writing Python extension code, studying existing modules is a good start. I admit I have little experience beyond patching existing code myself. As for a dev system, it was not that long ago that batch jobs were common :-).

On my Linux box, I had problem with non appearing characters (garbage)
when trying to display english characters using the Kochi font. I
don't know how it would work if one would try this in Windows. This
would be the only way to trigger the "character is not in the font" as
per the SDL_TTF doc.

I downloaded kochi-gothic.ttf and found it has ascii characters. Maybe this is the wrong ttf file. On Windows, anyway, the metrics method returns the tuple (1, 5, 0, 12, 5) for characters it should know nothing about. I don't think Gurmukhi ( U+0A00-U+0A7F ) is on my machine. This is a quick test session I did:

>>> from pygame import font
>>> font.init()
>>> f=font.Font('kochi-gothic.ttf', 16)
>>> f.metrics('a')
(0, 7, 0, 9, 8)
>>> f.metrics(u'\u2ee0')
(1, 5, 0, 12, 5)
>>> f.metrics(u'\u2eef')
(1, 5, 0, 12, 5)
>>> f.metrics(u'\U00012000')
(1, 5, 0, 12, 5)
>>> f.metrics('\x2e')
(1, 3, 0, 2, 8)
>>> f.metrics(u'\u0A01')
(1, 5, 0, 12, 5)
>>> f.metrics(u'\u0A00')
(1, 5, 0, 12, 5)


Regarding the exception, I don't have strong opinions, I tend to be
conservative with raising exceptions and maybe one should raise an
exception when the string passed as parameter is empty but... I am not
convinced. But I will let official maintainers make the best choice.

Yes, it is ultimately up to the Pygame maintainers to decide.

Good luck with the patch.

Lenard

--
Lenard Lindstrom
<len-l@xxxxxxxxx>