def add_file(font):
"""Add a font to pyglet's search path.
In order to load a font that is not installed on the system, you must
call this method to tell pyglet that it exists. You can supply
either a filename or any file-like object.
The font format is platform-dependent, but is typically a TrueType font
file containing a single font face. Note that to use a font added with this method,
you should pass the face name (not the file name) to :meth:`pyglet.font.load` or any
other place where you normally specify a font.
:Parameters:
`font` : str or file
Filename or file-like object to load fonts from.
"""
if isinstance(font, basestring):
font = open(font, 'rb')
if hasattr(font, 'read'):
font = font.read()
_font_class.add_font_data(font)
评论列表
文章目录