Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0f4d99e

Browse files
committed
Apply hinting factor rcParam in all cases.
This is only explicitly used in Agg, so any other users get the default in the C++ code. Thus if you modify this setting and use some other backend, you get very weird behaviour. Positioning sometimes breaks and glyphs are shrunk or cropped.
1 parent 11dcf76 commit 0f4d99e

2 files changed

Lines changed: 7 additions & 4 deletions

File tree

lib/matplotlib/backends/backend_agg.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -267,9 +267,7 @@ def _get_agg_font(self, prop):
267267
Get the font for text instance t, cacheing for efficiency
268268
"""
269269
fname = findfont(prop)
270-
font = get_font(
271-
fname,
272-
hinting_factor=rcParams['text.hinting_factor'])
270+
font = get_font(fname)
273271

274272
font.clear()
275273
size = prop.get_size_in_points()

lib/matplotlib/font_manager.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1366,7 +1366,12 @@ def is_opentype_cff_font(filename):
13661366
_fmcache = None
13671367

13681368

1369-
get_font = lru_cache(64)(ft2font.FT2Font)
1369+
_get_font = lru_cache(64)(ft2font.FT2Font)
1370+
1371+
def get_font(filename, hinting_factor=None):
1372+
if hinting_factor is None:
1373+
hinting_factor = rcParams['text.hinting_factor']
1374+
return _get_font(filename, hinting_factor)
13701375

13711376

13721377
# The experimental fontconfig-based backend.

0 commit comments

Comments
 (0)