-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
PostScript Type42 embedding is broken in various ways #18191
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Or sometimes fail to display anything at all. import matplotlib.pyplot as plt
from matplotlib.font_manager import FontProperties
plt.rcParams["ps.fonttype"] = 42
path = '/path/to/matplotlib/doc/_static/fonts/Carlogo-bolditalic.ttf'
prop = FontProperties(fname=path)
plt.figtext(0.5, 0.5, "normal_text", font=prop)
plt.savefig('normal_text.ps') The font has the glyphs (Type 3 works fine), but the output is blank (even though the whole font is embedded). |
Updating this issue:
|
I think the issue with |
I just checked, #20597 indeed fixes the |
Bug report
Bug summary
As in the title.
Code for reproduction
Actual outcome
In
euro.ps
the font is actually embedded as Type 3, not Type 42 (as can be checked by opening the file in a text editor).In
zeroeuro.ps
the font is correctly embedded as Type 42, but the euro sign fails to display correctly (we get a rectangular box instead).sqrt.ps
causes an error with the viewer (Error: /invalidfont in definefont
).Given that in all likelihood this has been broken for a loooooong time (as ttconv is rarely touched) it may be worth waiting for a decision on #18143 first before trying to fix this.
On the other hand, note that this also affects the
ps.fonttype = 3
case when rendering more than 255 characters, because we fall back to type 42 in that case (example below). By the spec, a type 3 font cannot contain more than 255 glyphs, but empirically, things work just fine for us, likely because we always refer to glyphs by glyph name rather than by glyph index? If we want to be super safe wrt. the spec, I guess we could split a >255-glyph font into multiple fonts and callsetfont
as needed (we're positioning glyphs one at a time anyways).As a side point, it seems likely that type 42 embedding is also broken for the pdf backend, per #12636...
Matplotlib version
print(matplotlib.get_backend())
): psThe text was updated successfully, but these errors were encountered: