Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
textpath encoding#12928
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
textpath encoding#12928
Uh oh!
There was an error while loading.Please reload this page.
Conversation
04dfa60
to83f2d64
Comparelib/matplotlib/textpath.py Outdated
# If psfonts.map specifies no encoding, the indices directly map to | ||
# the font's builtin charmap (see the pdftex manual, section 6.1 | ||
# -- Map files); so don't use the FreeType-synthesized charmap but | ||
# the native ones (we can't directly identify it but it's typically |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
anntzer commentedDec 6, 2018 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Very empirically, it looks like glyphs are correctly sized (across multiple of font sizes) with
which doesn't look completely nuts, but I haven't tracked down all the resizings either. |
533b875
to2077dc9
CompareThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Not clear on all details, but this seems to work...
rebased |
lib/matplotlib/textpath.py Outdated
glyph0 = font.load_char(charcode, flags=ft2font_flag) | ||
# See comments in _get_ps_font_and_encoding. | ||
if enc is not None: | ||
index = font.get_name_index(enc[glyph]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
this used to handle the case whereglyph not in enc
where as this looks like it will now raiseKeyError
. Is this a change we want to make?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Restored handling ofglyph not in enc
(in the last commit). Not sure why I removed this in the first place.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
modulo the question about changing.get
->[]
.
Consider the following example. import matplotlib.pyplot as plt plt.rcParams['text.usetex'] = True plt.rcParams['text.latex.preamble'] = r'\usepackage{siunitx}' plt.rcParams['text.hinting_factor'] = 1 plt.text(.5, .5, r'$\si{\degree}$') plt.text(.5, .4, r'ff\textwon') plt.gca().set_axis_off() plt.savefig('/tmp/plot.svg') plt.savefig('/tmp/plot.pdf') plt.savefig('/tmp/plot.png') plt.show()In the svg output, one sees that the \degree and \textwon characters(which come from a different font that the ff ligature) are nowcorrectly loaded, *but* at a too small size -- this still needs to befixed.(pdf and png output are unaffected.)
…928-on-v3.1.xBackport PR#12928 on branch v3.1.x (textpath encoding)
Uh oh!
There was an error while loading.Please reload this page.
PR Summary
Consider the following example.
In the svg output, one sees that the \degree and \textwon characters

(which come from a different font that the ff ligature) are now
correctly loaded,but at a too small size -- this still needs to be
fixedn but is already better than not loading the glyphs at all.
(pdf and png output are unaffected.)
Supersedes#8286,#8415 (from which a test is taken).
Fixes part of#8068,#8280 (the glyph-loading part; the sizing issue is a bug this PR newly exposes).
Likely the bad font sizing has something to do with the use, in textpath.py of
self.FONT_SCALE
rather thanprop.get_size_in_points()
/dvifont.size
...PR Checklist