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

Commit4881758

Browse files
committed
Add kerning to Type 3 font, ASCII strings in PDFs
1 parent63af5a2 commit4881758

File tree

1 file changed

+13
-11
lines changed

1 file changed

+13
-11
lines changed

‎lib/matplotlib/backends/backend_pdf.py

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2287,24 +2287,26 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
22872287
}
22882288
self.file._annotations[-1][1].append(link_annotation)
22892289

2290-
# If fonttype != 3or there are no multibyte characters, emit the whole
2291-
#string at once.
2292-
iffonttype!=3orall(ord(char)<=255forcharins):
2290+
# If fonttype != 3emit the whole string at once without manual
2291+
#kerning.
2292+
iffonttype!=3:
22932293
self.file.output(Op.begin_text,
22942294
self.file.fontName(prop),fontsize,Op.selectfont)
22952295
self._setup_textpos(x,y,angle)
2296-
self.file.output(self.encode_string(s,fonttype),Op.show,
2297-
Op.end_text)
2296+
self.file.output(self.encode_string(s,fonttype),
2297+
Op.show,Op.end_text)
22982298

22992299
# There is no way to access multibyte characters of Type 3 fonts, as
23002300
# they cannot have a CIDMap. Therefore, in this case we break the
23012301
# string into chunks, where each chunk contains either a string of
2302-
# consecutive 1-byte characters or a single multibyte character. Each
2303-
# chunk is emitted with a separate command: 1-byte characters use the
2304-
# regular text show command (Tj), whereas multibyte characters use
2305-
# the XObject command (Do). (If using Type 42 fonts, all of this
2306-
# complication is avoided, but of course, those fonts can not be
2307-
# subsetted.)
2302+
# consecutive 1-byte characters or a single multibyte character.
2303+
# A sequence of 1-byte characters is broken into multiple chunks to
2304+
# adjust the kerning between adjacent chunks. Each chunk is emitted
2305+
# with a separate command: 1-byte characters use the regular text show
2306+
# command (TJ) with appropriate kerning between chunks, whereas
2307+
# multibyte characters use the XObject command (Do). (If using Type
2308+
# 42 fonts, all of this complication is avoided, but of course, those
2309+
# fonts can not be subsetted.)
23082310
else:
23092311
# List of (start_x, [prev_kern, char, char, ...]), w/o zero kerns.
23102312
singlebyte_chunks= []

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp