diff --git a/allg5ui/font.go b/allg5ui/font.go index fb502ed..eb6a626 100644 --- a/allg5ui/font.go +++ b/allg5ui/font.go @@ -42,6 +42,8 @@ func (f *font) Measure(t string) geom.RectangleF32 { if f == nil { return geom.RectangleF32{} } - var x, y, w, h = f.TextDimensions(t) - return geom.RectF32(x, y, x+w, y+h) + // allg5.Font.TextDimentions (previous implementation) seems to return the closest fit rectangle to the drawn text (so depending on the glyphs). allg5.Font.TextWidth is giving the full width (not trimmed) which gives a better result together with allg5.Font.Height. + w := f.TextWidth(t) + h := f.Height() + return geom.RectRelF32(0, 0, w, h) }