Skip to content

Commit 32a41bc

Browse files
committed
Merge pull request #4113 from fcolas/fix#3330
MNT : normalize font weights in OSX
2 parents 3a5e624 + 0422e93 commit 32a41bc

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

lib/matplotlib/backends/backend_macosx.py

+10
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

+1
Original file line numberDiff line numberDiff line change
@@ -867,6 +867,7 @@ def set_weight(self, weight):
867867
except ValueError:
868868
if weight not in weight_dict:
869869
raise ValueError("weight is invalid")
870+
weight = weight_dict[weight]
870871
self._weight = weight
871872

872873
def set_stretch(self, stretch):

0 commit comments

Comments
 (0)