On 17/05/2007, at 4:04 AM, andre v wrote:
> yes glyph width are important. Will be used int he gui allot.
> some thing like:
> glyph_width('asfdf') # and optimized for singe chars
> glyph_height('sfsfs')
> width,height = glyph_size('sdfs')
This is a separate issue, and already easily achievable:
from pyglet import font
arial = font.load('Arial')
label = font.Label(arial, 'asfdf')
print label.width, label.height
There are methods on Glyph for retrieving individual glyph
dimensions, but these are not useful when you consider the effects of
bearing and kerning. If you're really in need of performance, use
the lower-level GlyphString instead of Label.
Alex.
>
> On 5/15/07, Richard Jones <[EMAIL PROTECTED]> wrote:
> On 5/16/07, [EMAIL PROTECTED] < codesite-
> [EMAIL PROTECTED]> wrote:
> + def get_subwidth(self, from_index, to_index):
> + '''Return the width of a slice of this string.
> +
> + Parameters as per GlyphString.get_subwidth(from_index,
> to_index)
> + '''
> + return self._glyph_string.get_subwidth(from_index, to_index)
>
> I'm not particularly happy with this, BTW.
>
> I'd actually like to see the glyph string "exposed", as I'm now
> writing code like:
>
> # XXX yuck - search through glyph string to find index
> matching x coord !!!
> x = [some X coordinate]
> for advance in self.label._glyph_string.cumulative_advance:
> # blah blah
>
> I'd prefer that _ not be there - but I'm not convinced we need to
> add a "findIndexOf" (or better-named ;) method to the Label class.
>
>
> Richard
>
>
>
>
>
> >
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---