25 lines
414 B
Go
25 lines
414 B
Go
|
package sdlui
|
||
|
|
||
|
import (
|
||
|
"github.com/veandco/go-sdl2/ttf"
|
||
|
"opslag.de/schobers/geom"
|
||
|
)
|
||
|
|
||
|
type Font struct {
|
||
|
*ttf.Font
|
||
|
}
|
||
|
|
||
|
func (f *Font) Height() float32 {
|
||
|
return float32(f.Font.Height())
|
||
|
}
|
||
|
|
||
|
func (f *Font) Measure(t string) geom.RectangleF32 {
|
||
|
w, h, _ := f.SizeUTF8(t)
|
||
|
return geom.RectF32(0, 0, float32(w), float32(h))
|
||
|
}
|
||
|
|
||
|
func (f *Font) WidthOf(t string) float32 {
|
||
|
w, _, _ := f.SizeUTF8(t)
|
||
|
return float32(w)
|
||
|
}
|