Skip to content

Fix missing CJK/Indic text on Linux with lazy font fallback#5993

Open
nibbbl wants to merge 1 commit into
secondlife:project/lua_editorfrom
nibbbl:cjk-lazy-font-fallback
Open

Fix missing CJK/Indic text on Linux with lazy font fallback#5993
nibbbl wants to merge 1 commit into
secondlife:project/lua_editorfrom
nibbbl:cjk-lazy-font-fallback

Conversation

@nibbbl

@nibbbl nibbbl commented Jul 12, 2026

Copy link
Copy Markdown

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:

  • I have provided a clear title and detailed description for this pull request.
  • If useful, I have included media such as screenshots and video to show off my changes.
  • The PR is linked to a relevant issue with sufficient context.
  • I have tested the changes locally and verified they work as intended.
  • All new and existing tests pass.
  • Code follows the project's style guidelines.
  • Documentation has been updated if needed.
  • Any dependent changes have been merged and published in downstream modules
  • I have reviewed the contributing guidelines.

Resolve fallback fonts per-glyph from FontConfig on demand instead of a
truncated static list, so CJK/Thai/Indic scripts render.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 LLFontFallbackMatch and a new LLWindow::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);

@nibbbl

nibbbl commented Jul 13, 2026

Copy link
Copy Markdown
Author

Thanks for the review, @marchcat. I'll address the recommendations from Copilot and review the build failures later today.

@marchcat

Copy link
Copy Markdown
Contributor

@nibbbl, thank you!
I'll check it once it's ready.

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.

Linux: CJK/Thai/Indic text does not render even with matching system font installed

3 participants