#3486

Preserve primary-font glyphs with partial SD-card fallback fonts

Opencoderabbitai[bot]opened 1mo ago

Summary

GfxRenderer::resolveTextFontId() currently selects one font for an entire string. If an SD-card fallback font provides one unsupported non-ASCII glyph but does not provide all primary-font glyphs in the same string, rendering can omit the unsupported glyphs from the selected fallback font.

For example, a mixed string such as AԱ can select an Armenian fallback font for Ա. If that fallback font does not include A, renderCharImpl() skips A.

Required changes

Implement a consistent per-glyph fallback strategy, or an equivalent selection rule that preserves primary-font glyphs when the SD-card fallback has partial coverage.

Update the related text paths so they use the same fallback rule:

  • Drawing in lib/GfxRenderer/GfxRenderer.cpp, including normal and rotated text.
  • Text measurement in GfxRenderer::getTextWidth() and GfxRenderer::getTextAdvanceX().
  • SD-card glyph prewarming in GfxRenderer::prewarmFallbackText() and GfxRenderer::ensureSdGlyphsResident().

Rationale

PR #3484 expands SD-card GUI fallback support beyond CJK scripts. Script-specific fonts, such as Armenian fonts, commonly have partial Latin coverage. Whole-string fallback can therefore drop glyphs that the primary font can render.

Acceptance criteria

  • Mixed strings retain every glyph that the primary font or a compatible fallback font can render.
  • A partial fallback font does not cause primary-font Latin, digits, punctuation, or symbols to disappear.
  • Drawing, measurement, wrapping/truncation, and prewarming use consistent glyph-selection behavior.
  • Existing full-string fallback behavior remains correct for fonts that cover the complete rendered string.
  • Add focused regression coverage for a mixed primary-and-fallback string with a partial fallback font.

Backlinks

Activity

0

No activity yet.