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

Skip to content

Don't forget to set stretch when exporting font as svg reference. #16484

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

Merged
merged 1 commit into from
Feb 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions lib/matplotlib/backends/backend_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1027,11 +1027,12 @@ def _draw_text_as_text(self, gc, x, y, s, prop, angle, ismath, mtext=None):
font.set_text(s, 0.0, flags=LOAD_NO_HINTING)

attrib = {}
# Must add "px" to workaround a Firefox bug
style['font-size'] = short_float_fmt(prop.get_size()) + 'px'
style['font-family'] = str(font.family_name)
style['font-style'] = prop.get_style().lower()
style['font-weight'] = str(prop.get_weight()).lower()
style['font-stretch'] = str(prop.get_stretch()).lower()
style['font-style'] = prop.get_style().lower()
# Must add "px" to workaround a Firefox bug
style['font-size'] = short_float_fmt(prop.get_size()) + 'px'
attrib['style'] = generate_css(style)

if mtext and (angle == 0 or mtext.get_rotation_mode() == "anchor"):
Expand Down
2 changes: 2 additions & 0 deletions lib/matplotlib/tests/test_backend_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ def test_svgnone_with_data_coordinates():
buf = fd.read().decode()

assert expected in buf
for prop in ["family", "weight", "stretch", "style", "size"]:
assert f"font-{prop}:" in buf


def test_gid():
Expand Down