Skip to content

Commit 980fbee

Browse files
committed
Add missing decode() in svg font embedding path.
Otherwise, rcParams["svg.fonttype"] = "svgfont"; title("foo"); savefig("/tmp/test.svg") fails (on Py3) with File ".../backend_svg.py", line 86, in escape_attrib s = s.replace("&", "&") TypeError: a bytes-like object is required, not 'str' The encoding of entry 1, 0, 0, 4 in the sfnt table is macroman (https://www.freetype.org/freetype2/docs/reference/ft2-truetype_tables.html#TT_MAC_ID_XXX). Note that after the fix is applied, the resulting svg file still appears to be unopenable by inkscape, so the fix is not complete, but hopefully a step in the correct direction.
1 parent 7a6bab7 commit 980fbee

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

lib/matplotlib/backends/backend_svg.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,7 @@ def _write_svgfonts(self):
506506
font = get_font(font_fname)
507507
font.set_size(72, 72)
508508
sfnt = font.get_sfnt()
509-
writer.start('font', id=sfnt[(1, 0, 0, 4)])
509+
writer.start('font', id=sfnt[1, 0, 0, 4].decode("macroman"))
510510
writer.element(
511511
'font-face',
512512
attrib={

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy