Skip to content

Conversation

@rdon-key
Copy link

@rdon-key rdon-key commented Sep 3, 2025

This pull request fixes an issue where GetGlyph could return the glyph of the next larger rune if the requested rune was not found in the font.
As a result, undefined characters could be rendered as completely unrelated glyphs (see #58).

Changes

  • Updated GetGlyph in both const1bit and const2bit packages:
    • Added an equality check (==) during the binary search.
    • Introduced a found flag to ensure that if no match is found, the function always falls back to index 0.
  • Updated function comments to explicitly state that undefined runes return the glyph at index 0.

Verification

  • Verified with const2bit fonts (WebAssembly rendering).
  • Could not test with const1bit fonts locally, but the implementation is identical.
tinyfont.WriteLine(target, &testfont, 10, 50, "①②③④⑤", color.RGBA{0, 0, 0, 255})
image

Impact

  • Undefined runes will no longer render as unrelated valid glyphs.
  • Instead, they consistently fall back to glyph 0 (commonly a space or placeholder).

Fixes #58

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.

1 participant