Skip to content
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
3 changes: 2 additions & 1 deletion lib/matplotlib/backends/backend_svg.py
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,8 @@ 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()
weight = fm.weight_dict.get(weight, weight) # convert to int
if weight != 400:
font_style['font-weight'] = f'{weight}'

Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/font_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,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