()
| 54 | |
| 55 | @cache # The parser instance is a singleton. |
| 56 | def _make_fontconfig_parser(): |
| 57 | def comma_separated(elem): |
| 58 | return elem + ZeroOrMore(Suppress(",") + elem) |
| 59 | |
| 60 | family = Regex(fr"([^{_family_punc}]|(\\[{_family_punc}]))*") |
| 61 | size = Regex(r"([0-9]+\.?[0-9]*|\.[0-9]+)") |
| 62 | name = Regex(r"[a-z]+") |
| 63 | value = Regex(fr"([^{_value_punc}]|(\\[{_value_punc}]))*") |
| 64 | prop = Group((name + Suppress("=") + comma_separated(value)) | one_of(_CONSTANTS)) |
| 65 | return ( |
| 66 | Optional(comma_separated(family)("families")) |
| 67 | + Optional("-" + comma_separated(size)("sizes")) |
| 68 | + ZeroOrMore(":" + prop("properties*")) |
| 69 | + StringEnd() |
| 70 | ) |
| 71 | |
| 72 | |
| 73 | # `parse_fontconfig_pattern` is a bottleneck during the tests because it is |
no test coverage detected
searching dependent graphs…