Skip to content

fix: preload fallback fonts on await draw and fix mesh '?' width - #56

Merged
mlightcad merged 1 commit into
mainfrom
fix/await-fallback-fonts-and-mesh-placeholder
Aug 9, 2026
Merged

mlightcad merged 1 commit into
mainfrom
fix/await-fallback-fonts-and-mesh-placeholder

Conversation

@mlightcad

@mlightcad mlightcad commented Aug 9, 2026

Copy link
Copy Markdown
Owner

Summary

  • When awaitFonts is enabled, MText/Shape.asyncDraw also requests default/symbol fallback fonts from getFontsToLoad(), so single-pass draws can resolve glyphs like diameter (U+2205 → amgdt) without relying on a later fontLoaded redraw.
  • MeshFont.getNotFoundTextShape now goes through getCharShape('?') so the glyph is loaded before measuring advance width, preventing zero-width placeholders that overlap the next character.
  • Bump @mlightcad/mtext-renderer to 0.12.4 and add regression coverage for both behaviors.

Test plan

  • Run packages/mtext-renderer vitest suite (including meshFont.notFound and render-remote-font-loading)
  • With awaitFontsBeforeDraw / awaitFonts: true, draw MText containing U+2205 and confirm diameter resolves on the first pass
  • Confirm a missing mesh glyph shows ? with non-zero advance and no overlap with the following character
  • Confirm fire-and-forget lazy draws (awaitFonts: false) still only request content/style fonts

Single-pass awaitFonts must load default/symbol chains (e.g. amgdt for U+2205), and MeshFont not-found placeholders need getCharShape so advance width is non-zero.

Co-authored-by: Cursor <cursoragent@cursor.com>
@mlightcad mlightcad self-assigned this Aug 9, 2026
@mlightcad mlightcad added the bug Something isn't working label Aug 9, 2026
@mlightcad
mlightcad merged commit 3393325 into main Aug 9, 2026
2 checks passed
@mlightcad
mlightcad deleted the fix/await-fallback-fonts-and-mesh-placeholder branch August 9, 2026 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant