Skip to content

Commit

Permalink
bugfix in rune path
Browse files Browse the repository at this point in the history
  • Loading branch information
tfriedel6 committed Mar 28, 2020
1 parent 1711693 commit 1d5a02b
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions text.go
Original file line number Diff line number Diff line change
Expand Up @@ -494,38 +494,32 @@ func (cv *Canvas) runePath(rn rune) *Path2D {

const scale = 1.0 / 64.0

gb := &truetype.GlyphBuf{}
gb.Load(cv.state.font.font, baseFontSize, idx, font.HintingNone)
var gb truetype.GlyphBuf
gb.Load(cv.state.font.font, baseFontSize, idx, font.HintingFull)

from := 0
for _, to := range gb.Ends {
ps := gb.Points[from:to]

start := fixed.Point26_6{
X: ps[0].X,
Y: ps[0].Y,
}
start := ps[0]
others := []truetype.Point(nil)
if ps[0].Flags&0x01 != 0 {
others = ps[1:]
} else {
last := fixed.Point26_6{
X: ps[len(ps)-1].X,
Y: ps[len(ps)-1].Y,
}
last := ps[len(ps)-1]
if ps[len(ps)-1].Flags&0x01 != 0 {
start = last
others = ps[:len(ps)-1]
} else {
start = fixed.Point26_6{
start = truetype.Point{
X: (start.X + last.X) / 2,
Y: (start.Y + last.Y) / 2,
}
others = ps
}
}

p0, on0 := gb.Points[from], false
p0, on0 := start, true
path.MoveTo(float64(p0.X)*scale, -float64(p0.Y)*scale)
for _, p := range others {
on := p.Flags&0x01 != 0
Expand Down

0 comments on commit 1d5a02b

Please sign in to comment.