// NewContext creates a new Context. func NewContext() *Context { return &Context{ r: raster.NewRasterizer(0, 0), glyphBuf: truetype.NewGlyphBuf(), fontSize: 12, dpi: 72, scale: 12 << 6, } }
//Glyph 字形 func (VC *VerifyCode) Glyph(s rune) (*Glyph, error) { var ( err error index truetype.Index ) truetypeFont := VC.Fonts.Random() truetypeGlyphBuf := truetype.NewGlyphBuf() index = truetypeFont.Index(s) err = truetypeGlyphBuf.Load(truetypeFont, truetypeFont.FUnitsPerEm(), index, VC.hinting()) if err != nil { return nil, err } return &Glyph{ G: truetypeGlyphBuf, F: truetypeFont, I: index, verifyCode: VC, text: s, }, nil }