removed dead code
enabled font hinting
This commit is contained in:
parent
59ddfe59c1
commit
978852494a
2 changed files with 1 additions and 37 deletions
38
freetype.go
38
freetype.go
|
@ -8,7 +8,6 @@ package canvas
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"image"
|
"image"
|
||||||
"image/draw"
|
|
||||||
|
|
||||||
"github.com/golang/freetype/raster"
|
"github.com/golang/freetype/raster"
|
||||||
"github.com/golang/freetype/truetype"
|
"github.com/golang/freetype/truetype"
|
||||||
|
@ -42,8 +41,6 @@ type frContext struct {
|
||||||
r *raster.Rasterizer
|
r *raster.Rasterizer
|
||||||
f *truetype.Font
|
f *truetype.Font
|
||||||
glyphBuf truetype.GlyphBuf
|
glyphBuf truetype.GlyphBuf
|
||||||
// dst and src are the destination and source images for drawing.
|
|
||||||
dst draw.Image
|
|
||||||
|
|
||||||
fontSize fixed.Int26_6
|
fontSize fixed.Int26_6
|
||||||
hinting font.Hinting
|
hinting font.Hinting
|
||||||
|
@ -236,37 +233,6 @@ func (c *frContext) recalc() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// setFont sets the font used to draw text.
|
|
||||||
func (c *frContext) setFont(f *truetype.Font) {
|
|
||||||
if c.f == f {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
c.f = f
|
|
||||||
c.recalc()
|
|
||||||
}
|
|
||||||
|
|
||||||
// setFontSize sets the font size in points (as in "a 12 point font").
|
|
||||||
func (c *frContext) setFontSize(fontSize fixed.Int26_6) {
|
|
||||||
if c.fontSize == fontSize {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
c.fontSize = fontSize
|
|
||||||
c.recalc()
|
|
||||||
}
|
|
||||||
|
|
||||||
// setHinting sets the hinting policy.
|
|
||||||
func (c *frContext) setHinting(hinting font.Hinting) {
|
|
||||||
c.hinting = hinting
|
|
||||||
for i := range c.cache {
|
|
||||||
c.cache[i] = cacheEntry{}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// setDst sets the destination image for draw operations.
|
|
||||||
func (c *frContext) setDst(dst draw.Image) {
|
|
||||||
c.dst = dst
|
|
||||||
}
|
|
||||||
|
|
||||||
func (c *frContext) cacheSize() int {
|
func (c *frContext) cacheSize() int {
|
||||||
if c.f == nil {
|
if c.f == nil {
|
||||||
return 0
|
return 0
|
||||||
|
@ -282,12 +248,10 @@ func (c *frContext) cacheSize() int {
|
||||||
return w * h * len(c.cache)
|
return w * h * len(c.cache)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(nigeltao): implement Context.SetGamma.
|
|
||||||
|
|
||||||
// NewContext creates a new Context.
|
|
||||||
func newFRContext() *frContext {
|
func newFRContext() *frContext {
|
||||||
return &frContext{
|
return &frContext{
|
||||||
r: raster.NewRasterizer(0, 0),
|
r: raster.NewRasterizer(0, 0),
|
||||||
fontSize: fixed.I(12),
|
fontSize: fixed.I(12),
|
||||||
|
hinting: font.HintingFull,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
BIN
testdata/Text.png
vendored
BIN
testdata/Text.png
vendored
Binary file not shown.
Before Width: | Height: | Size: 1.9 KiB After Width: | Height: | Size: 1.9 KiB |
Loading…
Reference in a new issue