@@ -1180,13 +1180,11 @@ def embedTTFType3(font, characters, descriptor):
1180
1180
'Widths' : widthsObject
1181
1181
}
1182
1182
1183
- from encodings import cp1252
1184
-
1185
1183
# Make the "Widths" array
1186
1184
def get_char_width (charcode ):
1187
- s = ord (cp1252 .decoding_table [charcode ])
1188
1185
width = font .load_char (
1189
- s , flags = LoadFlags .NO_SCALE | LoadFlags .NO_HINTING ).horiAdvance
1186
+ charcode ,
1187
+ flags = LoadFlags .NO_SCALE | LoadFlags .NO_HINTING ).horiAdvance
1190
1188
return cvt (width )
1191
1189
with warnings .catch_warnings ():
1192
1190
# Ignore 'Required glyph missing from current font' warning
@@ -2331,9 +2329,13 @@ def draw_tex(self, gc, x, y, s, prop, angle, *, mtext=None):
2331
2329
self .draw_path (boxgc , path , mytrans , gc ._rgb )
2332
2330
2333
2331
def encode_string (self , s , fonttype ):
2334
- if fonttype in (1 , 3 ):
2335
- return s .encode ('cp1252' , 'replace' )
2336
- return s .encode ('utf-16be' , 'replace' )
2332
+ match fonttype :
2333
+ case 1 :
2334
+ return s .encode ('cp1252' , 'replace' )
2335
+ case 3 :
2336
+ return s .encode ('latin-1' , 'replace' )
2337
+ case _:
2338
+ return s .encode ('utf-16be' , 'replace' )
2337
2339
2338
2340
def draw_text (self , gc , x , y , s , prop , angle , ismath = False , mtext = None ):
2339
2341
# docstring inherited
0 commit comments