Skip to content

Fix #3330 by changing weight into string [cherry-pick to master] #3334

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

Closed
wants to merge 1 commit into from
Closed
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
10 changes: 10 additions & 0 deletions lib/matplotlib/backends/backend_macosx.py
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,11 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
else:
family = prop.get_family()
weight = prop.get_weight()
# transform weight into string for the native backend
if weight >= 700:
weight = 'bold'
else:
weight = 'normal'
style = prop.get_style()
points = prop.get_size_in_points()
size = self.points_to_pixels(points)
Expand All @@ -159,6 +164,11 @@ def get_text_width_height_descent(self, s, prop, ismath):
return width, height, descent
family = prop.get_family()
weight = prop.get_weight()
# transform weight into string for the native backend
if weight >= 700:
weight = 'bold'
else:
weight = 'normal'
style = prop.get_style()
points = prop.get_size_in_points()
size = self.points_to_pixels(points)
Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/font_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,6 +864,7 @@ def set_weight(self, weight):
except ValueError:
if weight not in weight_dict:
raise ValueError("weight is invalid")
weight = weight_dict[weight]
self._weight = weight

def set_stretch(self, stretch):
Expand Down