@@ -29,7 +29,7 @@ def test_Type1Font():
29
29
'+ /FontName /CMR10_Slant_1000 def' ,
30
30
# Alters FontMatrix
31
31
'- /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' ,
33
33
# Alters ItalicAngle
34
34
'- /ItalicAngle 0 def' ,
35
35
'+ /ItalicAngle -45.0 def' ):
@@ -47,5 +47,23 @@ def test_Type1Font():
47
47
'+ /FontName /CMR10_Extend_500 def' ,
48
48
# Alters FontMatrix
49
49
'- /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' ):
51
51
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