-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Simplify svg font expansion logic. #24066
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
We can delay quoting and deduplication until quite late.
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.
Optional comment on quoting.
|
||
def _get_all_quoted_names(prop): | ||
# only quote specific names, not generic names | ||
return [name if name in fm.font_family_aliases else repr(name) |
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.
We have used repr()
before and it seems to have worked, but technically repr()
is not exactly quoting. Would both single and double quotes be ok? Unlikely, but in theory Python could change that in repr (or possibly more likely an interpreter other than CPython could use other quotes). Also, can we be sure we will never have byte strings here?
It's more defensive to f-string the quotes explicitly.
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.
Do browsers / svg viewers / svg care about double vs single quotes?
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.
I think we should be safe on byte strings though (I would say a byte string as a font name is a bug or at least un-defined behavior).
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.
Single and double quotes are equally valid, and backslash-escaping quotes is valid as well: https://developer.mozilla.org/en-US/docs/Web/CSS/string
Both test failures are
which is because we now have to tests that use the same underlying file matplotlib/lib/matplotlib/tests/test_axes.py Lines 897 to 909 in 7de767e
|
Merged and left the discussion about quotes to #24080 |
We can delay quoting and deduplication until quite late.
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).