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

[Bug]: problem with font property in text elements of svg figures #22528

Closed
Milestone
@cderemble

Description

@cderemble

Bug summary

Starting with 3.5.0, figures exported as SVG without font embedded in the file (i.e. “svg.fonttype” set to “none”) use thefont CSS shorthand property.
The problem is that the font-family generic name is quoted and some viewers don’t like it (chrome for exemple). My understanding (readinghttps://developer.mozilla.org/en-US/docs/Web/CSS/font-family) is that only the family name should be quoted if it contains spaces.

Code for reproduction

importmatplotlibimportmatplotlib.pyplotmatplotlib.rcParams["svg.fonttype"]="none"matplotlib.rcParams["font.family"]="sans-serif"matplotlib.use("SVG")fig=matplotlib.pyplot.figure()axes=fig.add_subplot()axes.plot([1,2], [3,4],label="test")axes.legend()fig.savefig(f"test.svg")

Actual outcome

In the text elements, the generic name of the font-family is quoted (here 'sans-serif')
<text x="94.6" y="57.629812" transform="rotate(-0, 94.6, 57.629812)">test</text>

Expected outcome

The generic name of the font-family should not be quoted
<text x="94.6" y="57.629812" transform="rotate(-0, 94.6, 57.629812)">test</text>

Additional information

No response

Operating system

No response

Matplotlib Version

3.5.1

Matplotlib Backend

SVG

Python version

3.9.10

Jupyter version

No response

Installation

conda

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp