| 918 | |
| 919 | |
| 920 | def 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 | |
| 953 | def test_ft2font_get_path(): |