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

Commit 7c390de

Browse filesBrowse files
committed
TST: Add tests for FT2Font.load_{char,glyph}
1 parent f618fc2 commit 7c390de
Copy full SHA for 7c390de

File tree

Expand file treeCollapse file tree

1 file changed

+23
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+23
-0
lines changed

‎lib/matplotlib/tests/test_ft2font.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_ft2font.py
+23Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -741,6 +741,29 @@ def test_ft2font_set_text():
741741
assert font.get_bitmap_offset() == (6, 0)
742742

743743

744+
def test_ft2font_loading():
745+
file = fm.findfont('DejaVu Sans')
746+
font = ft2font.FT2Font(file, hinting_factor=1, _kerning_factor=0)
747+
for glyph in [font.load_char(ord('M')),
748+
font.load_glyph(font.get_char_index(ord('M')))]:
749+
assert glyph is not None
750+
assert glyph.width == 576
751+
assert glyph.height == 576
752+
assert glyph.horiBearingX == 0
753+
assert glyph.horiBearingY == 576
754+
assert glyph.horiAdvance == 640
755+
assert glyph.linearHoriAdvance == 678528
756+
assert glyph.vertBearingX == -384
757+
assert glyph.vertBearingY == 64
758+
assert glyph.vertAdvance == 832
759+
assert glyph.bbox == (54, 0, 574, 576)
760+
assert font.get_num_glyphs() == 2 # Both count as loaded.
761+
# But neither has been placed anywhere.
762+
assert font.get_width_height() == (0, 0)
763+
assert font.get_descent() == 0
764+
assert font.get_bitmap_offset() == (0, 0)
765+
766+
744767
@pytest.mark.parametrize('family_name, file_name',
745768
[("WenQuanYi Zen Hei", "wqy-zenhei.ttc"),
746769
("Noto Sans CJK JP", "NotoSansCJK.ttc"),

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.