35
35
from matplotlib .figure import Figure
36
36
from matplotlib .font_manager import get_font , fontManager as _fontManager
37
37
from matplotlib ._afm import AFM
38
- from matplotlib .ft2font import FT2Font , FaceFlags , Kerning , LoadFlags , StyleFlags
38
+ from matplotlib .ft2font import FT2Font , FaceFlags , LoadFlags , StyleFlags
39
39
from matplotlib .transforms import Affine2D , BboxBase
40
40
from matplotlib .path import Path
41
41
from matplotlib .dates import UTC
@@ -2355,7 +2355,6 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
2355
2355
fonttype = 1
2356
2356
else :
2357
2357
font = self ._get_font_ttf (prop )
2358
- self .file ._character_tracker .track (font , s )
2359
2358
fonttype = mpl .rcParams ['pdf.fonttype' ]
2360
2359
2361
2360
if gc .get_url () is not None :
@@ -2367,6 +2366,8 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
2367
2366
# If fonttype is neither 3 nor 42, emit the whole string at once
2368
2367
# without manual kerning.
2369
2368
if fonttype not in [3 , 42 ]:
2369
+ if not mpl .rcParams ['pdf.use14corefonts' ]:
2370
+ self .file ._character_tracker .track (font , s )
2370
2371
self .file .output (Op .begin_text ,
2371
2372
self .file .fontName (prop ), fontsize , Op .selectfont )
2372
2373
self ._setup_textpos (x , y , angle )
@@ -2394,9 +2395,11 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
2394
2395
prev_was_multibyte = True
2395
2396
prev_font = font
2396
2397
for item in _text_helpers .layout (s , font , features = features ,
2397
- kern_mode = Kerning .UNFITTED ,
2398
2398
language = language ):
2399
- if _font_supports_glyph (fonttype , ord (item .char )):
2399
+ self .file ._character_tracker .track_glyph (item .ft_object ,
2400
+ item .glyph_index )
2401
+ if (len (item .char ) == 1 and
2402
+ _font_supports_glyph (fonttype , ord (item .char ))):
2400
2403
if prev_was_multibyte or item .ft_object != prev_font :
2401
2404
singlebyte_chunks .append ((item .ft_object , item .x , []))
2402
2405
prev_font = item .ft_object
@@ -2431,15 +2434,15 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
2431
2434
prev_start_x = start_x
2432
2435
self .file .output (Op .end_text )
2433
2436
# Then emit all the multibyte characters, one at a time.
2434
- for ft_object , start_x , glyph_idx in multibyte_glyphs :
2437
+ for ft_object , start_x , glyph_index in multibyte_glyphs :
2435
2438
self ._draw_xobject_glyph (
2436
- ft_object , fontsize , glyph_idx , start_x , 0
2439
+ ft_object , fontsize , glyph_index , start_x , 0
2437
2440
)
2438
2441
self .file .output (Op .grestore )
2439
2442
2440
- def _draw_xobject_glyph (self , font , fontsize , glyph_idx , x , y ):
2443
+ def _draw_xobject_glyph (self , font , fontsize , glyph_index , x , y ):
2441
2444
"""Draw a multibyte character from a Type 3 font as an XObject."""
2442
- glyph_name = font .get_glyph_name (glyph_idx )
2445
+ glyph_name = font .get_glyph_name (glyph_index )
2443
2446
name = self .file ._get_xobject_glyph_name (font .fname , glyph_name )
2444
2447
self .file .output (
2445
2448
Op .gsave ,
0 commit comments