Skip to content

Commit c2a0c5e

Browse files
committed
TST: Add tests for FT2Font.get_kerning
1 parent 3ad25a7 commit c2a0c5e

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

lib/matplotlib/tests/test_ft2font.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -678,6 +678,29 @@ def test_ft2font_get_sfnt_table(font_name, header):
678678
assert font.get_sfnt_table(header) == _expected_sfnt_tables[font_name][header]
679679

680680

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

0 commit comments

Comments
 (0)