From c24a4e4aaf7d5e01f5100cd5e371a9a175e0d216 Mon Sep 17 00:00:00 2001 From: AnnaLena2704 <93154549+AnnaLena2704@users.noreply.github.com> Date: Thu, 10 Aug 2023 11:22:52 +0200 Subject: [PATCH] Force stroke='none' if 'stroke-width' === 0 (#271) don't stroke text if stroke-width is zero Co-authored-by: Anna-Lena Lumpp Co-authored-by: Lukas Hollaender --- src/utils/text.ts | 8 +++++--- test/common/tests.js | 1 + test/specs/zero-width-strokes-text/reference.pdf | Bin 0 -> 3220 bytes test/specs/zero-width-strokes-text/spec.svg | 3 +++ 4 files changed, 9 insertions(+), 3 deletions(-) create mode 100644 test/specs/zero-width-strokes-text/reference.pdf create mode 100644 test/specs/zero-width-strokes-text/spec.svg diff --git a/src/utils/text.ts b/src/utils/text.ts index 4e88b442..3f0592cd 100644 --- a/src/utils/text.ts +++ b/src/utils/text.ts @@ -9,11 +9,13 @@ type TextRenderingMode = typeof tol.renderingMode export function getTextRenderingMode(attributeState: AttributeState): TextRenderingMode { let renderingMode: TextRenderingMode = 'invisible' - if (attributeState.fill && attributeState.stroke) { + const doStroke = attributeState.stroke && attributeState.strokeWidth !== 0 + const doFill = attributeState.fill + if (doFill && doStroke) { renderingMode = 'fillThenStroke' - } else if (attributeState.fill) { + } else if (doFill) { renderingMode = 'fill' - } else if (attributeState.stroke) { + } else if (doStroke) { renderingMode = 'stroke' } return renderingMode diff --git a/test/common/tests.js b/test/common/tests.js index d505b8b1..81539663 100644 --- a/test/common/tests.js +++ b/test/common/tests.js @@ -64,6 +64,7 @@ window.tests = [ 'vertical-align', 'xml-space', 'zero-width-strokes', + 'zero-width-strokes-text', 'current-color', 'text-length' ] diff --git a/test/specs/zero-width-strokes-text/reference.pdf b/test/specs/zero-width-strokes-text/reference.pdf new file mode 100644 index 0000000000000000000000000000000000000000..f71354b29ecfb951ce2520f16ad780b631110c2e GIT binary patch literal 3220 zcmcH+TW;Dw@PAJ+KT#7^VRvoJqe77agcdawDY2BQQ9g`Wh$FL3?4?P1rkpLtWo@ER*^K;o}M z#)m42=CQ95uoj3i z#V(je>N{e)U&|Yk^tQ`*uL-sQcf#yy#R2zpar{as=_QfX!LK`G`>uL02jJeY6PJC? zz0m`ijhQdVttF=?jDHNq30zW0hLHMlPB9=KWsJ^>k!9iPp}!e#dx;_l_y-k!Qzq~| z#?R*?lZKQ6D;Yo0el!mB6!=A;k986(5ol--C#G}l#b8?)9xr>a949Bdw!QGfb`*|Z zUxWG!G#HG+;BJno{Mv44yg&(Z!_E|GZd9a$RU4@I^?e|z?3dNN=o`gE%w+E<6Xd#t zo~wkV0z31+q-MCi6LzP^x`#jK3pbdltC&NPiZkmGJ+!Pn$`^F0c ze+Tw&Zj5XDcc#SV-uTtKopiDPk3563rq~v@8Ub>1^E-c>jiT^B&(BxXSseN2%D^SZ zjRiOjSK$2_t|#s6-pTHLoR#VHYqb!NKna0cOV0v|3_&)KdkCrmnLv;O)IbTU;S|rn zI;5S2unkBHoWLf?bSNW;lyb4!AS@wGJ|aO{xs-;)aw!jqQ>P7Skn%5s(T(yAprZJ= zp6fE-%hB-h+*dK|-y~$ZtcZ#@z|{)ZBojos>lp?6-FLFts7nj?ne_Emh&T8-$en7H zyL89HB8aB6;7xIz%l5m$tSek*N-Xj= zYz$}Nyk?nKie`yUS{5ehQ(kF1m=XnCwONuYYm^EFx_a3T*{GM!!`&ED>M1YA9`mMv zt2!l}EyvE$nb-?LTneaI&V%oY;>L$jWFXBKOy<6xM3AN=J#^s`TB($OT#mLOxuTp& Tj2D|UW2{;g|Ap+G40?Y6J%V%B literal 0 HcmV?d00001 diff --git a/test/specs/zero-width-strokes-text/spec.svg b/test/specs/zero-width-strokes-text/spec.svg new file mode 100644 index 00000000..864fd394 --- /dev/null +++ b/test/specs/zero-width-strokes-text/spec.svg @@ -0,0 +1,3 @@ + + Text +