package allg5ui import ( "opslag.de/schobers/allg5" "opslag.de/schobers/geom" ) type FontDefinition struct { Name string Size int } func NewFontDefinition(name string, size int) FontDefinition { return FontDefinition{Name: name, Size: size} } type font struct { *allg5.Font } func newFont(f *allg5.Font) *font { return &font{f} } func (f *font) Destroy() error { f.Font.Destroy() return nil } func (f *font) Height() float32 { if f == nil { return 0 } return f.Font.Height() } func (f *font) WidthOf(t string) float32 { return f.TextWidth(t) } func (f *font) Measure(t string) geom.RectangleF32 { if f == nil { return geom.RectangleF32{} } // 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) }