| 951 | |
| 952 | |
| 953 | def test_ft2font_get_path(): |
| 954 | file = fm.findfont('DejaVu Sans') |
| 955 | font = ft2font.FT2Font(file) |
| 956 | font.set_size(12, 72) |
| 957 | vertices, codes = font.get_path() |
| 958 | assert vertices.shape == (0, 2) |
| 959 | assert codes.shape == (0, ) |
| 960 | font.load_char(ord('M')) |
| 961 | vertices, codes = font.get_path() |
| 962 | expected_vertices = np.array([ |
| 963 | (0.843750, 9.000000), (2.609375, 9.000000), # Top left. |
| 964 | (4.906250, 2.875000), # Top of midpoint. |
| 965 | (7.218750, 9.000000), (8.968750, 9.000000), # Top right. |
| 966 | (8.968750, 0.000000), (7.843750, 0.000000), # Bottom right. |
| 967 | (7.843750, 7.906250), # Point under top right. |
| 968 | (5.531250, 1.734375), (4.296875, 1.734375), # Bar under midpoint. |
| 969 | (1.984375, 7.906250), # Point under top left. |
| 970 | (1.984375, 0.000000), (0.843750, 0.000000), # Bottom left. |
| 971 | (0.843750, 9.000000), # Back to top left corner. |
| 972 | (0.000000, 0.000000), |
| 973 | ]) |
| 974 | np.testing.assert_array_equal(vertices, expected_vertices) |
| 975 | expected_codes = np.full(expected_vertices.shape[0], mpath.Path.LINETO, |
| 976 | dtype=mpath.Path.code_type) |
| 977 | expected_codes[0] = mpath.Path.MOVETO |
| 978 | expected_codes[-1] = mpath.Path.CLOSEPOLY |
| 979 | np.testing.assert_array_equal(codes, expected_codes) |
| 980 | |
| 981 | |
| 982 | @pytest.mark.parametrize('fmt', ['pdf', 'png', 'ps', 'raw', 'svg']) |