diff --git a/example/truetype/main.go b/example/truetype/main.go index 6ab93fcc40267255230f7d0a8dc3173c90133828..d188d9b30d8a55476f8b72db00d7860813f376f0 100644 --- a/example/truetype/main.go +++ b/example/truetype/main.go @@ -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) diff --git a/freetype.go b/freetype.go index 885de24f454ad4aeb65ced41ba74d785c4de1dbf..a1d4ad155e0cd34dc048c15de6fd0925c5466258 100644 --- a/freetype.go +++ b/freetype.go @@ -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, diff --git a/truetype/glyph.go b/truetype/glyph.go index 1d549de87e38112bf29afa895ddeaa7acca0fcde..7a4946fe515f01544473ae8e877dd1735243ce4d 100644 --- a/truetype/glyph.go +++ b/truetype/glyph.go @@ -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), - } -} diff --git a/truetype/truetype_test.go b/truetype/truetype_test.go index 0f3253d2af72fe390a1ba28e5aa9fd3c1bd8c5bc..53b81dceb6c384458695cda03d3242ad9aa9f5b2 100644 --- a/truetype/truetype_test.go +++ b/truetype/truetype_test.go @@ -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)