8000 TST: Add tests for FT2Font.get_kerning · matplotlib/matplotlib@3748c99 · GitHub
[go: up one dir, main page]

Skip to content

Commit 3748c99

Browse files
committed
TST: Add tests for FT2Font.get_kerning
1 parent 2754aaa commit 3748c99

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

lib/matplotlib/tests/test_ft2font.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -682,6 +682,30 @@ def test_ft2font_get_sfnt_table(font_name, header):
682682
assert font.get_sfnt_table(header) == _expected_sfnt_tables[font_name][header]
683683

684684

685+
@pytest.mark.parametrize('left, right, unscaled, unfitted, default', [
686+
# These are all the same class.
687+
('A', 'A', 57, 248, 256), ('A', 'À', 57, 248, 256), ('A', 'Á', 57, 248, 256),
688+
('A', 'Â', 57, 248, 256), ('A', 'Ã', 57, 248, 256), ('A', 'Ä', 57, 248, 256),
689+
# And a few other random ones.
690+
('D', 'A', -36, -156, -128), ('T', '.', -243, -1056, -1024),
691+
('X', 'C', -149, -647, -640), ('-', 'J', 114, 495, 512),
692+
])
693+
def test_ft2font_get_kerning(left, right, unscaled, unfitted, default):
694+
file = fm.findfont('DejaVu Sans')
695+
# With unscaled, these settings should produce exact values found in FontForge.
696+
font = ft2font.FT2Font(file, hinting_factor=1, _kerning_factor=0)
697+
font.set_size(100, 100)
698+
assert font.get_kerning(font.get_char_index(ord(left)),
699+
font.get_char_index(ord(right)),
700+
ft2font.KERNING_UNSCALED) == unscaled
701+
assert font.get_kerning(font.get_char_index(ord(left)),
702+
font.get_char_index(ord(right)),
703+
ft2font.KERNING_UNFITTED) == unfitted
704+
assert font.get_kerning(font.get_char_index(ord(left)),
705+
font.get_char_index(ord(right)),
706+
ft2font.KERNING_DEFAULT) == default
707+
708+
685709
@pytest.mark.parametrize('family_name, file_name',
686710
[("WenQuanYi Zen Hei", "wqy-zenhei.ttc"),
687711
("Noto Sans CJK JP", "NotoSansCJK.ttc"),

0 commit comments

Comments
 (0)
0