Skip to content

svg backend has limited encoding support with usetex #8068

Closed

Description

@jkseppan

Bug report

Bug summary

As reported on Launchpad, the combination of text.usetex=True, text.latex.unicode=True, and the svg backend can produce files with missing or wrong characters. A warning does get printed.

Code for reproduction

from pylab import *
pp={'text.usetex': True, 'text.latex.unicode': True}
rcParams.update(pp)

plot(1,1)
ylabel(r'\textwon')
savefig('tmp.pdf')
savefig('tmp.png')
savefig('tmp.svg')

Actual outcome

The svg file lacks the won character. A warning like the following is printed:

../lib/matplotlib/textpath.py:389: UserWarning: The glyph (142) of font (/usr/local/texlive/2016/texmf-dist/fonts/type1/public/cm-super/sfss3583.pfb) cannot be converted with the encoding. Glyph may be wrong
  "be wrong" % (glyph, font_bunch.filename))

Expected outcome

The svg file should include the won character (₩), as the pdf and png files do. I don't think we document usetex as being supported in the svg backend, but for several use cases it works.

Matplotlib version

Current master (3d99e43) installed from git with pip install -e .

Activity

  1. added this to the milestone on Feb 12, 2017
  2. added
    Difficulty: Hardhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issues
    on Feb 12, 2017
  3. tacaswell commented on Feb 12, 2017

    @tacaswell
    Member

    Labeling this as hard as fixing it will likely involve understanding a whole lot about text encoding.

  4. slochower commented on Mar 7, 2018

    @slochower

    I believe I'm also experiencing this issue. In my case, I'm completely missing "fl" from a word in the SVG. I suspect this "fl" is a ligature in LaTeX and thus, possibly, treated as a special character (like the original report). In the generated SVG file, I can see

        <g id="text_26">
         <!-- Directional flux (cycle s$^{{-1}}$) -->
         <defs>
    

    which is correct.

    Using matplotlib version 2.1.2 installed via conda, with the following settings:

        mpl.rc('text', usetex=True)
        mpl.rcParams['text.latex.preamble'] = [
            r'\usepackage{amsmath}',
            r'\usepackage{helvet}',
            r'\usepackage[EULERGREEK]{sansmath}',
            r'\sansmath',
            r'\renewcommand{\familydefault}{\sfdefault}',
            r'\usepackage[T1]{fontenc}',
            r'\usepackage{graphicx}'
        ]

    text8219-2

  5. github-actions commented on Apr 7, 2023

    @github-actions

    This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

  6. QuLogic commented on Apr 7, 2023

    @QuLogic
    Member

    This was fixed by #12928 + #14156.

  7. modified the milestones: future releases, v3.1.0 on Apr 7, 2023
  8. slochower commented on Apr 8, 2023

    @slochower

    Thanks for the update @QuLogic

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Difficulty: Hardhttps://matplotlib.org/devdocs/devel/contribute.html#good-first-issuesbackend: svgtopic: text/unicodetopic: text/usetex

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions