@@ -682,6 +682,30 @@ def test_ft2font_get_sfnt_table(font_name, header):
682
682
assert font .get_sfnt_table (header ) == _expected_sfnt_tables [font_name ][header ]
683
683
684
684
685
+ @pytest .mark .parametrize ('left, right, unscaled, unfitted, default' , [
686
+ # These are all the same class.
687
+ ('A' , 'A' , 57 , 248 , 256 ), ('A' , 'À' , 57 , 248 , 256 ), ('A' , 'Á' , 57 , 248 , 256 ),
688
+ ('A' , 'Â' , 57 , 248 , 256 ), ('A' , 'Ã' , 57 , 248 , 256 ), ('A' , 'Ä' , 57 , 248 , 256 ),
689
+ # And a few other random ones.
690
+ ('D' , 'A' , - 36 , - 156 , - 128 ), ('T' , '.' , - 243 , - 1056 , - 1024 ),
691
+ ('X' , 'C' , - 149 , - 647 , - 640 ), ('-' , 'J' , 114 , 495 , 512 ),
692
+ ])
693
+ def test_ft2font_get_kerning (left , right , unscaled , unfitted , default ):
694
+ file = fm .findfont ('DejaVu Sans' )
695
+ # With unscaled, these settings should produce exact values found in FontForge.
696
+ font = ft2font .FT2Font (file , hinting_factor = 1 , _kerning_factor = 0 )
697
+ font .set_size (100 , 100 )
698
+ assert font .get_kerning (font .get_char_index (ord (left )),
699
+ font .get_char_index (ord (right )),
700
+ ft2font .KERNING_UNSCALED ) == unscaled
701
+ assert font .get_kerning (font .get_char_index (ord (left )),
702
+ font .get_char_index (ord (right )),
703
+ ft2font .KERNING_UNFITTED ) == unfitted
704
+ assert font .get_kerning (font .get_char_index (ord (left )),
705
+ font .get_char_index (ord (right )),
706
+ ft2font .KERNING_DEFAULT ) == default
707
+
708
+
685
709
@pytest .mark .parametrize ('family_name, file_name' ,
686
710
[("WenQuanYi Zen Hei" , "wqy-zenhei.ttc" ),
687
711
("Noto Sans CJK JP" , "NotoSansCJK.ttc" ),
0 commit comments