提交 7a598da6 编写于 作者: N Nigel Tao

Delete the truetype.NewGlyphBuf function.

The zero value of a GlyphBuf is already perfectly usable.
上级 fe260676
...@@ -66,7 +66,7 @@ func main() { ...@@ -66,7 +66,7 @@ func main() {
i0 := f.Index(c0) i0 := f.Index(c0)
hm := f.HMetric(fupe, i0) hm := f.HMetric(fupe, i0)
g := truetype.NewGlyphBuf() g := &truetype.GlyphBuf{}
err = g.Load(f, fupe, i0, font.HintingNone) err = g.Load(f, fupe, i0, font.HintingNone)
if err != nil { if err != nil {
log.Println(err) log.Println(err)
......
...@@ -60,7 +60,7 @@ func Pt(x, y int) fixed.Point26_6 { ...@@ -60,7 +60,7 @@ func Pt(x, y int) fixed.Point26_6 {
type Context struct { type Context struct {
r *raster.Rasterizer r *raster.Rasterizer
f *truetype.Font f *truetype.Font
glyphBuf *truetype.GlyphBuf glyphBuf truetype.GlyphBuf
// clip is the clip rectangle for drawing. // clip is the clip rectangle for drawing.
clip image.Rectangle clip image.Rectangle
// dst and src are the destination and source images for drawing. // dst and src are the destination and source images for drawing.
...@@ -334,7 +334,6 @@ func (c *Context) SetClip(clip image.Rectangle) { ...@@ -334,7 +334,6 @@ func (c *Context) SetClip(clip image.Rectangle) {
func NewContext() *Context { func NewContext() *Context {
return &Context{ return &Context{
r: raster.NewRasterizer(0, 0), r: raster.NewRasterizer(0, 0),
glyphBuf: truetype.NewGlyphBuf(),
fontSize: 12, fontSize: 12,
dpi: 72, dpi: 72,
scale: 12 << 6, scale: 12 << 6,
......
...@@ -515,13 +515,3 @@ func (g *GlyphBuf) addPhantomsAndScale(np0, np1 int, simple, adjust bool) { ...@@ -515,13 +515,3 @@ func (g *GlyphBuf) addPhantomsAndScale(np0, np1 int, simple, adjust bool) {
p = &g.Point[len(g.Point)-1] p = &g.Point[len(g.Point)-1]
p.Y = (p.Y + 32) &^ 63 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),
}
}
...@@ -63,7 +63,7 @@ func TestParse(t *testing.T) { ...@@ -63,7 +63,7 @@ func TestParse(t *testing.T) {
t.Errorf("Kern: got %v, want %v", got, want) t.Errorf("Kern: got %v, want %v", got, want)
} }
g := NewGlyphBuf() g := &GlyphBuf{}
err = g.Load(f, fupe, i0, font.HintingNone) err = g.Load(f, fupe, i0, font.HintingNone)
if err != nil { if err != nil {
t.Fatalf("Load: %v", err) t.Fatalf("Load: %v", err)
...@@ -319,7 +319,7 @@ func testScaling(t *testing.T, h font.Hinting) { ...@@ -319,7 +319,7 @@ func testScaling(t *testing.T, h font.Hinting) {
continue continue
} }
glyphBuf := NewGlyphBuf() glyphBuf := &GlyphBuf{}
for i, want := range wants { for i, want := range wants {
if err = glyphBuf.Load(f, fixed.I(tc.size), Index(i), h); err != nil { 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) t.Errorf("%s: glyph #%d: Load: %v", tc.name, i, err)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册