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

Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
2 changes: 1 addition & 1 deletion lib/matplotlib/backends/backend_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@ def _draw_text_as_text(self, gc, x, y, s, prop, angle, ismath, mtext=None):
font_style['font-style'] = prop.get_style()
if prop.get_variant() != 'normal':
font_style['font-variant'] = prop.get_variant()
weight = fm.weight_dict[prop.get_weight()]
weight = prop.get_weight()
Comment thread
story645 marked this conversation as resolved.
Comment thread
steveberardi marked this conversation as resolved.
if weight != 400:
font_style['font-weight'] = f'{weight}'

Expand Down
3 changes: 1 addition & 2 deletions lib/matplotlib/font_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
# - font size is incomplete
# - default font algorithm needs improvement and testing
# - setWeights function needs improvement
# - 'light' is an invalid weight value, remove it.

from __future__ import annotations

Expand Down Expand Up @@ -748,7 +747,7 @@ def get_variant(self):

def get_weight(self):
"""
Set the font weight. Options are: A numeric value in the
Get the font weight. Options are: A numeric value in the
range 0-1000 or one of 'light', 'normal', 'regular', 'book',
'medium', 'roman', 'semibold', 'demibold', 'demi', 'bold',
'heavy', 'extra bold', 'black'
Expand Down
6 changes: 4 additions & 2 deletions lib/matplotlib/tests/test_backend_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,8 @@ def test_bold_font_output():
ax.plot(np.arange(10), np.arange(10))
ax.set_xlabel('nonbold-xlabel')
ax.set_ylabel('bold-ylabel', fontweight='bold')
ax.set_title('bold-title', fontweight='bold')
# set weight as integer to assert it's handled properly
ax.set_title('bold-title', fontweight=600)


@image_comparison(['bold_font_output_with_none_fonttype.svg'])
Expand All @@ -84,7 +85,8 @@ def test_bold_font_output_with_none_fonttype():
ax.plot(np.arange(10), np.arange(10))
ax.set_xlabel('nonbold-xlabel')
ax.set_ylabel('bold-ylabel', fontweight='bold')
ax.set_title('bold-title', fontweight='bold')
# set weight as integer to assert it's handled properly
ax.set_title('bold-title', fontweight=600)


@check_figures_equal(extensions=['svg'], tol=20)
Expand Down
Loading