fix(textfield): cursor rounding, horizontal scroll, hinted advances (#211, #212) - #213
Merged
Conversation
…ext (#211) DrawText rounds text origin with math.Round(x), but CursorX used raw contentRect.Min.X — up to 0.5px constant offset. Now both agree.
TextField scrolls text horizontally when content exceeds visible width. Cursor stays near right edge via ensureCursorVisible (Flutter pattern). TextRect in PaintState separates text origin from clip rect. All 4 theme painters use TextRect for DrawText, ContentRect for PushClip. Known: cursor-scroll sync has drift on fast input (investigating).
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
This was referenced Aug 7, 2026
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
math.Round(fix(textfield): cursor position drifts on wide Cyrillic glyphs (ы, ш, щ, ж) #211)Details
Cursor rounding (#211)
DrawTextrounds text origin withmath.Round(x), butCursorXused rawcontentRect.Min.X— up to 0.5px constant offset.Horizontal scroll (#212)
TextField now scrolls text horizontally when content exceeds visible width.
ensureCursorVisible()adjustsscrollOffsetXto keep cursor within the visible content area.TextRectin PaintState separates text drawing origin from clip rect (ContentRect).Cursor-scroll sync (Flutter/Qt pattern)
Root cause of cursor drift:
CursorXclamped toscrolledRect.Max.X(shifted far left) instead of the visible area. Fix: compute cursor in text-local coordinates (unshiftedcontentRect), then applyscrollOffsetXuniformly to cursor and selection — matching Flutter_paintOffsetand QttopLeftpatterns.Hinted advances (gg#479)
gg v0.50.13:
Face.Advance()now returns hinted advances matchingdrawGlyphspositioning. Eliminates per-glyph cursor drift on wide Cyrillic characters.Test plan
go build ./...go test ./... -count=1(61 packages, 0 fail)golangci-lint run --timeout=5m(0 issues)