MCPcopy Index your code
hub / github.com/matplotlib/matplotlib / parse_fontconfig_pattern

Function parse_fontconfig_pattern

lib/matplotlib/_fontconfig_pattern.py:78–100  ·  view source on GitHub ↗

Parse a fontconfig *pattern* into a dict that can initialize a `.font_manager.FontProperties` object.

(pattern)

Source from the content-addressed store, hash-verified

76# during the test suite.
77@lru_cache
78def parse_fontconfig_pattern(pattern):
79 """
80 Parse a fontconfig *pattern* into a dict that can initialize a
81 `.font_manager.FontProperties` object.
82 """
83 parser = _make_fontconfig_parser()
84 try:
85 parse = parser.parse_string(pattern)
86 except ParseException as err:
87 # explain becomes a plain method on pyparsing 3 (err.explain(0)).
88 raise ValueError("\n" + ParseException.explain(err, 0)) from None
89 parser.reset_cache()
90 props = {}
91 if "families" in parse:
92 props["family"] = [*map(_family_unescape, parse["families"])]
93 if "sizes" in parse:
94 props["size"] = [*parse["sizes"]]
95 for prop in parse.get("properties", []):
96 if len(prop) == 1:
97 prop = _CONSTANTS[prop[0]]
98 k, *v = prop
99 props.setdefault(k, []).extend(map(_value_unescape, v))
100 return props
101
102
103def generate_fontconfig_pattern(d):

Callers 2

validate_font_propertiesFunction · 0.90

Calls 2

_make_fontconfig_parserFunction · 0.85
getMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…