Fix missing CJK/Indic text on Linux with lazy font fallback#5993
Fix missing CJK/Indic text on Linux with lazy font fallback#5993nibbbl wants to merge 3 commits into
Conversation
Resolve fallback fonts per-glyph from FontConfig on demand instead of a truncated static list, so CJK/Thai/Indic scripts render.
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.
|
Thanks for the review, @marchcat. I'll address the recommendations from Copilot and review the build failures later today. |
|
@nibbbl, thank you! |
|
lua branch doesn't have the 5e38c19, which probably is tha cause of the issue. I cherry picked it, please rebase or update from lua's branch. |
Done. Thanks. |
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: