On Wed, Mar 31, 2010 at 10:28 PM, Florian Bösch <[email protected]> wrote:
> I'd like to open a specific filename.ttf and provide it as a
> filestream and get back a font instance. Currently I only seem to be
> able to load some font into pyglet, and hope for the best when
> specifying the font name to load (crossing fingers it won't take any
> other font or some default or that I've misspelled the font name etc.)
>
> How can I load a specific font instance from a filestream to a TTF
> file?

In general it's not possible, as both the Windows and OS X font
systems operate by name, not stream (pyglet can provide the OS with
additional font files, but the OS does not return back the names in
those files).

However, pyglet has an undocumented class pyglet.font.ttf.TrueTypeInfo
which can read the TTF header; see TrueTypeInfo.get_names().  You
might need to trial and error a little to get the appropriate name (I
recall the OS does some mangling of the name; e.g. to turn "Courier
Bold" into "Courier").

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.

Reply via email to