From e6d8aab97490c89bc6bf10f6dcb3a78fb2135f48 Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Tue, 31 Mar 2020 19:38:43 -0700 Subject: [PATCH] Don't draw backwards miters. --- content/src/stroke.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/content/src/stroke.rs b/content/src/stroke.rs index 9f6d8ad2..fe1ac17e 100644 --- a/content/src/stroke.rs +++ b/content/src/stroke.rs @@ -383,11 +383,15 @@ impl Contour { LineJoin::Bevel => {} LineJoin::Miter(miter_limit) => { if let Some(prev_tangent_t) = prev_tangent.intersection_t(next_tangent) { + if prev_tangent_t < -EPSILON { + return; + } let miter_endpoint = prev_tangent.sample(prev_tangent_t); let threshold = miter_limit * distance; - if (miter_endpoint - join_point).square_length() <= threshold * threshold { - self.push_endpoint(miter_endpoint); + if (miter_endpoint - join_point).square_length() > threshold * threshold { + return; } + self.push_endpoint(miter_endpoint); } } LineJoin::Round => {