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

Appearance settings

Commit 9b6f7c1

Browse filesBrowse files
committed
Merge pull request #7961 from jkseppan/issue7937
Compute glyph widths similarly in Type 42 as in Type 3
1 parent 5a895da commit 9b6f7c1
Copy full SHA for 9b6f7c1

File tree

Expand file treeCollapse file tree

3 files changed

+16
-2
lines changed
Filter options
Expand file treeCollapse file tree

3 files changed

+16
-2
lines changed

‎lib/matplotlib/backends/backend_pdf.py

Copy file name to clipboardExpand all lines: lib/matplotlib/backends/backend_pdf.py
+3-2Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,8 +1003,9 @@ def embedTTFType42(font, characters, descriptor):
10031003
for c in characters:
10041004
ccode = c
10051005
gind = font.get_char_index(ccode)
1006-
glyph = font.load_char(ccode, flags=LOAD_NO_HINTING)
1007-
widths.append((ccode, glyph.horiAdvance / 6))
1006+
glyph = font.load_char(ccode,
1007+
flags=LOAD_NO_SCALE | LOAD_NO_HINTING)
1008+
widths.append((ccode, cvt(glyph.horiAdvance)))
10081009
if ccode < 65536:
10091010
cid_to_gid_map[ccode] = unichr(gind)
10101011
max_ccode = max(ccode, max_ccode)
Binary file not shown.

‎lib/matplotlib/tests/test_text.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_text.py
+13Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,3 +411,16 @@ def test_text_size_binding():
411411
matplotlib.rcParams['font.size'] = 100
412412

413413
assert sz1 == fp.get_size_in_points()
414+
415+
416+
@image_comparison(baseline_images=['font_scaling'],
417+
extensions=['pdf'])
418+
def test_font_scaling():
419+
matplotlib.rcParams['pdf.fonttype'] = 42
420+
fig, ax = plt.subplots(figsize=(6.4, 12.4))
421+
ax.xaxis.set_major_locator(plt.NullLocator())
422+
ax.yaxis.set_major_locator(plt.NullLocator())
423+
ax.set_ylim(-10, 600)
424+
425+
for i, fs in enumerate(range(4, 43, 2)):
426+
ax.text(0.1, i*30, "{fs} pt font size".format(fs=fs), fontsize=fs)

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.