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

Commit2535508

Browse files
committed
Get names from the original font
Not the subsetted one, since in some cases fontTools.subsetdoes not produce a good name table.
1 parentd509a90 commit2535508

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

‎lib/matplotlib/backends/backend_ps.py

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -222,30 +222,36 @@ def _font_to_ps_type42(font_path, chars, fh):
222222
subset_str=''.join(chr(c)forcinchars)
223223
_log.debug("SUBSET %s characters: %s",font_path,subset_str)
224224
try:
225-
with_backend_pdf_ps.get_glyphs_subset(
226-
font_path,subset_str
227-
)assubset:
225+
kw= {}
226+
iffont_path.endswith('.ttc'):
227+
# fix this once we support loading more fonts from a collection
228+
# https://github.com/matplotlib/matplotlib/issues/3135#issuecomment-571085541
229+
kw['fontNumber']=0
230+
withfontTools.ttLib.TTFont(font_path,**kw)asfont, \
231+
_backend_pdf_ps.get_glyphs_subset(font_path,subset_str)assubset:
228232
fontdata=_backend_pdf_ps.font_as_file(subset).getvalue()
229233
_log.debug(
230234
"SUBSET %s %d -> %d",font_path,os.stat(font_path).st_size,
231235
len(fontdata)
232236
)
233-
fh.write(_serialize_type42(subset,fontdata))
237+
fh.write(_serialize_type42(font,subset,fontdata))
234238
exceptRuntimeError:
235239
_log.warning(
236240
"The PostScript backend does not currently "
237241
"support the selected font (%s).",font_path)
238242
raise
239243

240244

241-
def_serialize_type42(font,fontdata):
245+
def_serialize_type42(font,subset,fontdata):
242246
"""
243247
Output a PostScript Type-42 format representation of font
244248
245249
Parameters
246250
----------
247251
font : fontTools.ttLib.ttFont.TTFont
248-
The font object
252+
The original font object
253+
subset : fontTools.ttLib.ttFont.TTFont
254+
The subset font object
249255
fontdata : bytes
250256
The raw font data in TTF format
251257
@@ -280,7 +286,7 @@ def _serialize_type42(font, fontdata):
280286
FontName currentdict end definefont pop
281287
""")
282288

283-
returnfmt% (_charstrings(font),_sfnts(fontdata,font,breakpoints))
289+
returnfmt% (_charstrings(subset),_sfnts(fontdata,subset,breakpoints))
284290

285291

286292
def_version_and_breakpoints(loca,fontdata):

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp