99from functools import total_ordering
1010from io import BytesIO
1111import logging
12- from math import ceil , cos , floor , pi , sin
12+ import math
1313import os
1414import re
1515import struct
16- import sys
1716import time
1817import types
1918import warnings
@@ -890,9 +889,9 @@ def cvt(length, upe=font.units_per_EM, nearest=True):
890889 # Perhaps best to round away from zero for bounding
891890 # boxes and the like
892891 if value < 0 :
893- return floor (value )
892+ return math . floor (value )
894893 else :
895- return ceil (value )
894+ return math . ceil (value )
896895
897896 def embedTTFType3 (font , characters , descriptor ):
898897 """The Type 3-specific part of embedding a Truetype font"""
@@ -1818,9 +1817,9 @@ def _setup_textpos(self, x, y, angle, oldx=0, oldy=0, oldangle=0):
18181817 if angle == oldangle == 0 :
18191818 self .file .output (x - oldx , y - oldy , Op .textpos )
18201819 else :
1821- angle = angle / 180.0 * pi
1822- self .file .output (cos (angle ), sin (angle ),
1823- - sin (angle ), cos (angle ),
1820+ angle = math . radians ( angle )
1821+ self .file .output (math . cos (angle ), math . sin (angle ),
1822+ - math . sin (angle ), math . cos (angle ),
18241823 x , y , Op .textmatrix )
18251824 self .file .output (0 , 0 , Op .textpos )
18261825
@@ -1836,10 +1835,11 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):
18361835 global_fonttype = rcParams ['pdf.fonttype' ]
18371836
18381837 # Set up a global transformation matrix for the whole math expression
1839- a = angle / 180.0 * pi
1838+ a = math . radians ( angle )
18401839 self .file .output (Op .gsave )
1841- self .file .output (cos (a ), sin (a ), - sin (a ), cos (a ), x , y ,
1842- Op .concat_matrix )
1840+ self .file .output (math .cos (a ), math .sin (a ),
1841+ - math .sin (a ), math .cos (a ),
1842+ x , y , Op .concat_matrix )
18431843
18441844 self .check_gc (gc , gc ._rgb )
18451845 self .file .output (Op .begin_text )
@@ -2058,9 +2058,10 @@ def draw_text_woven(chunks):
20582058 # Do the rotation and global translation as a single matrix
20592059 # concatenation up front
20602060 self .file .output (Op .gsave )
2061- a = angle / 180.0 * pi
2062- self .file .output (cos (a ), sin (a ), - sin (a ), cos (a ), x , y ,
2063- Op .concat_matrix )
2061+ a = math .radians (angle )
2062+ self .file .output (math .cos (a ), math .sin (a ),
2063+ - math .sin (a ), math .cos (a ),
2064+ x , y , Op .concat_matrix )
20642065
20652066 # Output all the 1-byte characters in a BT/ET group, then
20662067 # output all the 2-byte characters.
0 commit comments