From 066f4f55bb2f53b58ccbeff8ba2d60c71294f1ba Mon Sep 17 00:00:00 2001 From: Thomas Friedel Date: Sun, 22 Mar 2020 09:50:32 +0100 Subject: [PATCH] kerning in StrokeText --- text.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/text.go b/text.go index 31e282f..fb92102 100644 --- a/text.go +++ b/text.go @@ -326,11 +326,20 @@ func (cv *Canvas) StrokeText(str string, x, y float64) { prevPath := cv.path cv.BeginPath() + prev, hasPrev := truetype.Index(0), false for _, rn := range str { idx := fnt.Index(rn) if idx == 0 { idx = fnt.Index(' ') } + + if hasPrev { + kern := fnt.Kern(cv.state.fontSize, prev, idx) + if frc.hinting != font.HintingNone { + kern = (kern + 32) &^ 63 + } + x += float64(kern) / 64 + } advance, _, err := frc.glyphMeasure(idx, fixed.Point26_6{}) if err != nil { continue