-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Numpydocify FontManager.findfont() #13815
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
lib/matplotlib/font_manager.py
Outdated
|
||
Parameters | ||
---------- | ||
prop : `~matplotlib.fontmanager.FontProperties` |
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.
Apparently, this supports strings as well. I can do findfont('Calibri')
or findfont('Calibri:bold')
what is the correct terminology for the string representation?
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.
it's a "fontconfig pattern" (mentioned elsewhere in the module).
lib/matplotlib/font_manager.py
Outdated
---------- | ||
prop : `~matplotlib.fontmanager.FontProperties` | ||
The font properties to search for. | ||
fontext : str, optional, default: 'ttf' |
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 we support extensions other than 'ttf' and 'afm'?
The code says:
if fontext == 'afm':
fontlist = self.afmlist
else:
fontlist = self.ttflist
Not sure if extensions other than 'ttf' can appear in self.ttflist
.
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.
Really it's "ttf"->TrueType & OpenType (.ttf, .ttc, .otf) and "afm"->Adobe Font Metrics (.afm) (see get_fontext_synonyms).
If given, only search this directory and its subdirectories. | ||
fallback_to_default : bool | ||
If True, will fallback to the default font family (usually | ||
"DejaVu Sans" or "Helvetica") if the first lookup hard-fails. |
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 don't quite understand the behavior for fallback_to_default=False
. This also returns "DejaVu Sans". Not sure if this is a bug. Anyway, we're missing documentation for the non-fallback result.
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.
In one case we still try to match the font size, weight, and style (italic, bold, etc.) but not in the other. TBH I doubt the distinction really matters and would suggest just deprecating that argument (can be done in a separate PR, of course).
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.
Ok. I'll take care of that later in a separate PR.
…815-on-v3.1.x Backport PR #13815 on branch v3.1.x (Numpydocify FontManager.findfont())
PR Summary
Texts are mainly taken from the original docstring, but some of them are not quite clear yet. See below.
If somebody wants to immediately enhance the docstring, direct pushes are welcome.