@@ -243,14 +243,13 @@ def _transformer(cls, tokens, slant, extend):
243
243
def fontname (name ):
244
244
result = name
245
245
if slant :
246
- result += b'_Slant_' + str ( int (1000 * slant )). encode ( 'ascii' )
246
+ result += b'_Slant_%d' % int (1000 * slant )
247
247
if extend != 1.0 :
248
- result += b'_Extend_' + str ( int (1000 * extend )). encode ( 'ascii' )
248
+ result += b'_Extend_%d' % int (1000 * extend )
249
249
return result
250
250
251
251
def italicangle (angle ):
252
- return (str (float (angle ) - np .arctan (slant ) / np .pi * 180 )
253
- .encode ('ascii' ))
252
+ return b'%a' % (float (angle ) - np .arctan (slant ) / np .pi * 180 )
254
253
255
254
def fontmatrix (array ):
256
255
array = array .lstrip (b'[' ).rstrip (b']' ).split ()
@@ -264,19 +263,21 @@ def fontmatrix(array):
264
263
newmatrix = np .dot (modifier , oldmatrix )
265
264
array [::2 ] = newmatrix [0 :3 , 0 ]
266
265
array [1 ::2 ] = newmatrix [0 :3 , 1 ]
266
+ # Not directly using `b'%a' % x for x in array` for now as that
267
+ # produces longer reprs on numpy<1.14, causing test failures.
267
268
as_string = '[' + ' ' .join (str (x ) for x in array ) + ']'
268
269
return as_string .encode ('latin-1' )
269
270
270
271
def replace (fun ):
271
272
def replacer (tokens ):
272
273
token , value = next (tokens ) # name, e.g., /FontMatrix
273
- yield bytes ( value )
274
+ yield value
274
275
token , value = next (tokens ) # possible whitespace
275
276
while token is _TokenType .whitespace :
276
- yield bytes ( value )
277
+ yield value
277
278
token , value = next (tokens )
278
279
if value != b'[' : # name/number/etc.
279
- yield bytes ( fun (value ) )
280
+ yield fun (value )
280
281
else : # array, e.g., [1 2 3]
281
282
result = b''
282
283
while value != b']' :
@@ -298,9 +299,8 @@ def suppress(tokens):
298
299
299
300
for token , value in tokens :
300
301
if token is _TokenType .name and value in table :
301
- for value in table [value ](itertools .chain ([(token , value )],
302
- tokens )):
303
- yield value
302
+ yield from table [value ](
303
+ itertools .chain ([(token , value )], tokens ))
304
304
else :
305
305
yield value
306
306
0 commit comments