Thanks to visit codestin.com
Credit goes to github.com

Skip to content

ENH: try to use unicode charmap before ADOBE_STANDARD in textpath #8286

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

Closed
wants to merge 1 commit into from

Conversation

tacaswell
Copy link
Member

This will allow a wider range of glyphs to be exported.

Closes #8280

This needs some tests and an understanding of why the adobe mapping was used to begin with.

This will allow a wider range of glyphs to be exported.

Closes matplotlib#8280
@tacaswell tacaswell added this to the 2.1 (next point release) milestone Mar 13, 2017
@tacaswell tacaswell modified the milestones: 2.1.1 (next bug fix release), 2.1 (next point release) Aug 13, 2017
@tacaswell tacaswell modified the milestones: 2.1.1 (next bug fix release), 2.2 (next feature release) Oct 9, 2017
Copy link
Contributor

@anntzer anntzer left a comment

Choose a reason for hiding this comment

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

While working on improving usetex support in mplcairo, I realized why this won't work (at least as is).

In usetex mode, the SVG backend gets a list of (fontpath, glyph-index) from dviread and passes them to textpath to generate the glyph outlines that get embedded into the SVG file. However, the indices in the dvi file (and thus returned by dviread) correspond to the "native" charmap in the font file, which, for pfb fonts (e.g. computer modern), is an Adobe mapping. The Unicode charmaps are actually "fake" charmaps synthesized on-the-fly by FreeType. In particular, they do not include ligatures (which after all do not correspond to Unicode codepoints).
For example, one can try text(.5, .5, "ff", usetex=True); savefig("/tmp/test.svg") ("ff" is a ligature at position 11 of the "native" charmap); with this PR one gets

/home/antony/src/extern/matplotlib/lib/matplotlib/textpath.py:391: RuntimeWarning: Glyph 11 missing from current font.
  glyph0 = font.load_char(charcode, flags=ft2font_flag)

and the ff ligature is not included (because, with the PR, one tries instead to load the character at Unicode codepoint 11, which is not a printable character).

@tacaswell
Copy link
Member Author

@anntzer Is this salvageable? If you think not feel free to close.

@anntzer
Copy link
Contributor

anntzer commented Dec 2, 2018

Let's keep this open while I figure out whether #8415 works better.

@anntzer anntzer mentioned this pull request Dec 3, 2018
6 tasks
@anntzer
Copy link
Contributor

anntzer commented Jul 5, 2019

I think this has been superseded by #12928 (which owes much to this PR, thanks :)).

@anntzer anntzer closed this Jul 5, 2019
@tacaswell tacaswell deleted the fix_textpath_unicode branch July 5, 2019 22:39
@tacaswell
Copy link
Member Author

"Programming by doing it badly and annoying someone else enough to do it right" ;)

@anntzer
Copy link
Contributor

anntzer commented Jul 5, 2019

I'm very easily annoyable... :)

@story645 story645 removed this from the future releases milestone Oct 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trouble saving svg file when plot contains special characters
3 participants