|
16 | 16 |
|
17 | 17 | font = FT2Font(fname)
|
18 | 18 |
|
19 |
| -# these constants are used to access the style_flags and face_flags |
20 |
| -FT_FACE_FLAG_SCALABLE = 1 << 0 |
21 |
| -FT_FACE_FLAG_FIXED_SIZES = 1 << 1 |
22 |
| -FT_FACE_FLAG_FIXED_WIDTH = 1 << 2 |
23 |
| -FT_FACE_FLAG_SFNT = 1 << 3 |
24 |
| -FT_FACE_FLAG_HORIZONTAL = 1 << 4 |
25 |
| -FT_FACE_FLAG_VERTICAL = 1 << 5 |
26 |
| -FT_FACE_FLAG_KERNING = 1 << 6 |
27 |
| -FT_FACE_FLAG_FAST_GLYPHS = 1 << 7 |
28 |
| -FT_FACE_FLAG_MULTIPLE_MASTERS = 1 << 8 |
29 |
| -FT_FACE_FLAG_GLYPH_NAMES = 1 << 9 |
30 |
| -FT_FACE_FLAG_EXTERNAL_STREAM = 1 << 10 |
31 |
| -FT_STYLE_FLAG_ITALIC = 1 << 0 |
32 |
| -FT_STYLE_FLAG_BOLD = 1 << 1 |
| 19 | +# these globals are used to access the style_flags and face_flags |
| 20 | +FT_STYLE_FLAGS = ( |
| 21 | + ('Italics', 0), |
| 22 | + ('Bold', 1) |
| 23 | +) |
| 24 | + |
| 25 | +FT_FACE_FLAGS = ( |
| 26 | + ('Scalable', 0), |
| 27 | + ('Fixed sizes', 1), |
| 28 | + ('Fixed width', 2), |
| 29 | + ('SFNT', 3), |
| 30 | + ('Horizontal', 4), |
| 31 | + ('Vertical', 5), |
| 32 | + ('Kerning', 6), |
| 33 | + ('Fast glyphs', 7), |
| 34 | + ('Mult. masters', 8), |
| 35 | + ('Glyph names', 9), |
| 36 | + ('External stream', 10) |
| 37 | +) |
| 38 | + |
33 | 39 |
|
34 | 40 | print('Num faces :', font.num_faces) # number of faces in file
|
35 | 41 | print('Num glyphs :', font.num_glyphs) # number of glyphs in the face
|
|
60 | 66 | # vertical thickness of the underline
|
61 | 67 | print('Underline thickness :', font.underline_thickness)
|
62 | 68 |
|
63 |
| -print('Italics :', font.style_flags & FT_STYLE_FLAG_ITALIC != 0) |
64 |
| -print('Bold :', font.style_flags & FT_STYLE_FLAG_BOLD != 0) |
65 |
| -print('Scalable :', font.style_flags & FT_FACE_FLAG_SCALABLE != 0) |
66 |
| -print('Fixed sizes :', font.style_flags & FT_FACE_FLAG_FIXED_SIZES != 0) |
67 |
| -print('Fixed width :', font.style_flags & FT_FACE_FLAG_FIXED_WIDTH != 0) |
68 |
| -print('SFNT :', font.style_flags & FT_FACE_FLAG_SFNT != 0) |
69 |
| -print('Horizontal :', font.style_flags & FT_FACE_FLAG_HORIZONTAL != 0) |
70 |
| -print('Vertical :', font.style_flags & FT_FACE_FLAG_VERTICAL != 0) |
71 |
| -print('Kerning :', font.style_flags & FT_FACE_FLAG_KERNING != 0) |
72 |
| -print('Fast glyphs :', font.style_flags & FT_FACE_FLAG_FAST_GLYPHS != 0) |
73 |
| -print('Mult. masters :', font.style_flags & FT_FACE_FLAG_MULTIPLE_MASTERS != 0) |
74 |
| -print('Glyph names :', font.style_flags & FT_FACE_FLAG_GLYPH_NAMES != 0) |
| 69 | +for desc, val in FT_STYLE_FLAGS: |
| 70 | + print('%-16s:' % desc, bool(font.style_flags & (1 << val))) |
| 71 | +for desc, val in FT_FACE_FLAGS: |
| 72 | + print('%-16s:' % desc, bool(font.style_flags & (1 << val))) |
75 | 73 |
|
76 | 74 | print(dir(font))
|
77 | 75 |
|
|
0 commit comments