Skip to content

Commit

Permalink
text: fix bitmap y offset computation
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
whereswaldon authored and eliasnaur committed Jul 17, 2023
1 parent 6d925a1 commit 5606a96
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion text/gotext.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down

0 comments on commit 5606a96

Please sign in to comment.