Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

pep8ify examples (part2) #3488

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
refactor ftface_props example
Signed-off-by: Thomas Hisch <t.hisch@gmail.com>
  • Loading branch information
twmr committed Sep 13, 2014
commit 7b4a3a9cb81dac0d8b6fbff09a3ca3f4b4c3d151
50 changes: 24 additions & 26 deletions 50 examples/misc/ftface_props.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,20 +16,26 @@

font = FT2Font(fname)

# these constants are used to access the style_flags and face_flags
FT_FACE_FLAG_SCALABLE = 1 << 0
FT_FACE_FLAG_FIXED_SIZES = 1 << 1
FT_FACE_FLAG_FIXED_WIDTH = 1 << 2
FT_FACE_FLAG_SFNT = 1 << 3
FT_FACE_FLAG_HORIZONTAL = 1 << 4
FT_FACE_FLAG_VERTICAL = 1 << 5
FT_FACE_FLAG_KERNING = 1 << 6
FT_FACE_FLAG_FAST_GLYPHS = 1 << 7
FT_FACE_FLAG_MULTIPLE_MASTERS = 1 << 8
FT_FACE_FLAG_GLYPH_NAMES = 1 << 9
FT_FACE_FLAG_EXTERNAL_STREAM = 1 << 10
FT_STYLE_FLAG_ITALIC = 1 << 0
FT_STYLE_FLAG_BOLD = 1 << 1
# these globals are used to access the style_flags and face_flags
FT_STYLE_FLAGS = (
('Italics', 0),
('Bold', 1)
)

FT_FACE_FLAGS = (
('Scalable', 0),
('Fixed sizes', 1),
('Fixed width', 2),
('SFNT', 3),
('Horizontal', 4),
('Vertical', 5),
('Kerning', 6),
('Fast glyphs', 7),
('Mult. masters', 8),
('Glyph names', 9),
('External stream', 10)
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you want me to convert these lists of tuples to lists of strings? I could use enumerate in the client code to get the indices.



print('Num faces :', font.num_faces) # number of faces in file
print('Num glyphs :', font.num_glyphs) # number of glyphs in the face
Expand Down Expand Up @@ -59,18 +65,10 @@
# vertical thickness of the underline
print('Underline thickness :', font.underline_thickness)

print('Italics :', font.style_flags & FT_STYLE_FLAG_ITALIC != 0)
print('Bold :', font.style_flags & FT_STYLE_FLAG_BOLD != 0)
print('Scalable :', font.style_flags & FT_FACE_FLAG_SCALABLE != 0)
print('Fixed sizes :', font.style_flags & FT_FACE_FLAG_FIXED_SIZES != 0)
print('Fixed width :', font.style_flags & FT_FACE_FLAG_FIXED_WIDTH != 0)
print('SFNT :', font.style_flags & FT_FACE_FLAG_SFNT != 0)
print('Horizontal :', font.style_flags & FT_FACE_FLAG_HORIZONTAL != 0)
print('Vertical :', font.style_flags & FT_FACE_FLAG_VERTICAL != 0)
print('Kerning :', font.style_flags & FT_FACE_FLAG_KERNING != 0)
print('Fast glyphs :', font.style_flags & FT_FACE_FLAG_FAST_GLYPHS != 0)
print('Mult. masters :', font.style_flags & FT_FACE_FLAG_MULTIPLE_MASTERS != 0)
print('Glyph names :', font.style_flags & FT_FACE_FLAG_GLYPH_NAMES != 0)
for desc, val in FT_STYLE_FLAGS:
print('%-16s:' % desc, bool(font.style_flags & (1 << val)))
for desc, val in FT_FACE_FLAGS:
print('%-16s:' % desc, bool(font.style_flags & (1 << val)))

print(dir(font))

Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.