示例#1
0
func (m *Module) setup() (err error) {
	// Retrieve the default system font, encoded as a TTF.
	ttfBytes := font.Default()

	m.font, err = truetype.Parse(ttfBytes)
	return err
}
示例#2
0
func NewSquare(glctx gl.Context, inc, x, y float32) (*Square, error) {
	images := glutil.NewImages(glctx)
	img1 := images.NewImage(800, 200)

	ftctx := freetype.NewContext()
	ftFont, err := freetype.ParseFont(font.Default())
	if err != nil {
		return nil, err
	}
	ftctx.SetFont(ftFont)

	ftctx.SetDPI(312)
	ftctx.SetSrc(image.NewUniform(colornames.Map["black"]))
	ftctx.SetDst(img1.RGBA)
	ftctx.SetClip(img1.RGBA.Bounds())
	ftctx.SetHinting(ifont.HintingFull)

	sq := &Square{
		images: images,
		img1:   img1,
		ftctx:  ftctx,
	}
	return sq, nil
}