| 
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  | 
 | 
59 | 65 |     # vertical thickness of the underline  | 
60 | 66 |     print('Underline thickness :', font.underline_thickness)  | 
61 | 67 | 
 
  | 
62 |  | -print('Italics       :', font.style_flags & FT_STYLE_FLAG_ITALIC          != 0)  | 
63 |  | -print('Bold          :', font.style_flags & FT_STYLE_FLAG_BOLD            != 0)  | 
64 |  | -print('Scalable      :', font.style_flags & FT_FACE_FLAG_SCALABLE         != 0)  | 
65 |  | -print('Fixed sizes   :', font.style_flags & FT_FACE_FLAG_FIXED_SIZES      != 0)  | 
66 |  | -print('Fixed width   :', font.style_flags & FT_FACE_FLAG_FIXED_WIDTH      != 0)  | 
67 |  | -print('SFNT          :', font.style_flags & FT_FACE_FLAG_SFNT             != 0)  | 
68 |  | -print('Horizontal    :', font.style_flags & FT_FACE_FLAG_HORIZONTAL       != 0)  | 
69 |  | -print('Vertical      :', font.style_flags & FT_FACE_FLAG_VERTICAL         != 0)  | 
70 |  | -print('Kerning       :', font.style_flags & FT_FACE_FLAG_KERNING          != 0)  | 
71 |  | -print('Fast glyphs   :', font.style_flags & FT_FACE_FLAG_FAST_GLYPHS      != 0)  | 
72 |  | -print('Mult. masters :', font.style_flags & FT_FACE_FLAG_MULTIPLE_MASTERS != 0)  | 
73 |  | -print('Glyph names   :', font.style_flags & FT_FACE_FLAG_GLYPH_NAMES      != 0)  | 
 | 68 | +for desc, val in FT_STYLE_FLAGS:  | 
 | 69 | +    print('%-16s:' % desc, bool(font.style_flags & (1 << val)))  | 
 | 70 | +for desc, val in FT_FACE_FLAGS:  | 
 | 71 | +    print('%-16s:' % desc, bool(font.style_flags & (1 << val)))  | 
74 | 72 | 
 
  | 
75 | 73 | print(dir(font))  | 
76 | 74 | 
 
  | 
 | 
0 commit comments