Simplify svg font expansion logic.#24066
Conversation
We can delay quoting and deduplication until quite late.
timhoffm
left a comment
There was a problem hiding this comment.
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.
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.
Do browsers / svg viewers / svg care about double vs single quotes?
There was a problem hiding this comment.
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.
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
pytestpasses).flake8-docstringsand 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).