From 0422e932d85b028cf9511190a03da574d78917b2 Mon Sep 17 00:00:00 2001 From: Francis Colas Date: Wed, 22 Oct 2014 21:01:49 +0200 Subject: [PATCH] forcing weight to int --- lib/matplotlib/backends/backend_macosx.py | 10 ++++++++++ lib/matplotlib/font_manager.py | 1 + 2 files changed, 11 insertions(+) diff --git a/lib/matplotlib/backends/backend_macosx.py b/lib/matplotlib/backends/backend_macosx.py index 371f687b1190..00273386a93e 100755 --- a/lib/matplotlib/backends/backend_macosx.py +++ b/lib/matplotlib/backends/backend_macosx.py @@ -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) @@ -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) diff --git a/lib/matplotlib/font_manager.py b/lib/matplotlib/font_manager.py index 3d33a28ce923..03115ff3fb2a 100644 --- a/lib/matplotlib/font_manager.py +++ b/lib/matplotlib/font_manager.py @@ -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):