Skip to content

Commit

Permalink
Force stroke='none' if 'stroke-width' === 0 (#271)
Browse files Browse the repository at this point in the history
don't stroke text if stroke-width is zero

Co-authored-by: Anna-Lena Lumpp <anna-lena.lumpp@yworks.com>
Co-authored-by: Lukas Hollaender <lukas.hollaender@yworks.com>
  • Loading branch information
3 people committed Aug 10, 2023
1 parent 07b8ca1 commit c24a4e4
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/utils/text.ts
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions test/common/tests.js
Expand Up @@ -64,6 +64,7 @@ window.tests = [
'vertical-align',
'xml-space',
'zero-width-strokes',
'zero-width-strokes-text',
'current-color',
'text-length'
]
Binary file added test/specs/zero-width-strokes-text/reference.pdf
Binary file not shown.
3 changes: 3 additions & 0 deletions test/specs/zero-width-strokes-text/spec.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit c24a4e4

Please sign in to comment.