2019-03-05 20:52:18 +00:00
|
|
|
package allg5ui
|
|
|
|
|
|
|
|
import (
|
|
|
|
"opslag.de/schobers/geom"
|
|
|
|
"opslag.de/schobers/zntg/allg5"
|
|
|
|
)
|
|
|
|
|
|
|
|
type FontDefinition struct {
|
|
|
|
Name string
|
|
|
|
Size int
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewFontDefinition(name string, size int) FontDefinition {
|
|
|
|
return FontDefinition{Name: name, Size: size}
|
|
|
|
}
|
|
|
|
|
|
|
|
type font struct {
|
|
|
|
f *allg5.Font
|
|
|
|
}
|
|
|
|
|
|
|
|
func newFont(f *allg5.Font) *font {
|
|
|
|
return &font{f}
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *font) Destroy() {
|
|
|
|
f.f.Destroy()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *font) Height() float32 {
|
|
|
|
if f == nil {
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
return f.f.Height()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (f *font) WidthOf(t string) float32 {
|
2019-04-13 08:18:00 +00:00
|
|
|
return f.f.TextWidth(t)
|
2019-03-05 20:52:18 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (f *font) Measure(t string) geom.RectangleF32 {
|
|
|
|
if f == nil {
|
|
|
|
return geom.RectangleF32{}
|
|
|
|
}
|
|
|
|
var x, y, w, h = f.f.TextDimensions(t)
|
|
|
|
return geom.RectF32(x, y, x+w, y+h)
|
|
|
|
}
|