|
30 | 30 | from matplotlib.cbook import is_string_like, maxdict
|
31 | 31 | from matplotlib.figure import Figure
|
32 | 32 | from matplotlib.font_manager import findfont
|
33 |
| -from matplotlib.ft2font import FT2Font, LOAD_FORCE_AUTOHINT, LOAD_NO_HINTING |
| 33 | +from matplotlib.ft2font import FT2Font, LOAD_FORCE_AUTOHINT, LOAD_NO_HINTING, \ |
| 34 | + LOAD_DEFAULT, LOAD_NO_AUTOHINT |
34 | 35 | from matplotlib.mathtext import MathTextParser
|
35 | 36 | from matplotlib.path import Path
|
36 | 37 | from matplotlib.transforms import Bbox, BboxBase
|
|
40 | 41 |
|
41 | 42 | backend_version = 'v2.2'
|
42 | 43 |
|
| 44 | +def get_hinting_flag(): |
| 45 | + mapping = { |
| 46 | + True: LOAD_FORCE_AUTOHINT, |
| 47 | + False: LOAD_NO_HINTING, |
| 48 | + 'either': LOAD_DEFAULT, |
| 49 | + 'native': LOAD_NO_AUTOHINT, |
| 50 | + 'auto': LOAD_FORCE_AUTOHINT, |
| 51 | + 'none': LOAD_NO_HINTING |
| 52 | + } |
| 53 | + return mapping[rcParams['text.hinting']] |
| 54 | + |
| 55 | + |
43 | 56 | class RendererAgg(RendererBase):
|
44 | 57 | """
|
45 | 58 | The renderer handles all the drawing primitives using a graphics
|
@@ -69,12 +82,6 @@ def __init__(self, width, height, dpi):
|
69 | 82 | if __debug__: verbose.report('RendererAgg.__init__ done',
|
70 | 83 | 'debug-annoying')
|
71 | 84 |
|
72 |
| - def _get_hinting_flag(self): |
73 |
| - if rcParams['text.hinting']: |
74 |
| - return LOAD_FORCE_AUTOHINT |
75 |
| - else: |
76 |
| - return LOAD_NO_HINTING |
77 |
| - |
78 | 85 | # for filtering to work with rasterization, methods needs to be wrapped.
|
79 | 86 | # maybe there is better way to do it.
|
80 | 87 | def draw_markers(self, *kl, **kw):
|
@@ -141,7 +148,7 @@ def draw_text(self, gc, x, y, s, prop, angle, ismath):
|
141 | 148 | if ismath:
|
142 | 149 | return self.draw_mathtext(gc, x, y, s, prop, angle)
|
143 | 150 |
|
144 |
| - flags = self._get_hinting_flag() |
| 151 | + flags = get_hinting_flag() |
145 | 152 | font = self._get_agg_font(prop)
|
146 | 153 | if font is None: return None
|
147 | 154 | if len(s) == 1 and ord(s) > 127:
|
@@ -178,7 +185,7 @@ def get_text_width_height_descent(self, s, prop, ismath):
|
178 | 185 | self.mathtext_parser.parse(s, self.dpi, prop)
|
179 | 186 | return width, height, descent
|
180 | 187 |
|
181 |
| - flags = self._get_hinting_flag() |
| 188 | + flags = get_hinting_flag() |
182 | 189 | font = self._get_agg_font(prop)
|
183 | 190 | font.set_text(s, 0.0, flags=flags) # the width and height of unrotated string
|
184 | 191 | w, h = font.get_width_height()
|
|
0 commit comments