10000 TST: Add test for FT2Font.set_size · matplotlib/matplotlib@f618fc2 · GitHub
[go: up one dir, main page]

Skip to content

Commit f618fc2

Browse files
committed
TST: Add test for FT2Font.set_size
1 parent 833a259 commit f618fc2

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

lib/matplotlib/tests/test_ft2font.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,20 @@ def test_ft2font_clear():
176176
assert font.get_bitmap_offset() == (0, 0)
177177

178178

179+
def test_ft2font_set_size():
180+
file = fm.findfont('DejaVu Sans')
181+
# Default is 12pt @ 72 dpi.
182+
font = ft2font.FT2Font(file, hinting_factor=1, _kerning_factor=1)
183+
font.set_text('ABabCDcd')
184+
orig = font.get_width_height()
185+
font.set_size(24, 72)
186+
font.set_text('ABabCDcd')
187+
assert font.get_width_height() == tuple(pytest.approx(2 * x, 1e-1) for x in orig)
188+
font.set_size(12, 144)
189+
font.set_text('ABabCDcd')
190+
assert font.get_width_height() == tuple(pytest.approx(2 * x, 1e-1) for x in orig)
191+
192+
179193
def test_ft2font_charmaps():
180194
def enc(name):
181195
# We don't expose the encoding enum from FreeType, but can generate it here.

0 commit comments

Comments
 (0)
0