Embedded Allegro font struct directly inside font wrapped.

This commit is contained in:
Sander Schobers 2020-05-13 16:49:45 +02:00
parent 8c11aec276
commit f618c55b25
2 changed files with 6 additions and 6 deletions

View File

@ -15,7 +15,7 @@ func NewFontDefinition(name string, size int) FontDefinition {
}
type font struct {
f *allg5.Font
*allg5.Font
}
func newFont(f *allg5.Font) *font {
@ -23,24 +23,24 @@ func newFont(f *allg5.Font) *font {
}
func (f *font) Destroy() {
f.f.Destroy()
f.Font.Destroy()
}
func (f *font) Height() float32 {
if f == nil {
return 0
}
return f.f.Height()
return f.Font.Height()
}
func (f *font) WidthOf(t string) float32 {
return f.f.TextWidth(t)
return f.TextWidth(t)
}
func (f *font) Measure(t string) geom.RectangleF32 {
if f == nil {
return geom.RectangleF32{}
}
var x, y, w, h = f.f.TextDimensions(t)
var x, y, w, h = f.TextDimensions(t)
return geom.RectF32(x, y, x+w, y+h)
}

View File

@ -265,7 +265,7 @@ func (r *Renderer) text(p geom.PointF32, font string, c color.Color, t string, a
return
}
x, y := snap(p)
f.f.Draw(x, y, newColor(c), align, t)
f.Draw(x, y, newColor(c), align, t)
}
func (r *Renderer) Text(p geom.PointF32, font string, c color.Color, t string) {