Skip to content

Commit 0422e93

Browse files
author
Francis Colas
committed
forcing weight to int
1 parent 862b2c3 commit 0422e93

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/matplotlib/backends/backend_macosx.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,11 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
140140
else:
141141
family = prop.get_family()
142142
weight = prop.get_weight()
143+
# transform weight into string for the native backend
144+
if weight >= 700:
145+
weight = 'bold'
146+
else:
147+
weight = 'normal'
143148
style = prop.get_style()
144149
points = prop.get_size_in_points()
145150
size = self.points_to_pixels(points)
@@ -159,6 +164,11 @@ def get_text_width_height_descent(self, s, prop, ismath):
159164
return width, height, descent
160165
family = prop.get_family()
161166
weight = prop.get_weight()
167+
# transform weight into string for the native backend
168+
if weight >= 700:
169+
weight = 'bold'
170+
else:
171+
weight = 'normal'
162172
style = prop.get_style()
163173
points = prop.get_size_in_points()
164174
size = self.points_to_pixels(points)

lib/matplotlib/font_manager.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -864,6 +864,7 @@ def set_weight(self, weight):
864864
except ValueError:
865865
if weight not in weight_dict:
866866
raise ValueError("weight is invalid")
867+
weight = weight_dict[weight]
867868
self._weight = weight
868869

869870
def set_stretch(self, stretch):

0 commit comments

Comments
 (0)