Skip to content

Fix custom font fallback rendering#6485

Open
gta66666668 wants to merge 2 commits into
MeteorDevelopment:masterfrom
gta66666668:codex/chinese-font-fallback
Open

Fix custom font fallback rendering#6485
gta66666668 wants to merge 2 commits into
MeteorDevelopment:masterfrom
gta66666668:codex/chinese-font-fallback

Conversation

@gta66666668

Copy link
Copy Markdown

Fixes custom text rendering for glyphs that are not present in the selected Meteor font, such as Chinese characters.

The previous custom font renderer pre-packed a fixed set of Latin, Greek, Cyrillic, and symbol ranges. Characters outside those ranges could not render even when the OS had a suitable font installed.

Changes:

  • load an available system fallback font for common CJK font families
  • let Font use multiple font buffers
  • lazily pack missing glyphs into the texture atlas
  • upload pending glyphs before GUI/HUD custom text rendering
  • handle Unicode code points instead of only Java char values

Validation:

  • ./gradlew.bat build --stacktrace passes

This PR is based on master and does not include the Minecraft 26.2 update branch.

}

public static List<FontFace> getFallbackFonts(FontFace primary) {
List<FontFace> fonts = new ArrayList<>();

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.

Why you even need a list here? Isn't this just an Optional<FontFace>

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

Changed. You are right: this path selects at most one fallback face, so returning a List<FontFace> made the API more general than the implementation actually was. getFallbackFont(FontFace) now returns Optional<FontFace>, and readFontBuffers consumes it directly with flatMap / ifPresent.

I also tightened the related rendering path while rebasing this PR onto the latest master:

  • fallback selection skips the entire primary family, prefers the primary style, then Regular, and uses locale-stable name matching;
  • primary/fallback font buffers are loaded once and reused by GUI/HUD font sizes instead of rereading large CJK font files for every height;
  • width measurement now caches glyph metrics without rasterizing into (and consuming) the texture atlas;
  • missing prepacked glyphs correctly fall through to the fallback font, while supplementary Unicode code points remain handled as code points rather than UTF-16 chars;
  • partially filled initial atlases are accepted safely, missing/unpackable glyphs are cached, and one packing failure no longer disables all later glyphs;
  • renderer replacement and font cleanup are now atomic/idempotent, with HUD font resets deferred until the current frame finishes.

Validated with ./gradlew.bat build --stacktrace --console=plain (BUILD SUCCESSFUL).

@BerryRock0 BerryRock0 mentioned this pull request Jul 1, 2026
5 tasks
@gta66666668
gta66666668 force-pushed the codex/chinese-font-fallback branch from 67cdf45 to 18bb92d Compare July 18, 2026 12:21
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.

2 participants