Skip to content

Commit 77534c6

Browse files
author
Francis Colas
committed
forcing weight to int
1 parent 0790137 commit 77534c6

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
@@ -138,6 +138,11 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath=False, mtext=None):
138138
else:
139139
family = prop.get_family()
140140
weight = prop.get_weight()
141+
# transform weight into string for the native backend
142+
if weight >= 700:
143+
weight = 'bold'
144+
else:
145+
weight = 'normal'
141146
style = prop.get_style()
142147
points = prop.get_size_in_points()
143148
size = self.points_to_pixels(points)
@@ -157,6 +162,11 @@ def get_text_width_height_descent(self, s, prop, ismath):
157162
return width, height, descent
158163
family = prop.get_family()
159164
weight = prop.get_weight()
165+
# transform weight into string for the native backend
166+
if weight >= 700:
167+
weight = 'bold'
168+
else:
169+
weight = 'normal'
160170
style = prop.get_style()
161171
points = prop.get_size_in_points()
162172
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)