Skip to content

Commit

Permalink
kerning in StrokeText
Browse files Browse the repository at this point in the history
  • Loading branch information
tfriedel6 committed Mar 22, 2020
1 parent d3cc20f commit 066f4f5
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions text.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 066f4f5

Please sign in to comment.