I have this code inside a Go package of mine. It must load the cmr10.ttf
font file. So, the font file must be next to every executable which is using this package.
import (
"github.com/deadsy/sdfx/sdf"
)
func Text(txt string, height, thickness, roundness float32) (sdf.SDF3, error) {
f, err := sdf.LoadFont("cmr10.ttf")
if err != nil {
return nil, err
}
t := sdf.NewText(txt)
s2d, err := sdf.TextSDF2(f, t, float64(height))
if err != nil {
return nil, err
}
// Extrude the 2D SDF to a 3D SDF.
return sdf.ExtrudeRounded3D(s2d, float64(thickness), float64(roundness))
}
Question
Is there a way to avoid copying the cmr10.ttf
font file next to any executable using this package?
For example, like embedding the font file into the built binary. If possible, how to exactly do it?
Any other idea to try?