From 03bdcc0fe1c41fb81c28f5ad739241c1f0b6ec9b Mon Sep 17 00:00:00 2001 From: Nigel Tao Date: Mon, 31 Aug 2015 11:34:42 +1000 Subject: [PATCH] Have face.Glyph return an advance width, not the new dot. This tracks an upstream change in the x/exp/shiny/font package. --- truetype/face.go | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/truetype/face.go b/truetype/face.go index 7730b9b..dea6524 100644 --- a/truetype/face.go +++ b/truetype/face.go @@ -239,7 +239,7 @@ func (a *face) Kern(r0, r1 rune) fixed.Int26_6 { // Glyph satisfies the font.Face interface. func (a *face) Glyph(dot fixed.Point26_6, r rune) ( - newDot fixed.Point26_6, dr image.Rectangle, mask image.Image, maskp image.Point, ok bool) { + dr image.Rectangle, mask image.Image, maskp image.Point, advance fixed.Int26_6, ok bool) { // Quantize to the sub-pixel granularity. dotX := (dot.X + a.subPixelBiasX) & a.subPixelMaskX @@ -265,17 +265,13 @@ func (a *face) Glyph(dot fixed.Point26_6, r rune) ( var ok bool v, ok = a.rasterize(index, fx, fy) if !ok { - return fixed.Point26_6{}, image.Rectangle{}, nil, image.Point{}, false + return image.Rectangle{}, nil, image.Point{}, 0, false } a.cache[cIndex] = cacheEntry{k, v} } else { v = a.cache[cIndex].val } - newDot = fixed.Point26_6{ - X: dot.X + v.advanceWidth, - Y: dot.Y, - } dr.Min = image.Point{ X: ix + v.offset.X, Y: iy + v.offset.Y, @@ -284,7 +280,7 @@ func (a *face) Glyph(dot fixed.Point26_6, r rune) ( X: dr.Min.X + v.gw, Y: dr.Min.Y + v.gh, } - return newDot, dr, a.masks, image.Point{Y: a.paintOffset}, true + return dr, a.masks, image.Point{Y: a.paintOffset}, v.advanceWidth, true } func (a *face) GlyphBounds(r rune) (bounds fixed.Rectangle26_6, advance fixed.Int26_6, ok bool) {