Also preserve empty path segments if stroke-linecap is square
This was implemented for round linecaps in 6c50c78d99 but applies to square linecaps, too (only butt is not rendered).
See https://www.w3.org/TR/SVG11/implnote.html#PathElementImplementationNotes for details.
This commit is contained in:
parent
b7bfb3250a
commit
05c2dde477
1 changed files with 4 additions and 4 deletions
|
|
@ -2045,9 +2045,9 @@ def cleanPath(element, options):
|
||||||
oldPathStr = element.getAttribute('d')
|
oldPathStr = element.getAttribute('d')
|
||||||
path = svg_parser.parse(oldPathStr)
|
path = svg_parser.parse(oldPathStr)
|
||||||
|
|
||||||
# This determines whether the stroke has round linecaps. If it does,
|
# This determines whether the stroke has round or square linecaps. If it does, we do not want to collapse empty
|
||||||
# we do not want to collapse empty segments, as they are actually rendered.
|
# segments, as they are actually rendered (as circles or squares with diameter/dimension matching the path-width).
|
||||||
withRoundLineCaps = element.getAttribute('stroke-linecap') == 'round'
|
has_round_or_square_linecaps = element.getAttribute('stroke-linecap') in ['round', 'square']
|
||||||
|
|
||||||
# This determines whether the stroke has intermediate markers. If it does, we do not want to collapse
|
# This determines whether the stroke has intermediate markers. If it does, we do not want to collapse
|
||||||
# straight segments running in the same direction, as markers are rendered on the intermediate nodes.
|
# straight segments running in the same direction, as markers are rendered on the intermediate nodes.
|
||||||
|
|
@ -2162,7 +2162,7 @@ def cleanPath(element, options):
|
||||||
# remove empty segments
|
# remove empty segments
|
||||||
# Reuse the data structure 'path' and the coordinate lists, even if we're
|
# Reuse the data structure 'path' and the coordinate lists, even if we're
|
||||||
# deleting items, because these deletions are relatively cheap.
|
# deleting items, because these deletions are relatively cheap.
|
||||||
if not withRoundLineCaps:
|
if not has_round_or_square_linecaps:
|
||||||
for pathIndex in range(0, len(path)):
|
for pathIndex in range(0, len(path)):
|
||||||
cmd, data = path[pathIndex]
|
cmd, data = path[pathIndex]
|
||||||
i = 0
|
i = 0
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue