@@ -243,14 +243,13 @@ def _transformer(cls, tokens, slant, extend):
243243 def fontname (name ):
244244 result = name
245245 if slant :
246- result += b'_Slant_' + str ( int (1000 * slant )). encode ( 'ascii' )
246+ result += b'_Slant_%d' % int (1000 * slant )
247247 if extend != 1.0 :
248- result += b'_Extend_' + str ( int (1000 * extend )). encode ( 'ascii' )
248+ result += b'_Extend_%d' % int (1000 * extend )
249249 return result
250250
251251 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 )
254253
255254 def fontmatrix (array ):
256255 array = array .lstrip (b'[' ).rstrip (b']' ).split ()
@@ -264,19 +263,21 @@ def fontmatrix(array):
264263 newmatrix = np .dot (modifier , oldmatrix )
265264 array [::2 ] = newmatrix [0 :3 , 0 ]
266265 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.
267268 as_string = '[' + ' ' .join (str (x ) for x in array ) + ']'
268269 return as_string .encode ('latin-1' )
269270
270271 def replace (fun ):
271272 def replacer (tokens ):
272273 token , value = next (tokens ) # name, e.g., /FontMatrix
273- yield bytes ( value )
274+ yield value
274275 token , value = next (tokens ) # possible whitespace
275276 while token is _TokenType .whitespace :
276- yield bytes ( value )
277+ yield value
277278 token , value = next (tokens )
278279 if value != b'[' : # name/number/etc.
279- yield bytes ( fun (value ) )
280+ yield fun (value )
280281 else : # array, e.g., [1 2 3]
281282 result = b''
282283 while value != b']' :
@@ -298,9 +299,8 @@ def suppress(tokens):
298299
299300 for token , value in tokens :
300301 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 ))
304304 else :
305305 yield value
306306
0 commit comments