我面临一个问题,字体样式未按照 SVG 中的定义应用。请注意,我正在使用 inkscape 创建 SVG 文件。
我正在使用 imagemagick,但是它不能很好地播放,或者它不尊重应用于 SVG 字体的这种特定样式。
<tspan y="300.2991" x="92.389214" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:42.22720337px;font-family:Impact;-inkscape-font-specification:Impact;text-align:center;text-anchor:middle;fill:#ffffff;stroke-width:0.3480221" id="tspan1159-0" sodipodi:role="line" textLength="80%" lengthAdjust="spacingAndGlyphs">Diploma Computer Engineering</tspan>
</text>
具体来说,我希望正确应用这种样式:
textLength="80%" lengthAdjust="spacingAndGlyphs"
但我不确定为什么 imagemagick 在转换为 PNG 时会忽略它们。
或者,请指导我选择使用 C# 以编程方式将 svg 转换为 png 的最佳库/工具?
SVG 文件
<!-- Created with Inkscape (http://www.inkscape.org/) -->
<svg xmlns="http://www.w3.org/2000/svg" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:cc="http://creativecommons.org/ns#" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:svg="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd" xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape" width="200mm" height="200mm" viewBox="0 0 200 200" version="1.1" id="svg933" inkscape:version="0.92.4 (5da689c313, 2019-01-14)" sodipodi:docname="Generic-basic-001.svg">
<defs id="defs927" />
<sodipodi:namedview id="base" pagecolor="#ffffff" bordercolor="#666666" borderopacity="1.0" inkscape:pageopacity="0.0" inkscape:pageshadow="2" inkscape:zoom="0.7" inkscape:cx="420.83998" inkscape:cy="361.08122" inkscape:document-units="mm" inkscape:current-layer="g4841" showgrid="false" showguides="true" inkscape:guide-bbox="true" inkscape:window-width="1600" inkscape:window-height="837" inkscape:window-x="-8" inkscape:window-y="-8" inkscape:window-maximized="1" />
<metadata id="metadata930">
<rdf:RDF>
<cc:Work rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g inkscape:label="Layer 1" inkscape:groupmode="layer" id="layer1" transform="translate(0,-97)">
<g id="g4841" transform="translate(2.3899998e-6,13.099254)">
<path d="M 7.7005693,261.48884 0.85816725,240.68517 H 199.23209 l -7.0088,20.80367 6.6641,20.87657 H 0.85816725 Z" style="fill:#00329f;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277775" id="path_1657007234" inkscape:connector-curvature="0" sodipodi:nodetypes="ccccccc" />
<text y="300.2991" x="92.389214" id="text_534011718" style="font-variant:normal;font-weight:normal;font-stretch:normal;font-size:15.37923622px;font-family:Bitter;-inkscape-font-specification:Bitter-Regular;writing-mode:lr-tb;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.3480221" transform="scale(1.084439,0.92213577)">
<tspan y="300.2991" x="92.389214" style="font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:42.22720337px;font-family:Impact;-inkscape-font-specification:Impact;text-align:center;text-anchor:middle;fill:#ffffff;stroke-width:0.3480221" id="tspan1159-0" sodipodi:role="line" textLength="80%" lengthAdjust="spacingAndGlyphs">Diploma Computer Engineering</tspan>
</text>
<text transform="scale(0.90833359,1.1009171)" y="201.96021" x="110.44985" id="text_237820880" style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:50.56167221px;font-family:'Alfa Slab One';-inkscape-font-specification:'Alfa Slab One Bold';text-align:center;writing-mode:lr-tb;text-anchor:middle;fill:#00329f;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.35277781">
<tspan y="201.96021" x="110.44985" style="font-style:normal;font-variant:normal;font-weight:bold;font-stretch:normal;font-size:52.64328003px;font-family:Impact;-inkscape-font-specification:'Impact Bold';text-align:center;text-anchor:middle;fill:#00329f;fill-opacity:1;stroke-width:0.35277781" id="tspan1163-8" sodipodi:role="line" textLength="100%" lengthAdjust="spacingAndGlyphs">Qualification</tspan>
</text>
<path inkscape:connector-curvature="0" id="path_1412011072" d="m 0.83004735,230.11114 a 0.81305725,2.1359739 0 1 0 0,4.27041 H 199.26021 a 0.81305725,2.1359739 0 1 0 0,-4.27041 z" style="color:#000000;font-style:normal;font-variant:normal;font-weight:normal;font-stretch:normal;font-size:medium;line-height:normal;font-family:sans-serif;font-variant-ligatures:normal;font-variant-position:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-alternates:normal;font-feature-settings:normal;text-indent:0;text-align:start;text-decoration:none;text-decoration-line:none;text-decoration-style:solid;text-decoration-color:#000000;letter-spacing:normal;word-spacing:normal;text-transform:none;writing-mode:lr-tb;direction:ltr;text-orientation:mixed;dominant-baseline:auto;baseline-shift:baseline;text-anchor:start;white-space:normal;shape-padding:0;clip-rule:nonzero;display:inline;overflow:visible;visibility:visible;opacity:1;isolation:auto;mix-blend-mode:normal;color-interpolation:sRGB;color-interpolation-filters:linearRGB;solid-color:#000000;solid-opacity:1;vector-effect:none;fill:#00329f;fill-opacity:1;fill-rule:nonzero;stroke:none;stroke-width:0.54116118;stroke-linecap:round;stroke-linejoin:round;stroke-miterlimit:10;stroke-dasharray:none;stroke-dashoffset:0;stroke-opacity:1;color-rendering:auto;image-rendering:auto;shape-rendering:auto;text-rendering:auto;enable-background:accumulate" />
<image width="85" height="85" preserveAspectRatio="none" style="stroke-width:0.66612744;image-rendering:optimizeSpeed" xlink:href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAANYAAADWCAYAAACt43wuAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz AAAOxAAADsQBlSsOGwAAABl0RVh0U29mdHdhcmUAd3d3Lmlua3NjYXBlLm9yZ5vuPBoAAAN/SURB VHic7d1BahZBFIXR1xU35B5cpxtxUaIENQT/duAGMngfgXDOWFrBFP3q3qrONZ+/fpnr+jbAmjNP 1/Xe/wj4aM7cFhZ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8f9/yZc/9eedbMzON+08/HP4wDkH5G/41GAAAAAElFTkSuQmCC " id="image_1002897798" x="57.545128" y="84.95945" />
</g>
</g>
</svg>
更新 我们正在使用 Inkscape 版本 - 0.92.4(最新版本)ImageMagick 版本 - 7.14.5(ImageMagick 为 .Net 平台提供的“Magick.NET-Q16-AnyCPU.dll”的最新版本)。
另请注意,我们正在手动添加此属性。