Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit696abf7

Browse files
committed
Allow Type3 subsetting of otf fonts in pdf backend.
This is supported since19359c1, results in smaller files (*much*smaller when using CJK fonts), and avoids running into issues with type42 embedding and certain pdf readers such as Acrobat Reader.
1 parentdd15dc0 commit696abf7

File tree

1 file changed

+2
-17
lines changed

1 file changed

+2
-17
lines changed

‎lib/matplotlib/backends/backend_pdf.py

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
GraphicsContextBase,RendererBase)
3232
frommatplotlib.backends.backend_mixedimportMixedModeRenderer
3333
frommatplotlib.figureimportFigure
34-
frommatplotlib.font_managerimportfindfont,is_opentype_cff_font,get_font
34+
frommatplotlib.font_managerimportfindfont,get_font
3535
frommatplotlib.afmimportAFM
3636
importmatplotlib.type1fontastype1font
3737
importmatplotlib.dvireadasdviread
@@ -1337,15 +1337,6 @@ def embedTTFType42(font, characters, descriptor):
13371337
'StemV':0# ???
13381338
}
13391339

1340-
# The font subsetting to a Type 3 font does not work for
1341-
# OpenType (.otf) that embed a Postscript CFF font, so avoid that --
1342-
# save as a (non-subsetted) Type 42 font instead.
1343-
ifis_opentype_cff_font(filename):
1344-
fonttype=42
1345-
_log.warning("%r can not be subsetted into a Type 3 font. The "
1346-
"entire font will be embedded in the output.",
1347-
os.path.basename(filename))
1348-
13491340
iffonttype==3:
13501341
returnembedTTFType3(font,characters,descriptor)
13511342
eliffonttype==42:
@@ -2095,7 +2086,7 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):
20952086
width,height,descent,glyphs,rects= \
20962087
self._text2path.mathtext_parser.parse(s,72,prop)
20972088

2098-
global_fonttype=mpl.rcParams['pdf.fonttype']
2089+
fonttype=mpl.rcParams['pdf.fonttype']
20992090

21002091
# Set up a global transformation matrix for the whole math expression
21012092
a=math.radians(angle)
@@ -2113,8 +2104,6 @@ def draw_mathtext(self, gc, x, y, s, prop, angle):
21132104
forfont,fontsize,num,ox,oyinglyphs:
21142105
self.file._character_tracker.track(font,chr(num))
21152106
fontname=font.fname
2116-
fonttype= (
2117-
42ifis_opentype_cff_font(fontname)elseglobal_fonttype)
21182107
iffonttype==3andnum>255:
21192108
# For Type3 fonts, multibyte characters must be emitted
21202109
# separately (below).
@@ -2245,10 +2234,6 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
22452234
font=self._get_font_ttf(prop)
22462235
self.file._character_tracker.track(font,s)
22472236
fonttype=mpl.rcParams['pdf.fonttype']
2248-
# We can't subset all OpenType fonts, so switch to Type 42
2249-
# in that case.
2250-
ifis_opentype_cff_font(font.fname):
2251-
fonttype=42
22522237

22532238
# If fonttype != 3 or there are no multibyte characters, emit the whole
22542239
# string at once.

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp