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

Skip to content

Commit f792c8b

Browse files
authored
Merge pull request #17380 from anntzer/ftflags
Support standard names for freetype hinting flags.
2 parents 904227b + 8167e81 commit f792c8b

File tree

4 files changed

+28
-13
lines changed

4 files changed

+28
-13
lines changed

doc/api/api_changes_3.3/behaviour.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,3 +285,11 @@ Qt and wx backends no longer create a status bar by default
285285
The coordinates information is now displayed in the toolbar, consistently with
286286
the other backends. This is intended to simplify embedding of Matplotlib in
287287
larger GUIs, where Matplotlib may control the toolbar but not the status bar.
288+
289+
:rc:`text.hinting` now supports names mapping to FreeType flags
290+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
291+
:rc:`text.hinting` now supports the values "default", "no_autohint",
292+
"force_autohint", and "no_hinting", which directly map to the FreeType flags
293+
FT_LOAD_DEFAULT, etc. The old synonyms (respectively "either", "native",
294+
"auto", and "none") are still supported. To get normalized values, use
295+
`.backend_agg.get_hinting_flag`, which returns integer flag values.

lib/matplotlib/backends/backend_agg.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,13 +54,17 @@
5454

5555
def get_hinting_flag():
5656
mapping = {
57+
'default': LOAD_DEFAULT,
58+
'no_autohint': LOAD_NO_AUTOHINT,
59+
'force_autohint': LOAD_FORCE_AUTOHINT,
60+
'no_hinting': LOAD_NO_HINTING,
5761
True: LOAD_FORCE_AUTOHINT,
5862
False: LOAD_NO_HINTING,
5963
'either': LOAD_DEFAULT,
6064
'native': LOAD_NO_AUTOHINT,
6165
'auto': LOAD_FORCE_AUTOHINT,
62-
'none': LOAD_NO_HINTING
63-
}
66+
'none': LOAD_NO_HINTING,
67+
}
6468
return mapping[mpl.rcParams['text.hinting']]
6569

6670

lib/matplotlib/rcsetup.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -691,9 +691,11 @@ def _validate_hinting(s):
691691
"True or False is deprecated since %(since)s and will be removed "
692692
"%(removal)s; set it to its synonyms 'auto' or 'none' instead.")
693693
return s
694-
if s.lower() in ('auto', 'native', 'either', 'none'):
695-
return s.lower()
696-
raise ValueError("hinting should be 'auto', 'native', 'either' or 'none'")
694+
return ValidateInStrings(
695+
'text.hinting',
696+
['default', 'no_autohint', 'force_autohint', 'no_hinting',
697+
'auto', 'native', 'either', 'none'],
698+
ignorecase=True)(s)
697699

698700

699701
validate_pgf_texsystem = ValidateInStrings(

matplotlibrc.template

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -292,14 +292,15 @@
292292
# Adobe Postscript (PSSNFS) font packages may also be
293293
# loaded, depending on your font settings.
294294

295-
#text.hinting: auto # May be one of the following:
296-
# - none: Perform no hinting
297-
# - auto: Use FreeType's autohinter
298-
# - native: Use the hinting information in the
299-
# font file, if available, and if your
300-
# FreeType library supports it
301-
# - either: Use the native hinting information,
302-
# or the autohinter if none is available.
295+
## FreeType hinting flag ("foo" corresponds to FT_LOAD_FOO); may be one of the following:
296+
## - default: Use the font's native hinter if possible, else FreeType's auto-hinter.
297+
## ("either" is a synonym).
298+
## - no_autohint: Use the font's native hinter if possible, else don't hint.
299+
## ("native" is a synonym.)
300+
## - force_autohint: Use FreeType's auto-hinter. ("auto" is a synonym.)
301+
## - no_hinting: Disable hinting. ("none" is a synonym.)
302+
#text.hinting: force_autohint
303+
303304
#text.hinting_factor: 8 # Specifies the amount of softness for hinting in the
304305
# horizontal direction. A value of 1 will hint to full
305306
# pixels. A value of 2 will hint to half pixels etc.

0 commit comments

Comments
 (0)