feat(canvas): measure labels with real font metrics via engine callback (DasherCore v0.2.4) - #33
Merged
Merged
Conversation
willwade
force-pushed
the
fix/speed-bounds-from-engine
branch
from
August 24, 2026 21:02
9795046 to
2a49d13
Compare
willwade
added a commit
that referenced
this pull request
Aug 24, 2026
SP_DASHER_FONT was read after dasher_frame() returned, so on the frame following a font change the engine measured labels with the previous font while the renderer drew the commands with the new one - one transient frame of clipped/overlapping labels per font change (caught in review of #33). Read + invalidate before the frame so measurement and rendering always see the same typeface. Signed-off-by: will wade <willwade@gmail.com>
willwade
force-pushed
the
feat/text-size-callback
branch
from
August 24, 2026 21:02
8e46dab to
9671a4b
Compare
Wire DasherCore v0.2.4's dasher_set_text_size_callback: the engine measures single-line labels with the same typeface the canvas draws opcode-5 text with (the user-selected Dasher font, or Segoe UI) instead of its code-points x fontSize/2 estimate, which under-measured wide Segoe UI glyphs by up to 2x and compounded into the jumbled, squashed, cut-off labels at the right edge on long sentences (#28, DasherCore #56; the reporting user runs v5 on Windows without the problem). - measuring and drawing share CommandRenderer.ResolveTypeface so they can never disagree - SP_DASHER_FONT is read and dasher_text_metrics_changed() invalidates the engine's measurement cache BEFORE dasher_frame(), so measurement never lags rendering after a font change - failures return 0: the engine falls back to its estimate and retries next frame without caching Recreated from the stacked branch onto post-merge main; content identical to the reviewed commits. Fixes #28 Signed-off-by: will wade <willwade@gmail.com>
willwade
force-pushed
the
feat/text-size-callback
branch
from
August 24, 2026 21:18
9671a4b to
e01a5f0
Compare
Contributor
Author
|
@greptile re-review |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Wires DasherCore v0.2.4's
dasher_set_text_size_callback(#28's Windows-side actions; engine fix = DasherCore #56 / PR #57): the engine now asks the frontend to measure single-line labels with real font metrics instead of its code-points × fontSize/2 estimate. The estimate under-measured wide Segoe UI glyphs by up to ~2× and the error compounded down the ancestor label chain — long sentences ended with jumbled, squashed, cut-off labels at the right edge (the reporting user's screenshots; she runs v5 on Windows without the problem).CommandRenderer.ResolveTypeface(user-selected Dasher font, or Segoe UI) so layout can never disagree with renderingdasher_text_metrics_changed()invalidates the engine's measurement cache wheneverSP_DASHER_FONTchanges (font picker, settings import)dasher_frame()thread = the UI thread (DispatcherTimer), soFormattedTextis safeSubmodule pin: v0.2.4 (bumped in the stacked #32).
Issue / RFC: #28, DasherCore #56, DasherCore #57
Type of change
Cross-platform impact
Manual verification (RFC 0011)
Definition of Done
Stacked on #30 → #31 → #32. Fixes #28
Greptile Summary
The PR integrates DasherCore’s text-size callback so label layout uses the same Avalonia typeface metrics as rendering.
Confidence Score: 5/5
The PR appears safe to merge.
No blocking failure remains.
Important Files Changed
Sequence Diagram
sequenceDiagram participant Timer as UI DispatcherTimer participant Canvas as DasherCanvas participant Core as DasherCore participant Renderer as CommandRenderer Timer->>Canvas: OnTick() Canvas->>Core: Read SP_DASHER_FONT alt Font changed Canvas->>Core: dasher_text_metrics_changed() end Canvas->>Core: dasher_frame() Core->>Canvas: OnTextSize(label, size) Canvas->>Renderer: ResolveTypeface(_dasherFont) Canvas-->>Core: measured width and height Core-->>Canvas: drawing commands Canvas->>Renderer: Render(..., _dasherFont)Reviews (3): Last reviewed commit: "feat(canvas): measure labels with real f..." | Re-trigger Greptile