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

Fallback fonts support #4102

Merged
merged 5 commits into from
Jan 14, 2025

Conversation

saurtron
Copy link
Collaborator

@saurtron saurtron commented Jan 3, 2025

Work done

  • Add support for fallback fonts
    • new FontsChanged callin
    • call AddFallbackFont from fonthandler
  • Add NotoEmoji b&w font
  • Make SourceHan fallback instead of main font

Remarks

  • Only supported by yet unreleased engine, although support is already on the "test engine" version from launcher.
  • Maybe fonthandler is not the best, thinking about adding at some "out of widget" include on init.
  • Will also need support at chobby to show proper emojis/language fonts there.
    • Can add the fonts and code to chobby, or better make it use the resource from BAR and maybe even some common include, but shouldn't do it the other way around since then running without chobby would result in missing fonts.
    • Let me know what you think is best here.
  • There will be color font support later but will most likely require another engine release cycle, see Color fonts support spring#1799, also might not want colored emojis everywhere.
  • Just chose the first emoji font I stumbled upon, we can change by any other you like as long as it's type is supported by freetype currently linked to engine (better to choose before merging this so we save some space from git history).

Addresses Issue(s)

also after this is in, we can select a russian font to fix the following:

Test steps

  • Run this PR with the "Test Engine" from launcher
  • Paste 🔥 into chat it should look like the below screenshot while before it would look different based on your OS.
  • Switch between chinese and english font, the change should be somewhat faster since it doesn't require full reload, and also look like the below screenshots.

You can also try with current engine version, and in that case the code here won't do anything and everything should work like it did before.

Screenshots:

BEFORE AND AFTER:

Note how english letters show different with "zh before" since there main font is replaced with chinese font, and then english letters show pretty random based on os.

After, we have "full" control over both english, chinese and emoji glyphs.

fallbacks

@WatchTheFort
Copy link
Member

I'm confused by this, why do individual widgets and components need to handle this at all? Shouldn't this be specified just once during Lua environment initialization?

@saurtron
Copy link
Collaborator Author

saurtron commented Jan 3, 2025

I'm confused by this, why do individual widgets and components need to handle this at all? Shouldn't this be specified just once during Lua environment initialization?

That's in case fallback fonts get changed when the widget has active display lists or other caches with old fallbacks, shouldn't generally be needed since just setting them at start, but it's better for consistency since the font will need to refresh display lists if that happens or would keep showing the old glyphs.

Haven't seen the need for that generally, but chat widget is where tests are usually done when hot changing fallbacks, so best to have FontsChanged support there.

Regarding the fonthandler widget, that's where I added the lua environment initialization, but could be done elsewhere like I commented at PR description.

@Ruwetuin Ruwetuin merged commit 977dadc into beyond-all-reason:master Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants