kerning in StrokeText
This commit is contained in:
parent
d3cc20f911
commit
066f4f55bb
1 changed files with 9 additions and 0 deletions
9
text.go
9
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
|
||||
|
|
Loading…
Reference in a new issue