Fix missing CJK/Indic text on Linux with lazy font fallback#5993
Open
nibbbl wants to merge 1 commit into
Open
Conversation
Resolve fallback fonts per-glyph from FontConfig on demand instead of a truncated static list, so CJK/Thai/Indic scripts render.
This was referenced Jul 12, 2026
marchcat
approved these changes
Jul 13, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves Linux text rendering by switching font fallback from a truncated, pre-enumerated FontConfig font list to an on-demand per-codepoint lookup, allowing CJK/Indic/Thai glyphs to resolve correctly even on systems with very large font inventories.
Changes:
- Introduces
LLFontFallbackMatchand a newLLWindow::findFallbackFontForChar()API for lazy, OS-driven font fallback. - Implements Linux FontConfig matching per missing glyph (including face index for font collections), while stubbing the API on Windows/macOS.
- Updates
LLFontFreetype::addGlyph()to lazily discover/load/attach fallback faces when existing fallback fonts don’t cover a codepoint.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| indra/llwindow/llwindow.h | Adds LLFontFallbackMatch and declares findFallbackFontForChar() for OS font fallback queries. |
| indra/llwindow/llwindow.cpp | Implements platform dispatch for LLWindow::findFallbackFontForChar(). |
| indra/llwindow/llwindowsdl.h | Declares SDL/Linux implementation entrypoint for per-codepoint fallback. |
| indra/llwindow/llwindowsdl.cpp | Replaces Linux static fallback list with lazy FontConfig per-glyph matching. |
| indra/llwindow/llwindowwin32.h | Declares Windows stub for per-codepoint fallback API. |
| indra/llwindow/llwindowwin32.cpp | Adds Windows placeholder implementation (returns empty match). |
| indra/llwindow/llwindowmacosx.h | Declares macOS stub for per-codepoint fallback API. |
| indra/llwindow/llwindowmacosx.cpp | Adds macOS placeholder implementation (returns empty match). |
| indra/llrender/llfontfreetype.h | Adds state to support lazy fallback discovery and tracks attempted codepoints. |
| indra/llrender/llfontfreetype.cpp | Lazily queries OS for missing glyph coverage and loads fallback faces as needed. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| #include <glib.h> | ||
| #endif | ||
|
|
||
| #include <algorithm> |
Comment on lines
1892
to
1896
| if (!FcInit()) | ||
| { | ||
| LL_WARNS() << "FontConfig failed to initialize." << LL_ENDL; | ||
| rtns.push_back(final_fallback); | ||
| return rtns; | ||
| LL_WARNS_ONCE() << "FontConfig failed to initialize." << LL_ENDL; | ||
| return result; | ||
| } |
Comment on lines
+1899
to
+1905
| FcCharSet* charset = FcCharSetCreate(); | ||
| FcCharSetAddChar(charset, (FcChar32)wch); | ||
|
|
||
| FcPattern* pat = FcPatternCreate(); | ||
| FcPatternAddCharSet(pat, FC_CHARSET, charset); | ||
| FcPatternAddBool(pat, FC_SCALABLE, FcTrue); | ||
|
|
Author
|
Thanks for the review, @marchcat. I'll address the recommendations from Copilot and review the build failures later today. |
Contributor
|
@nibbbl, thank you! |
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
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Resolve fallback fonts per-glyph from FontConfig on demand instead of a truncated static list. This is a general improvement over the prior system, which simply slurped up 40 sorted fonts from the OS, causing missing characters on systems with many fonts. The newer system should result in less fonts being loaded, which is a nice bonus.
Closes #5991
Checklist
Please ensure the following before requesting review: