Fix filename rendering: split drawText into layout + drawLineText to avoid triple LayoutString calls

Co-authored-by: Qwen-Coder <qwen-coder@alibabacloud.com>
This commit is contained in:
Greg Pomerantz 2026-05-09 11:26:35 -04:00
parent 0f62ef32fa
commit 1acad99450
2 changed files with 6 additions and 3 deletions

View File

@ -230,9 +230,9 @@ func (r *Renderer) drawTruncatedText(gtx layout.Context, shp *text.Shaper, str s
}
}
// Re-layout truncated text and draw
// Re-layout truncated text and draw glyphs directly
shp.LayoutString(text.Parameters{PxPerEm: fixed.I(gtx.Sp(size))}, fullStr)
r.drawText(gtx, shp, fullStr, size, x, y, col)
r.drawLineText(gtx, shp, x, y, col)
}
// drawText draws text using the same approach as Gio's textView:
@ -240,8 +240,11 @@ func (r *Renderer) drawTruncatedText(gtx layout.Context, shp *text.Shaper, str s
func (r *Renderer) drawText(gtx layout.Context, shp *text.Shaper, str string, size unit.Sp, x, y unit.Dp, col color.NRGBA) {
// Layout text
shp.LayoutString(text.Parameters{PxPerEm: fixed.I(gtx.Sp(size))}, str)
r.drawLineText(gtx, shp, x, y, col)
}
// Draw glyphs using the same approach as Gio's textView
// drawLineText draws already-laid-out glyphs using shaper.Shape() and shaper.Bitmaps().
func (r *Renderer) drawLineText(gtx layout.Context, shp *text.Shaper, x, y unit.Dp, col color.NRGBA) {
var glyphs [32]text.Glyph
line := glyphs[:0]
for g, ok := shp.NextGlyph(); ok; g, ok = shp.NextGlyph() {

BIN
pad

Binary file not shown.