|
8 | 8 | load_char
|
9 | 9 | """
|
10 | 10 | import matplotlib
|
11 |
| -from matplotlib.ft2font import FT2Font |
| 11 | +import matplotlib.ft2font as ft |
| 12 | + |
12 | 13 |
|
13 | 14 | #fname = '/usr/local/share/matplotlib/VeraIt.ttf'
|
14 | 15 | fname = matplotlib.get_data_path() + '/fonts/ttf/VeraIt.ttf'
|
15 | 16 | #fname = '/usr/local/share/matplotlib/cmr10.ttf'
|
16 | 17 |
|
17 |
| -font = FT2Font(fname) |
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 |
| 18 | +font = ft.FT2Font(fname) |
33 | 19 |
|
34 | 20 | print('Num faces :', font.num_faces) # number of faces in file
|
35 | 21 | print('Num glyphs :', font.num_glyphs) # number of glyphs in the face
|
|
59 | 45 | # vertical thickness of the underline
|
60 | 46 | print('Underline thickness :', font.underline_thickness)
|
61 | 47 |
|
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) |
| 48 | +for style in ('Italic', |
| 49 | + 'Bold', |
| 50 | + 'Scalable', |
| 51 | + 'Fixed sizes', |
| 52 | + 'Fixed width', |
| 53 | + 'SFNT', |
| 54 | + 'Horizontal', |
| 55 | + 'Vertical', |
| 56 | + 'Kerning', |
| 57 | + 'Fast glyphs', |
| 58 | + 'Multiple masters', |
| 59 | + 'Glyph names', |
| 60 | + 'External stream'): |
| 61 | + bitpos = getattr(ft, style.replace(' ', '_').upper()) - 1 |
| 62 | + print('%-17s:' % style, bool(font.style_flags & (1 << bitpos))) |
74 | 63 |
|
75 | 64 | print(dir(font))
|
76 | 65 |
|
|
0 commit comments