-_____- Anyway, as a work around for this craziness, see here: http://www.starrhorne.com/2012/01/18/how-to-extract-font-names-from-ttf-files-using-python-and-our-old-friend-the-command-line.html
I've manually patched my copy of pyglet so: 1) have_font() does what it is supposed to and checks if the font exists 2) a new font_name() function that returns the font name for a given ttf / otf, etc. It pulls a dependency in on fontTools (http://sourceforge.net/projects/fonttools/) so it's probably no good for a mainline merge, but something along these lines would make the pyglet font for working with font files a great deal easier to use. ~ Doug. On Monday, May 6, 2013 8:29:44 PM UTC+8, Doug Linder wrote: > > Hey there, > > I'm having a lot of trouble with the font api. > > Basically it comes down to this: > > 1) If you have a font, and you call add_file() on it, you have no idea > what the associated font name is. > > 2) If you call either pyglet.font.load() for > pyglet.font.base.Font.have_font(), these return a font / true in all > circumstances. > > The only way I've found to determine if we're successfully using a font or > not is: > > pyglet.font.add_file(path) > font = pyglet.font.load(name=font_name, size=1) > span = font.ascent + font.descent > if span > 5: > print("ID %s did not match a known font name" % self.font) > > This seems absolutely ridiculous to me. > > I mean, what the heck is this nonsense? > > @classmethod > def have_font(cls, name): > '''Determine if a font with the given name is installed. > > :Parameters: > `name` : str > Name of a font to search for > > :rtype: bool > ''' > return True > > !!! Why does the call even exist? > > I appreciate loading fonts cross platform is tricky, and I suppose it's > vaguely nice having access to the default system fonts, but this api is > really really hard to use. > > > Am I doing something wrong? > Why is using fonts so difficult? > > ~ > Doug. > -- You received this message because you are subscribed to the Google Groups "pyglet-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/pyglet-users?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
