Skip to content
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

Add a last resort font for missing glyphs #29356

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

QuLogic
Copy link
Member

@QuLogic QuLogic commented Dec 20, 2024

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:

import matplotlib.pyplot as plt

text = '\N{Bengali Digit Zero}\N{Hiragana Letter A}\ufdd0'
sizes = [
    (0.90, 6),
    (0.85, 8),
    (0.80, 10),
    (0.75, 12),
    (0.70, 16),
    (0.63, 20),
    (0.55, 24),
    (0.45, 32),
    (0.30, 48),
    (0.10, 64),
]

fig = plt.figure()
for y, size in sizes:
    fig.text(0.01, y, f'{size}pt: {text}', fontsize=size)
plt.show()

Figure_1

PR checklist

@story645
Copy link
Member

would this also address #27232 ?

@QuLogic
Copy link
Member Author

QuLogic commented Dec 20, 2024

I haven't tested it, but I think so.

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.

2 participants