File tree 1 file changed +18
-27
lines changed
1 file changed +18
-27
lines changed Original file line number Diff line number Diff line change 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 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
10000
- ('Glyph names' , 9 ),
36
- ('External stream' , 10 )
37
- )
38
-
18
+ font = ft .FT2Font (fname )
39
19
40
20
print ('Num faces :' , font .num_faces ) # number of faces in file
41
21
print ('Num glyphs :' , font .num_glyphs ) # number of glyphs in the face
65
45
# vertical thickness of the underline
66
46
print ('Underline thickness :' , font .underline_thickness )
67
47
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 )))
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 )))
72
63
73
64
print (dir (font ))
74
65
You can’t perform that action at this time.
0 commit comments