From 5606a961f2523264baf5a6c9e01ec49b0045d1b5 Mon Sep 17 00:00:00 2001 From: Chris Waldon Date: Fri, 14 Jul 2023 16:59:28 -0400 Subject: [PATCH] text: fix bitmap y offset computation This commit fixes a bug that would incorrectly baseline bitmap glyphs text if the line contained another font with a taller line height. The logic for computing the y offset of the glyph incorrectly assumed that the Glyph.Ascent was particular to the glyph instead of the line. I've updated it to use a glyph-specific value. Signed-off-by: Chris Waldon --- text/gotext.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/text/gotext.go b/text/gotext.go index 429a502d..538a5ec0 100644 --- a/text/gotext.go +++ b/text/gotext.go @@ -674,7 +674,7 @@ func (s *shaperImpl) Bitmaps(ops *op.Ops, gs []Glyph) op.CallOp { } off := op.Affine(f32.Affine2D{}.Offset(f32.Point{ X: fixedToFloat((g.X - x) - g.Offset.X), - Y: fixedToFloat(g.Offset.Y - g.Ascent), + Y: fixedToFloat(g.Offset.Y + g.Bounds.Min.Y), })).Push(ops) cl := clip.Rect{Max: imgSize}.Push(ops)