MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / test_ft2font_get_kerning

Function test_ft2font_get_kerning

lib/matplotlib/tests/test_ft2font.py:803–840  ·  view source on GitHub ↗
(left, right, unscaled, unfitted, default)

Source from the content-addressed store, hash-verified

801 ('X', 'C', -149, -647, -640), ('-', 'J', 114, 495, 512),
802])
803def test_ft2font_get_kerning(left, right, unscaled, unfitted, default):
804 file = fm.findfont('DejaVu Sans')
805 # With unscaled, these settings should produce exact values found in FontForge.
806 font = ft2font.FT2Font(file)
807 font.set_size(100, 100)
808 assert font.get_kerning(font.get_char_index(ord(left)),
809 font.get_char_index(ord(right)),
810 ft2font.Kerning.UNSCALED) == unscaled
811 assert font.get_kerning(font.get_char_index(ord(left)),
812 font.get_char_index(ord(right)),
813 ft2font.Kerning.UNFITTED) == unfitted
814 assert font.get_kerning(font.get_char_index(ord(left)),
815 font.get_char_index(ord(right)),
816 ft2font.Kerning.DEFAULT) == default
817 with pytest.warns(mpl.MatplotlibDeprecationWarning,
818 match='Use Kerning.UNSCALED instead'):
819 k = ft2font.KERNING_UNSCALED
820 with pytest.warns(mpl.MatplotlibDeprecationWarning,
821 match='Use Kerning enum values instead'):
822 assert font.get_kerning(font.get_char_index(ord(left)),
823 font.get_char_index(ord(right)),
824 int(k)) == unscaled
825 with pytest.warns(mpl.MatplotlibDeprecationWarning,
826 match='Use Kerning.UNFITTED instead'):
827 k = ft2font.KERNING_UNFITTED
828 with pytest.warns(mpl.MatplotlibDeprecationWarning,
829 match='Use Kerning enum values instead'):
830 assert font.get_kerning(font.get_char_index(ord(left)),
831 font.get_char_index(ord(right)),
832 int(k)) == unfitted
833 with pytest.warns(mpl.MatplotlibDeprecationWarning,
834 match='Use Kerning.DEFAULT instead'):
835 k = ft2font.KERNING_DEFAULT
836 with pytest.warns(mpl.MatplotlibDeprecationWarning,
837 match='Use Kerning enum values instead'):
838 assert font.get_kerning(font.get_char_index(ord(left)),
839 font.get_char_index(ord(right)),
840 int(k)) == default
841
842
843def test_ft2font_set_text():

Callers

nothing calls this directly

Calls 4

findfontMethod · 0.80
get_char_indexMethod · 0.80
set_sizeMethod · 0.45
get_kerningMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…