On Sat, Apr 9, 2011 at 12:23 PM, Richard Jones <[email protected]> wrote:
> On Sat, Apr 9, 2011 at 3:10 AM, hugo <[email protected]> wrote:
>> I'm using a monospaced font and I'd like to know the width in pixels
>> of one character. Is that even possible?
>
> I'm pretty sure you have to create a text label with the one character
> and then look at its dimensions. I don't believe there's a query API -
> mostly because the query API would have to do that render under the
> hood (there's no way AFAIK to ask a truetype font what the dimensions
> are of any given glyph without rendering it first).
Something like this should work:
font = ...
glyphs = font.get_glyphs('X')
width = glyphs[0].advance
Alex.
--
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pyglet-users?hl=en.