From 2238f8749a8e66b5dbc5ccf6f7e2567a97c923b9 Mon Sep 17 00:00:00 2001 From: Sander Schobers Date: Sat, 23 May 2020 08:28:21 +0200 Subject: [PATCH] Changed allg5ui.font.Measure() implementation to be more consistent with the sdlui implementation. --- allg5ui/font.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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) }