-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Simplify and tighten parse_fontconfig_pattern. #24220
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
c6feb3f
to
f11731a
Compare
if "families" in parse: | ||
props["family"] = [*map(_family_unescape, parse['families'])] | ||
if "size" in parse: | ||
props["size"] = parse["sizes"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo? (At least I do not understand why checking for "size"
is a requirement to get "sizes"
.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, fixed.
b9ae235
to
e2ced43
Compare
``parse_fontconfig_pattern`` will no longer ignore unknown constant names | ||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ | ||
Previously, in a fontconfig pattern like ``DejaVu Sans:foo``, the | ||
unknown ``foo`` constant name would be silently ignored. This is now raises |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unknown ``foo`` constant name would be silently ignored. This is now raises | |
unknown ``foo`` constant name would be silently ignored. This now raises |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oops, fixed.
6961e32
to
cf9ebeb
Compare
I further tweaked the parser a bit for conciseness. |
- Warn on unknown constant names, e.g. ``DejaVu Sans:unknown`` (as opposed e.g. to ``DejaVu Sans:bold``); they were previously silently ignored. - Rewrite the parser into something much simpler, moving nearly all the logic into a single block post-processing the result of parseString, instead of splitting everything into many small parse actions. In particular this makes the parser mostly stateless (except for the cache held by pyparsing itself), instead of having the various parts communicate through the _properties attribute.
Warn on unknown constant names, e.g.
DejaVu Sans:unknown
(as opposed e.g. toDejaVu Sans:bold
); they were previously silently ignored.Rewrite the parser into something much simpler, moving nearly all the logic into a single block post-processing the result of parseString, instead of splitting everything into many small parse actions. In particular this makes the parser mostly stateless (except for the cache held by pyparsing itself), instead of having the various parts communicate through the _properties attribute.
PR Summary
PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).