FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

pdf: Simplify Type 3 font character encoding by QuLogic · Pull Request #30520 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
16 changes: 9 additions & 7 deletions lib/matplotlib/backends/backend_pdf.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -1180,13 +1180,11 @@ def embedTTFType3(font, characters, descriptor):
'Widths': widthsObject
}

from encodings import cp1252

# Make the "Widths" array
def get_char_width(charcode):
s = ord(cp1252.decoding_table[charcode])
width = font.load_char(
s, flags=LoadFlags.NO_SCALE | LoadFlags.NO_HINTING).horiAdvance
charcode,
flags=LoadFlags.NO_SCALE | LoadFlags.NO_HINTING).horiAdvance
return cvt(width)
with warnings.catch_warnings():
# Ignore 'Required glyph missing from current font' warning
Expand Down Expand Up @@ -2331,9 +2329,13 @@ def draw_tex(self, gc, x, y, s, prop, angle, *, mtext=None):
self.draw_path(boxgc, path, mytrans, gc._rgb)

def encode_string(self, s, fonttype):
if fonttype in (1, 3):
return s.encode('cp1252', 'replace')
return s.encode('utf-16be', 'replace')
match fonttype:
case 1:
return s.encode('cp1252', 'replace')
case 3:
return s.encode('latin-1', 'replace')
case _:
return s.encode('utf-16be', 'replace')

def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
# docstring inherited
Expand Down
Loading

Back | FazBrowse Home | New Git URL