SDWebImage / SDWebImageSVGCoder

A SVG coder plugin for SDWebImage, using Apple's built-in framework
MIT License
103 stars 34 forks source link

If 'x' inside 'text' represents multiple values, it will result in a rendering error. #50

Closed muyizl closed 9 months ago

muyizl commented 9 months ago
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" fill-rule="evenodd" height="48" preserveAspectRatio="none" stroke-linecap="round" viewBox="0 0 2240 480" width="224">
<style type="text/css">
.brush0 { fill: rgb(255,255,255); }
.pen0 { stroke: rgb(0,0,0); stroke-width: 1; stroke-linejoin: round; }
.font0 { font-size: 303px; font-family: "Times New Roman", serif; }
.font1 { font-style: italic; font-size: 303px; font-family: "Times New Roman", serif; }
.font2 { font-size: 274px; font-family: Symbol, serif; }
.font3 { font-weight: bold; font-size: 16px; font-family: System, sans-serif; }
</style>
<g>
<text class="font0" fill="rgb(0,0,0)" stroke="none" style="dominant-baseline: alphabetic;" x="154 264 836 1473 1925" xml:lang="en" xml:space="preserve" y="320">(3)13</text>
<text class="font1" fill="rgb(0,0,0)" stroke="none" style="dominant-baseline: alphabetic;" x="49 731 2077" xml:lang="en" xml:space="preserve" y="320">iii</text>
<text class="font2" fill="rgb(0,0,0)" stroke="none" style="dominant-baseline: alphabetic;" x="484 1026 1290 1678" xml:space="preserve" y="320">+=-+</text>
</g>
</svg>
截屏2024-01-18 16 41 26 截屏2024-01-18 16 43 04

In the aforementioned code, the 'x' inside 'text' represents multiple values, it seems that the current types of 'Coder' are not compatible.

dreampiggy commented 9 months ago

For this CoreSVG based implementation, we have no way to workaround. It's closed-source Apple OS vendor framework.

You can try to change the SVG by yourself and to workaround, or using anther like SVG-native based solution(https://github.com/SDWebImage/SDWebImageSVGNativeCoder)

But anyway, this is good point. We can add this in the readme.

muyizl commented 9 months ago

For this CoreSVG based implementation, we have no way to workaround. It's closed-source Apple OS vendor framework.

You can try to change the SVG by yourself and to workaround, or using anther like SVG-native based solution(https://github.com/SDWebImage/SDWebImageSVGNativeCoder)

But anyway, this is good point. We can add this in the readme.

The implementation based on SVGNativeCoder seems unable to render this SVG. Similarly, I have also reviewed the source code of SVGKit and it indeed does not handle the issue with multiple 'x' values. It looks like I'll need to resolve this on my own later.