| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
"""Display font information. |
| 5 |
|
| 6 |
Usage:: |
| 7 |
|
| 8 |
inspect_font.py <filename> [<filename> ...] |
| 9 |
""" |
| 10 |
|
| 11 |
import sys |
| 12 |
from pyglet.font import ttf |
| 13 |
|
| 14 |
|
| 15 |
def inspect_font(filename): |
| 16 |
try: |
| 17 |
info = ttf.TruetypeInfo(filename) |
| 18 |
print('{0}:'.format(filename)) |
| 19 |
print(info.get_name('family')) |
| 20 |
print('bold=%r' % info.is_bold()) |
| 21 |
print('italic=%r' % info.is_italic()) |
| 22 |
except: |
| 23 |
print("%s could not be identified. It is probably not a TrueType or " |
| 24 |
"OpenType font. However, pyglet may still be able to load it " |
| 25 |
"on some platforms." % filename) |
| 26 |
|
| 27 |
|
| 28 |
if __name__ == '__main__': |
| 29 |
if len(sys.argv) < 2: |
| 30 |
print(__doc__) |
| 31 |
for file_name in sys.argv[1:]: |
| 32 |
inspect_font(file_name) |