Skip to content

Commit

Permalink
faster font contour path
Browse files Browse the repository at this point in the history
  • Loading branch information
tfriedel6 committed Mar 24, 2020
1 parent c36395c commit a0a1cea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion path2d.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ type Path2D struct {

standalone bool
fillCache []backendbase.Vec

noSelfIntersection bool
}

type pathPoint struct {
Expand Down Expand Up @@ -104,9 +106,12 @@ func (p *Path2D) lineTo(x, y float64, checkSelfIntersection bool) {
}
}

csi := checkSelfIntersection && !Performance.IgnoreSelfIntersections && !p.noSelfIntersection

if prev.flags&pathSelfIntersects > 0 {
newp.flags |= pathSelfIntersects
} else if newp.flags&pathIsConvex == 0 && newp.flags&pathSelfIntersects == 0 && checkSelfIntersection && !Performance.IgnoreSelfIntersections {
} else if newp.flags&pathIsConvex == 0 && newp.flags&pathSelfIntersects == 0 && csi {

cuts := false
var cutPoint backendbase.Vec
b0, b1 := prev.pos, backendbase.Vec{x, y}
Expand Down
2 changes: 1 addition & 1 deletion text.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,7 +489,7 @@ func (cv *Canvas) runePath(rn rune) *Path2D {
}
}

path := &Path2D{cv: cv, p: make([]pathPoint, 0, 50), standalone: true}
path := &Path2D{cv: cv, p: make([]pathPoint, 0, 50), standalone: true, noSelfIntersection: true}

const scale = 1.0 / 64.0

Expand Down

0 comments on commit a0a1cea

Please sign in to comment.