@@ -29,7 +29,7 @@ def test_Type1Font():
2929 '+ /FontName /CMR10_Slant_1000 def' ,
3030 # Alters FontMatrix
3131 '- /FontMatrix [0.001 0 0 0.001 0 0 ]readonly def' ,
32- '+ /FontMatrix [0.001 0.0 0.001 0.001 0.0 0. 0]readonly def' ,
32+ '+ /FontMatrix [0.001 0 0.001 0.001 0 0]readonly def' ,
3333 # Alters ItalicAngle
3434 '- /ItalicAngle 0 def' ,
3535 '+ /ItalicAngle -45.0 def' ):
@@ -47,5 +47,23 @@ def test_Type1Font():
4747 '+ /FontName /CMR10_Extend_500 def' ,
4848 # Alters FontMatrix
4949 '- /FontMatrix [0.001 0 0 0.001 0 0 ]readonly def' ,
50- '+ /FontMatrix [0.0005 0.0 0.0 0.001 0.0 0. 0]readonly def' ):
50+ '+ /FontMatrix [0.0005 0 0 0.001 0 0]readonly def' ):
5151 assert line in diff , 'diff to condensed font must contain %s' % line
52+
53+
54+ def test_overprecision ():
55+ # We used to output too many digits in FontMatrix entries and
56+ # ItalicAngle, which could make Type-1 parsers unhappy.
57+ filename = os .path .join (os .path .dirname (__file__ ), 'cmr10.pfb' )
58+ font = t1f .Type1Font (filename )
59+ slanted = font .transform ({'slant' : .167 })
60+ lines = slanted .parts [0 ].decode ('ascii' ).splitlines ()
61+ matrix , = [line [line .index ('[' )+ 1 :line .index (']' )]
62+ for line in lines if '/FontMatrix' in line ]
63+ angle , = [word
64+ for line in lines if '/ItalicAngle' in line
65+ for word in line .split () if word [0 ] in '-0123456789' ]
66+ # the following used to include 0.00016700000000000002
67+ assert matrix == '0.001 0 0.000167 0.001 0 0'
68+ # and here we had -9.48090361795083
69+ assert angle == '-9.4809'
0 commit comments