freetype: s/float/float64/.

R=adg, r2
CC=golang-dev
http://codereview.appspot.com/4040045
This commit is contained in:
Nigel Tao 2011-01-21 12:27:50 +11:00
parent 18fe7866b3
commit 380b6363b2
4 changed files with 11 additions and 12 deletions

View File

@ -21,8 +21,8 @@ import (
var (
dpi = flag.Int("dpi", 72, "screen resolution in Dots Per Inch")
fontfile = flag.String("fontfile", "../../luxi-fonts/luxisr.ttf", "filename of the ttf font")
size = flag.Float("size", 12, "font size in points")
spacing = flag.Float("spacing", 1.5, "line spacing (e.g. 2 means double spaced)")
size = flag.Float64("size", 12, "font size in points")
spacing = flag.Float64("spacing", 1.5, "line spacing (e.g. 2 means double spaced)")
wonb = flag.Bool("whiteonblack", false, "white text on a black background")
)

View File

@ -55,7 +55,7 @@ func main() {
draw.Draw(rgba, image.Rect(0, h/2, w, h), image.White, image.ZP)
mask := image.NewAlpha(50, 50)
painter := raster.NewAlphaSrcPainter(mask)
gammas := []float{1.0 / 10.0, 1.0 / 3.0, 1.0 / 2.0, 2.0 / 3.0, 4.0 / 5.0, 1.0, 5.0 / 4.0, 3.0 / 2.0, 2.0, 3.0, 10.0}
gammas := []float64{1.0 / 10.0, 1.0 / 3.0, 1.0 / 2.0, 2.0 / 3.0, 4.0 / 5.0, 1.0, 5.0 / 4.0, 3.0 / 2.0, 2.0, 3.0, 10.0}
for i, g := range gammas {
clear(mask)
r.Rasterize(raster.NewGammaCorrectionPainter(painter, g))

View File

@ -69,7 +69,7 @@ type Context struct {
// which equals 384 fixed point units per 256 FUnits.
// To check this, 1 em * 2048 FUnits per em * 384 fixed point units per 256 FUnits
// equals 3072 fixed point units.
fontSize float
fontSize float64
dpi int
upe int
scale int
@ -97,8 +97,8 @@ func (c *Context) FUnitToPixelRU(x int) int {
// PointToFix32 converts the given number of points (as in ``a 12 point font'')
// into fixed point units.
func (c *Context) PointToFix32(x float) raster.Fix32 {
return raster.Fix32(x * float(c.dpi) * (256.0 / 72.0))
func (c *Context) PointToFix32(x float64) raster.Fix32 {
return raster.Fix32(x * float64(c.dpi) * (256.0 / 72.0))
}
// drawContour draws the given closed contour with the given offset.
@ -243,7 +243,7 @@ func (c *Context) DrawString(s string, p raster.Point) (raster.Point, os.Error)
// recalc recalculates scale and bounds values from the font size, screen
// resolution and font metrics, and invalidates the glyph cache.
func (c *Context) recalc() {
c.scale = int((c.fontSize * float(c.dpi) * 256 * 256) / (float(c.upe) * 72))
c.scale = int((c.fontSize * float64(c.dpi) * 256 * 256) / (float64(c.upe) * 72))
if c.font == nil {
c.r.SetBounds(0, 0)
} else {
@ -283,7 +283,7 @@ func (c *Context) SetFont(font *truetype.Font) {
}
// SetFontSize sets the font size in points (as in ``a 12 point font'').
func (c *Context) SetFontSize(fontSize float) {
func (c *Context) SetFontSize(fontSize float64) {
if c.fontSize == fontSize {
return
}

View File

@ -273,23 +273,22 @@ func (g *GammaCorrectionPainter) Paint(ss []Span, done bool) {
}
// SetGamma sets the gamma value.
func (g *GammaCorrectionPainter) SetGamma(gamma float) {
func (g *GammaCorrectionPainter) SetGamma(gamma float64) {
if gamma == 1.0 {
g.gammaIsOne = true
return
}
g.gammaIsOne = false
gamma64 := float64(gamma)
for i := 0; i < 256; i++ {
a := float64(i) / 0xff
a = math.Pow(a, gamma64)
a = math.Pow(a, gamma)
g.a[i] = uint16(0xffff * a)
}
}
// NewGammaCorrectionPainter creates a new GammaCorrectionPainter that wraps
// the given Painter.
func NewGammaCorrectionPainter(p Painter, gamma float) *GammaCorrectionPainter {
func NewGammaCorrectionPainter(p Painter, gamma float64) *GammaCorrectionPainter {
g := &GammaCorrectionPainter{Painter: p}
g.SetGamma(gamma)
return g