File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed
Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change @@ -160,6 +160,22 @@ def test_ft2font_invalid_args(tmp_path):
160160 ft2font .FT2Font (file , _kerning_factor = 1.3 )
161161
162162
163+ def test_ft2font_clear ():
164+ file = fm .findfont ('DejaVu Sans' )
165+ font = ft2font .FT2Font (file )
166+ assert font .get_num_glyphs () == 0
167+ assert font .get_width_height () == (0 , 0 )
168+ assert font .get_bitmap_offset () == (0 , 0 )
169+ font .set_text ('ABabCDcd' )
170+ assert font .get_num_glyphs () == 8
171+ assert font .get_width_height () != (0 , 0 )
172+ assert font .get_bitmap_offset () != (0 , 0 )
173+ font .clear ()
174+ assert font .get_num_glyphs () == 0
175+ assert font .get_width_height () == (0 , 0 )
176+ assert font .get_bitmap_offset () == (0 , 0 )
177+
178+
163179@pytest .mark .parametrize ('family_name, file_name' ,
164180 [("WenQuanYi Zen Hei" , "wqy-zenhei.ttc" ),
165181 ("Noto Sans CJK JP" , "NotoSansCJK.ttc" ),
Original file line number Diff line number Diff line change @@ -304,8 +304,9 @@ FT2Font::~FT2Font()
304304
305305void FT2Font::clear ()
306306{
307- pen.x = 0 ;
308- pen.y = 0 ;
307+ pen.x = pen.y = 0 ;
308+ bbox.xMin = bbox.yMin = bbox.xMax = bbox.yMax = 0 ;
309+ advance = 0 ;
309310
310311 for (size_t i = 0 ; i < glyphs.size (); i++) {
311312 FT_Done_Glyph (glyphs[i]);
You can’t perform that action at this time.
0 commit comments