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

Function test_ft2font_drawing

lib/matplotlib/tests/test_ft2font.py:920–950  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

918
919
920def test_ft2font_drawing():
921 expected_str = (
922 ' ',
923 '11 11 ',
924 '11 11 ',
925 '1 1 1 1 ',
926 '1 1 1 1 ',
927 '1 1 1 1 ',
928 '1 11 1 ',
929 '1 11 1 ',
930 '1 1 ',
931 '1 1 ',
932 ' ',
933 )
934 expected = np.array([
935 [int(c) for c in line.replace(' ', '0')] for line in expected_str
936 ])
937 expected *= 255
938 file = fm.findfont('DejaVu Sans')
939 font = ft2font.FT2Font(file)
940 font.set_size(12, 72)
941 font.set_text('M')
942 font.draw_glyphs_to_bitmap(antialiased=False)
943 image = font.get_image()
944 np.testing.assert_array_equal(image, expected)
945 font = ft2font.FT2Font(file)
946 font.set_size(12, 72)
947 glyph = font.load_char(ord('M'))
948 image = np.zeros(expected.shape, np.uint8)
949 font.draw_glyph_to_bitmap(image, -1, 1, glyph, antialiased=False)
950 np.testing.assert_array_equal(image, expected)
951
952
953def test_ft2font_get_path():

Callers

nothing calls this directly

Calls 3

findfontMethod · 0.80
set_sizeMethod · 0.45
set_textMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…