From a0a1cea27095bd671b3b1b02e30dced3d1f20755 Mon Sep 17 00:00:00 2001 From: Thomas Friedel Date: Tue, 24 Mar 2020 14:25:51 +0100 Subject: [PATCH] faster font contour path --- path2d.go | 7 ++++++- text.go | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/path2d.go b/path2d.go index 115704d..d40c1c8 100644 --- a/path2d.go +++ b/path2d.go @@ -16,6 +16,8 @@ type Path2D struct { standalone bool fillCache []backendbase.Vec + + noSelfIntersection bool } type pathPoint struct { @@ -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} diff --git a/text.go b/text.go index 5ee7362..4d001d7 100644 --- a/text.go +++ b/text.go @@ -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