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

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

Merged
tacaswell merged 4 commits intomatplotlib:masterfromanntzer:textpath-encoding
Apr 2, 2019
Merged

Conversation

anntzer
Copy link
Contributor

@anntzeranntzer commentedDec 3, 2018
edited
Loading

PR Summary

Consider the following example.

import matplotlib.pyplot as pltplt.rcParams['text.usetex'] = Trueplt.rcParams['text.latex.preamble'] = r'\usepackage{siunitx}'plt.rcParams['text.hinting_factor'] = 1plt.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 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.)
screenshot_20181203_174540

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 ofself.FONT_SCALE rather thanprop.get_size_in_points()/dvifont.size...

PR Checklist

  • Has Pytest style unit tests
  • Code isFlake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

schneiderfelipe reacted with thumbs up emoji
@anntzeranntzer added this to thev3.1 milestoneDec 3, 2018
@anntzeranntzerforce-pushed thetextpath-encoding branch 2 times, most recently from04dfa60 to83f2d64CompareDecember 3, 2018 20:41
# 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
Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

@anntzer
Copy link
ContributorAuthor

anntzer commentedDec 6, 2018
edited
Loading

Very empirically, it looks like glyphs are correctly sized (across multiple of font sizes) with

diff --git i/lib/matplotlib/textpath.py w/lib/matplotlib/textpath.pyindex 8ef6187bd..d306e82c8 100644--- i/lib/matplotlib/textpath.py+++ w/lib/matplotlib/textpath.py@@ -315,7 +315,7 @@ class TextToPath(object):              if char_id not in glyph_map:                 font.clear()-                font.set_size(self.FONT_SCALE, self.DPI)+                font.set_size(self.FONT_SCALE ** 2 / dvifont.size, self.DPI)                 # See comments in _get_ps_font_and_encoding.                 if enc is not None:                     index = font.get_name_index(enc[glyph])

which doesn't look completely nuts, but I haven't tracked down all the resizings either.

@anntzeranntzerforce-pushed thetextpath-encoding branch 2 times, most recently from533b875 to2077dc9CompareDecember 7, 2018 14:57
Copy link
Member

@jklymakjklymak left a 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...

@anntzer
Copy link
ContributorAuthor

rebased

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])
Copy link
Member

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?

Copy link
ContributorAuthor

@anntzeranntzerApr 2, 2019
edited
Loading

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.

Copy link
Member

@tacaswelltacaswell left a 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 ->[].

anntzerand others added4 commitsApril 2, 2019 13:54
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.)
@tacaswelltacaswell merged commita2277af intomatplotlib:masterApr 2, 2019
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull requestApr 2, 2019
@anntzeranntzer deleted the textpath-encoding branchApril 2, 2019 13:25
dstansby added a commit that referenced this pull requestApr 2, 2019
…928-on-v3.1.xBackport PR#12928 on branch v3.1.x (textpath encoding)
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@tacaswelltacaswelltacaswell approved these changes

@jklymakjklymakjklymak approved these changes

Assignees
No one assigned
Projects
None yet
Milestone
v3.1.0
Development

Successfully merging this pull request may close these issues.

3 participants
@anntzer@tacaswell@jklymak

[8]ページ先頭

©2009-2025 Movatter.jp