Sander Schobers
3591e22c97
- Fonts are now managed by context instead of the implementation specific renderers.
30 lines
478 B
Go
30 lines
478 B
Go
package sdlui
|
|
|
|
import (
|
|
"github.com/veandco/go-sdl2/ttf"
|
|
"opslag.de/schobers/geom"
|
|
)
|
|
|
|
type Font struct {
|
|
*ttf.Font
|
|
}
|
|
|
|
func (f *Font) Destroy() error {
|
|
f.Font.Close()
|
|
return nil
|
|
}
|
|
|
|
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)
|
|
}
|