File tree Expand file tree Collapse file tree 1 file changed +18
-27
lines changed Expand file tree Collapse file tree 1 file changed +18
-27
lines changed Original file line number Diff line number Diff line change 88load_char
99"""
1010import matplotlib
11- from matplotlib .ft2font import FT2Font
11+ import matplotlib .ft2font as ft
12+
1213
1314#fname = '/usr/local/share/matplotlib/VeraIt.ttf'
1415fname = matplotlib .get_data_path () + '/fonts/ttf/VeraIt.ttf'
1516#fname = '/usr/local/share/matplotlib/cmr10.ttf'
1617
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- ('Glyph names' , 9 ),
36- ('External stream' , 10 )
37- )
38-
18+ font = ft .FT2Font (fname )
3919
4020print ('Num faces :' , font .num_faces ) # number of faces in file
4121print ('Num glyphs :' , font .num_glyphs ) # number of glyphs in the face
6545 # vertical thickness of the underline
6646 print ('Underline thickness :' , font .underline_thickness )
6747
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 )))
7263
7364print (dir (font ))
7465
You can’t perform that action at this time.
0 commit comments