Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Allow Type3 subsetting of otf fonts in pdf backend. #18651

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 11, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 2 additions & 17 deletions lib/matplotlib/backends/backend_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
GraphicsContextBase, RendererBase)
from matplotlib.backends.backend_mixed import MixedModeRenderer
from matplotlib.figure import Figure
from matplotlib.font_manager import findfont, is_opentype_cff_font, get_font
from matplotlib.font_manager import findfont, get_font
from matplotlib.afm import AFM
import matplotlib.type1font as type1font
import matplotlib.dviread as dviread
Expand Down Expand Up @@ -1348,15 +1348,6 @@ def embedTTFType42(font, characters, descriptor):
'StemV': 0 # ???
}

# The font subsetting to a Type 3 font does not work for
# OpenType (.otf) that embed a Postscript CFF font, so avoid that --
# save as a (non-subsetted) Type 42 font instead.
if is_opentype_cff_font(filename):
fonttype = 42
_log.warning("%r can not be subsetted into a Type 3 font. The "
"entire font will be embedded in the output.",
os.path.basename(filename))

if fonttype == 3:
return embedTTFType3(font, characters, descriptor)
elif fonttype == 42:
Expand Down Expand Up @@ -2119,7 +2110,7 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):
}
self.file._annotations[-1][1].append(link_annotation)

global_fonttype = mpl.rcParams['pdf.fonttype']
fonttype = mpl.rcParams['pdf.fonttype']

# Set up a global transformation matrix for the whole math expression
a = math.radians(angle)
Expand All @@ -2137,8 +2128,6 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):
for font, fontsize, num, ox, oy in glyphs:
self.file._character_tracker.track(font, chr(num))
fontname = font.fname
fonttype = (
42 if is_opentype_cff_font(fontname) else global_fonttype)
if fonttype == 3 and num > 255:
# For Type3 fonts, multibyte characters must be emitted
# separately (below).
Expand Down Expand Up @@ -2282,10 +2271,6 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
font = self._get_font_ttf(prop)
self.file._character_tracker.track(font, s)
fonttype = mpl.rcParams['pdf.fonttype']
# We can't subset all OpenType fonts, so switch to Type 42
# in that case.
if is_opentype_cff_font(font.fname):
fonttype = 42

if gc.get_url() is not None:
font.set_text(s)
Expand Down