FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

MNT: Deprecate FontProperties(pattern) by timhoffm · Pull Request #28837 · matplotlib/matplotlib · GitHub

MNT: Deprecate FontProperties(pattern) - #28837

Closed
timhoffm wants to merge 1 commit into
matplotlib:mainfrom
timhoffm:FontProperties-pattern
Closed

timhoffm wants to merge 1 commit into
matplotlib:mainfrom
timhoffm:FontProperties-pattern

Conversation

timhoffm commented Sep 18, 2024 •
edited
Loading

Copy link
Copy Markdown
Member

... and use FontProperties.from_pattern() instead.

FontProperties(pattern) was an overloaded API that easily conflicts with FontProperties(family). The parameter was assumed to be a pattern if it was a string and the only parameter.

Noted in #28836 (review).

... and use `FontProperties.from_pattern()` instead.

`FontProperties(pattern)` was an overloaded API that easily conflicts
with `FontProperties(family)`. The parameter was assumed to be a
pattern if it was a string and the only parameter.
timhoffm force-pushed the FontProperties-pattern branch from 86f308d to f63e438 Compare September 18, 2024 22:16

anntzer commented Sep 18, 2024

Copy link
Copy Markdown
Contributor

See also the item starting with "The FP constructor is a bit a mess..." at #10249, I guess.
Based on the writeup at #10249 I vaguely suspect we should rather deprecate FP(family) because that's easily written as FP(family=family) (consistently with all other attributes), and if anything the constructor without named parameter should take a pattern (... perhaps a CSS pattern, but that's another issue).

timhoffm marked this pull request as draft September 18, 2024 23:30

Copy link
Copy Markdown
Member Author

Sure. We could do __init__(pattern=None, /, *, family=None, ...). Notes:

  • We still need an either pattern or the other parameters internal check, i.e. we have two orthogonal APIs in the constructor, but at least they are logically separated.
  • for the deprecation: can we detect whether a given single parameter is a family rather than a pattern?

timhoffm added the status: needs comment/discussion needs consensus on next step label Sep 18, 2024

anntzer commented Sep 19, 2024

Copy link
Copy Markdown
Contributor
  • for the deprecation: can we detect whether a given single parameter is a family rather than a pattern?

In the single-arg case, I would try calling parse_fontconfig_pattern, then if it raises, treat as a family (and warn) (If it doesn't raise, this can also occur if the family and the pattern are identical, e.g. "Times" parses as {"family": "Times"}.)

Copy link
Copy Markdown
Member Author

Superseeded by #28843.

timhoffm closed this Sep 19, 2024
QuLogic removed this from the v3.10.0 milestone Sep 19, 2024
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants


Back | FazBrowse Home | New Git URL