-
-
Notifications
You must be signed in to change notification settings - Fork 7.8k
Add a last resort font for missing glyphs #29356
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
would this also address #27232 ? |
I haven't tested it, but I think so. |
IIRC, our conversation in a previous meeting concluded with moving this fallback to the missing-glyph warning trigger. While this is possible with some refactoring, I've realized we reach a problem with font size. This would not have been set for the last-resort font, and it's a bit difficult to copy that information from another font due to the way FreeType stores it (it's stored in some font units, not the original call units.) If we have a global object for it, then we'd also have to worry about threading issues if propagating the size. So overall, this may not be the best course of action. However, that does mean we'd need to find an alternative means of ensuring the missing-glyph warning appears. |
24a4b0e
to
2a3d7a2
Compare
2a3d7a2
to
e95972c
Compare
So in the end, I just added a flag to the Last Resort I don't recall if we concluded that the |
I think I'm missing something super-obvious, as I don't know why the What's new plot isn't displaying anything. |
OK, I've figured out why the plot is missing. The warning is preserved here, and since the doc builds set This is supposed to be caught: matplotlib/lib/matplotlib/sphinxext/plot_directive.py Lines 700 to 713 in a9dc9ac
and reported: matplotlib/lib/matplotlib/sphinxext/plot_directive.py Lines 868 to 875 in a9dc9ac
but I've never seen this output. Because the exception occurs in |
e95972c
to
b081a80
Compare
6499c51
to
b8b8e5a
Compare
While testing out fallbacks with libraqm, I noticed that these don't work in PDF for some reason. Still need to investigate that a bit closer. |
b8b8e5a
to
6f8cf65
Compare
So instead of using the existing font objects, the PDF backend tracks fonts by filename, and then loads them again individually when writing the final font subsets. What this meant is that a) the Last Resort font was loaded without selecting the right charmap and b) the Last Resort fallback was added to Last Resort if it was explicitly asked for (and only this fallback had the right charmap). I've modified |
Also, I had to bump the GitHub cache key so that |
4fe3a07
to
c872584
Compare
: ft_glyph_warn(warn), image(), face(nullptr) | ||
FT2Font::WarnFunc warn, bool warn_if_used) | ||
: ft_glyph_warn(warn), warn_if_used(warn_if_used), image(), face(nullptr), | ||
hinting_factor(hinting_factor_), |
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.
hinting_factor(hinting_factor_), | |
// set a default fontsize 12 pt at 72dpi | |
hinting_factor(hinting_factor_), |
and presumably the comment should be removed below?
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.
No, that had nothing to do with the hinting factor, which is why I left it there.
@@ -268,12 +271,7 @@ FT2Font::FT2Font(FT_Open_Args &open_args, | |||
throw_ft_error("Can not load face", error); | |||
} | |||
|
|||
// set default kerning factor to 0, i.e., no kerning manipulation | |||
kerning_factor = 0; | |||
|
|||
// set a default fontsize 12 pt at 72dpi |
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.
// set a default fontsize 12 pt at 72dpi |
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.
Left one minor comment about moving a comment.
c872584
to
9abe036
Compare
PR summary
Some time ago, I came across https://github.com/unicode-org/last-resort-font. Through some charmap magic, the "High Efficiency" font from this project is able to provide a glyph for every Unicode codepoint while only being about 550K. (The expanded version in that repo in 8.6MB.)
This is a proof-of-concept for applying this font as final fallback at (almost) all times. I have added an
rcParam
to turn it off, mostly for one test to work, but we may not want to use that. I'm also not sure if it's been inserted in the best place. We may instead want to insert the glyph at the point where we have none, so that we can warn about it too.These glyphs show a representative character from the Unicode block, a square frame, and if large enough, the block name and code point range:
PR checklist