@@ -323,18 +323,18 @@ def pdfRepr(obj):
323323 .format (type (obj )))
324324
325325
326- def _font_supports_char (fonttype , char ):
326+ def _font_supports_glyph (fonttype , glyph ):
327327 """
328- Returns True if the font is able to provide *char * in a PDF.
328+ Returns True if the font is able to provide codepoint *glyph * in a PDF.
329329
330330 For a Type 3 font, this method returns True only for single-byte
331- chars. For Type 42 fonts this method return True if the char is from
332- the Basic Multilingual Plane.
331+ characters. For Type 42 fonts this method return True if the character is
332+ from the Basic Multilingual Plane.
333333 """
334334 if fonttype == 3 :
335- return ord ( char ) <= 255
335+ return glyph <= 255
336336 if fonttype == 42 :
337- return ord ( char ) <= 65535
337+ return glyph <= 65535
338338 raise NotImplementedError ()
339339
340340
@@ -1227,13 +1227,9 @@ def embedTTFType42(font, characters, descriptor):
12271227 wObject = self .reserveObject ('Type 0 widths' )
12281228 toUnicodeMapObject = self .reserveObject ('ToUnicode map' )
12291229
1230- _log .debug (
1231- "SUBSET %s characters: %s" ,
1232- filename , "" .join (chr (c ) for c in characters )
1233- )
1234- fontdata = _backend_pdf_ps .get_glyphs_subset (
1235- filename , "" .join (chr (c ) for c in characters )
1236- )
1230+ subset_str = "" .join (chr (c ) for c in characters )
1231+ _log .debug ("SUBSET %s characters: %s" , filename , subset_str )
1232+ fontdata = _backend_pdf_ps .get_glyphs_subset (filename , subset_str )
12371233 _log .debug (
12381234 "SUBSET %s %d -> %d" , filename ,
12391235 os .stat (filename ).st_size , fontdata .getbuffer ().nbytes
@@ -1327,7 +1323,7 @@ def embedTTFType42(font, characters, descriptor):
13271323 # Add XObjects for unsupported chars
13281324 glyph_ids = []
13291325 for ccode in characters :
1330- if not _font_supports_char (fonttype , chr ( ccode ) ):
1326+ if not _font_supports_glyph (fonttype , ccode ):
13311327 gind = full_font .get_char_index (ccode )
13321328 glyph_ids .append (gind )
13331329
@@ -2193,10 +2189,9 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):
21932189
21942190 self .file .output (Op .begin_text )
21952191 for font , fontsize , num , ox , oy in glyphs :
2196- char = chr (num )
2197- self .file ._character_tracker .track (font , char )
2192+ self .file ._character_tracker .track_glyph (font , num )
21982193 fontname = font .fname
2199- if not _font_supports_char (fonttype , char ):
2194+ if not _font_supports_glyph (fonttype , num ):
22002195 # Unsupported chars (i.e. multibyte in Type 3 or beyond BMP in
22012196 # Type 42) must be emitted separately (below).
22022197 unsupported_chars .append ((font , fontsize , ox , oy , num ))
@@ -2383,7 +2378,7 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
23832378 prev_was_multibyte = True
23842379 for item in _text_helpers .layout (
23852380 s , font , kern_mode = KERNING_UNFITTED ):
2386- if _font_supports_char (fonttype , item .char ):
2381+ if _font_supports_glyph (fonttype , ord ( item .char ) ):
23872382 if prev_was_multibyte :
23882383 singlebyte_chunks .append ((item .x , []))
23892384 if item .prev_kern :
0 commit comments