Delete the truetype.NewGlyphBuf function.

The zero value of a GlyphBuf is already perfectly usable.
This commit is contained in:
Nigel Tao 2015-08-30 21:35:58 +10:00
parent fe26067669
commit 7a598da6de
4 changed files with 4 additions and 15 deletions

View File

@ -66,7 +66,7 @@ func main() {
i0 := f.Index(c0)
hm := f.HMetric(fupe, i0)
g := truetype.NewGlyphBuf()
g := &truetype.GlyphBuf{}
err = g.Load(f, fupe, i0, font.HintingNone)
if err != nil {
log.Println(err)

View File

@ -60,7 +60,7 @@ func Pt(x, y int) fixed.Point26_6 {
type Context struct {
r *raster.Rasterizer
f *truetype.Font
glyphBuf *truetype.GlyphBuf
glyphBuf truetype.GlyphBuf
// clip is the clip rectangle for drawing.
clip image.Rectangle
// dst and src are the destination and source images for drawing.
@ -334,7 +334,6 @@ func (c *Context) SetClip(clip image.Rectangle) {
func NewContext() *Context {
return &Context{
r: raster.NewRasterizer(0, 0),
glyphBuf: truetype.NewGlyphBuf(),
fontSize: 12,
dpi: 72,
scale: 12 << 6,

View File

@ -515,13 +515,3 @@ func (g *GlyphBuf) addPhantomsAndScale(np0, np1 int, simple, adjust bool) {
p = &g.Point[len(g.Point)-1]
p.Y = (p.Y + 32) &^ 63
}
// TODO: is this necessary? The zero-valued GlyphBuf is perfectly usable.
// NewGlyphBuf returns a newly allocated GlyphBuf.
func NewGlyphBuf() *GlyphBuf {
return &GlyphBuf{
Point: make([]Point, 0, 256),
End: make([]int, 0, 32),
}
}

View File

@ -63,7 +63,7 @@ func TestParse(t *testing.T) {
t.Errorf("Kern: got %v, want %v", got, want)
}
g := NewGlyphBuf()
g := &GlyphBuf{}
err = g.Load(f, fupe, i0, font.HintingNone)
if err != nil {
t.Fatalf("Load: %v", err)
@ -319,7 +319,7 @@ func testScaling(t *testing.T, h font.Hinting) {
continue
}
glyphBuf := NewGlyphBuf()
glyphBuf := &GlyphBuf{}
for i, want := range wants {
if err = glyphBuf.Load(f, fixed.I(tc.size), Index(i), h); err != nil {
t.Errorf("%s: glyph #%d: Load: %v", tc.name, i, err)