Changed allg5ui.font.Measure() implementation to be more consistent with the sdlui implementation.

This commit is contained in:
Sander Schobers 2020-05-23 08:28:21 +02:00
parent b434a71f00
commit 2238f8749a

View File

@ -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)
}