Skip to content

Commit 11f8d5d

Browse files
committed
pdf: Fix first-block characters using multiple glyph representations
If mixing languages, sometimes a single character may use different glyphs in one document. In that case, we need to give it a new character code in the next subset, since subset 0 is preserving character codes.
1 parent f7a3c1c commit 11f8d5d

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

lib/matplotlib/backends/_backend_pdf_ps.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,15 @@ def track_glyph(
251251
# Default to preserving the character code as it was.
252252
use_next_charmap = (
253253
self.subset_size != 0
254-
# But start filling a new subset if outside the first block; this preserves
255-
# ASCII (for Type 3) or the Basic Multilingual Plane (for Type 42).
256-
and charcode >= self.subset_size
254+
and (
255+
# But start filling a new subset if outside the first block; this
256+
# preserves ASCII (for Type 3) or the Basic Multilingual Plane (for
257+
# Type 42).
258+
charcode >= self.subset_size
259+
# Or, use a new subset if the character code is already mapped for the
260+
# first block. This means it's using an alternate glyph.
261+
or charcode in subset_maps[0]
262+
)
257263
)
258264
if use_next_charmap:
259265
if len(subset_maps) == 1 or len(subset_maps[-1]) == self.subset_size:

0 commit comments

Comments
 (0)