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

Skip to content

Fix glyph sizing in textpath. #14159

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

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
18 changes: 5 additions & 13 deletions lib/matplotlib/tests/test_backend_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -182,20 +182,12 @@ def psfont(*args, **kwargs):
fig.savefig(tmpfile, format='svg')


# Use Computer Modern Sans Serif, not Helvetica (which has no \textwon).
@pytest.mark.style('default')
@needs_usetex
def test_unicode_won():
fig = Figure()
fig.text(.5, .5, r'\textwon', usetex=True)

with BytesIO() as fd:
fig.savefig(fd, format='svg')
buf = fd.getvalue().decode('ascii')

won_id = 'Computer_Modern_Sans_Serif-142'
assert re.search(r'<path d=(.|\s)*?id="{0}"/>'.format(won_id), buf)
assert re.search(r'<use[^/>]*? xlink:href="#{0}"/>'.format(won_id), buf)
@image_comparison(baseline_images=['unicode_usetex'], extensions=['svg'])
def test_unicode_usetex():
mpl.rcParams['svg.fonttype'] = 'none'
mpl.style.use('default')
plt.figtext(.5, .5, r'\textdegree', usetex=True)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

(I intentionally chose this character with a simple outline to make the svg as small as possible :))



def test_svgnone_with_data_coordinates():
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/textpath.py
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ def get_glyphs_tex(self, prop, s, glyph_map=None,
glyph_ids.append(char_id)
xpositions.append(x1)
ypositions.append(y1)
sizes.append(dvifont.size / self.FONT_SCALE)
sizes.append(1)

myrects = []

Expand Down