Fix non-ascii characters, add check for them
This commit is contained in:
parent
2f6b43796b
commit
512a11740e
2 changed files with 47 additions and 76 deletions
|
@ -1,78 +1,44 @@
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||||
<!-- Generator: Adobe Illustrator 22.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
|
||||||
|
|
||||||
<svg
|
<svg
|
||||||
version="1.1"
|
version="1.1"
|
||||||
id="图层_1"
|
id="elevator"
|
||||||
x="0px"
|
x="0px"
|
||||||
y="0px"
|
y="0px"
|
||||||
viewBox="0 0 65.9 66"
|
viewBox="0 0 65.9 66"
|
||||||
style="enable-background:new 0 0 65.9 66;"
|
style="enable-background:new 0 0 65.9 66;"
|
||||||
xml:space="preserve"
|
xml:space="preserve"
|
||||||
sodipodi:docname="elevator.svg"
|
xmlns="http://www.w3.org/2000/svg">
|
||||||
inkscape:version="1.1.2 (0a00cf5339, 2022-02-04)"
|
|
||||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
|
||||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
|
||||||
xmlns="http://www.w3.org/2000/svg"
|
|
||||||
xmlns:svg="http://www.w3.org/2000/svg"><defs
|
|
||||||
id="defs33">
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</defs><sodipodi:namedview
|
|
||||||
id="namedview31"
|
|
||||||
pagecolor="#ffffff"
|
|
||||||
bordercolor="#111111"
|
|
||||||
borderopacity="1"
|
|
||||||
inkscape:pageshadow="0"
|
|
||||||
inkscape:pageopacity="0"
|
|
||||||
inkscape:pagecheckerboard="1"
|
|
||||||
showgrid="false"
|
|
||||||
inkscape:zoom="61.063924"
|
|
||||||
inkscape:cx="32.105699"
|
|
||||||
inkscape:cy="40.138265"
|
|
||||||
inkscape:window-width="1920"
|
|
||||||
inkscape:window-height="1007"
|
|
||||||
inkscape:window-x="0"
|
|
||||||
inkscape:window-y="0"
|
|
||||||
inkscape:window-maximized="1"
|
|
||||||
inkscape:current-layer="图层_1" />
|
|
||||||
<path
|
<path
|
||||||
d="M 48.2,15.6 H 19.3 c -1.6,0 -2.8,1.3 -2.8,2.8 v 29 c 0,1.6 1.3,2.8 2.8,2.8 h 28.9 c 1.6,0 2.8,-1.3 2.8,-2.8 V 18.5 C 51,17 49.7,15.6 48.2,15.6 Z m 0.3,30.7 c 0,0.8 -0.6,1.4 -1.4,1.4 H 20.4 C 19.6,47.7 19,47.1 19,46.3 V 19.6 c 0,-0.8 0.6,-1.4 1.4,-1.4 h 26.7 c 0.8,0 1.4,0.6 1.4,1.4 z"
|
d="M 48.2,15.6 H 19.3 c -1.6,0 -2.8,1.3 -2.8,2.8 v 29 c 0,1.6 1.3,2.8 2.8,2.8 h 28.9 c 1.6,0 2.8,-1.3 2.8,-2.8 V 18.5 C 51,17 49.7,15.6 48.2,15.6 Z m 0.3,30.7 c 0,0.8 -0.6,1.4 -1.4,1.4 H 20.4 C 19.6,47.7 19,47.1 19,46.3 V 19.6 c 0,-0.8 0.6,-1.4 1.4,-1.4 h 26.7 c 0.8,0 1.4,0.6 1.4,1.4 z"
|
||||||
id="path2" /><polygon
|
id="path2"/>
|
||||||
|
<polygon
|
||||||
points="29.4,9.5 33.7,5.5 38.1,9.5 35.3,9.5 35.3,13.5 32.2,13.5 32.2,9.5 "
|
points="29.4,9.5 33.7,5.5 38.1,9.5 35.3,9.5 35.3,13.5 32.2,13.5 32.2,9.5 "
|
||||||
id="polygon8" /><polygon
|
id="polygon8"/>
|
||||||
|
<polygon
|
||||||
points="38.1,56.6 33.7,60.5 29.4,56.6 32.2,56.6 32.2,52.5 35.3,52.5 35.3,56.6 "
|
points="38.1,56.6 33.7,60.5 29.4,56.6 32.2,56.6 32.2,52.5 35.3,52.5 35.3,56.6 "
|
||||||
id="polygon10" /><circle
|
id="polygon10"/>
|
||||||
|
<circle
|
||||||
cx="28.6"
|
cx="28.6"
|
||||||
cy="21.4"
|
cy="21.4"
|
||||||
r="1.9"
|
r="1.9"
|
||||||
id="circle12" /><path
|
id="circle12"/>
|
||||||
|
<path
|
||||||
d="m 29.1,35.6 c 0,-0.2 -0.2,-0.5 -0.5,-0.5 -0.3,0 -0.5,0.2 -0.5,0.5 v 1.7 3 5 c 0,0.6 -0.6,1.2 -1.2,1.2 -0.6,0 -1.2,-0.5 -1.2,-1.2 V 40.5 37.3 33.2 32 28.2 28.3 c 0,-0.2 -0.1,-0.4 -0.4,-0.4 -0.2,0 -0.4,0.2 -0.4,0.4 v 1.3 3.5 1.8 c 0,0.4 -0.3,0.7 -0.7,0.7 -0.4,0 -0.7,-0.3 -0.7,-0.7 v -1 -3.5 -4.2 c 0,-1 0.8,-1.9 1.9,-1.9 h 5.2 0.3 c 0.2,0 0.5,0.1 0.6,0.3 l 2.1,2.1 2.5,-2.5 c 0.4,-0.4 1,-0.4 1.3,0 0.4,0.4 0.4,1 0,1.3 l -3.2,3.2 C 34,28.9 33.8,29 33.5,29 33.3,29 33,28.9 32.8,28.7 L 32,27.9 31.8,27.8 h -0.2 c -0.2,0 -0.4,0.2 -0.4,0.4 v 1.6 10.6 l 7.68e-4,4.906766 c 9.4e-5,0.6 -0.6,1.2 -1.2,1.2 -0.6,0 -0.957071,-0.484801 -0.957071,-1.184801 0,0 0.0563,-6.496244 0.0563,-9.721965 z"
|
d="m 29.1,35.6 c 0,-0.2 -0.2,-0.5 -0.5,-0.5 -0.3,0 -0.5,0.2 -0.5,0.5 v 1.7 3 5 c 0,0.6 -0.6,1.2 -1.2,1.2 -0.6,0 -1.2,-0.5 -1.2,-1.2 V 40.5 37.3 33.2 32 28.2 28.3 c 0,-0.2 -0.1,-0.4 -0.4,-0.4 -0.2,0 -0.4,0.2 -0.4,0.4 v 1.3 3.5 1.8 c 0,0.4 -0.3,0.7 -0.7,0.7 -0.4,0 -0.7,-0.3 -0.7,-0.7 v -1 -3.5 -4.2 c 0,-1 0.8,-1.9 1.9,-1.9 h 5.2 0.3 c 0.2,0 0.5,0.1 0.6,0.3 l 2.1,2.1 2.5,-2.5 c 0.4,-0.4 1,-0.4 1.3,0 0.4,0.4 0.4,1 0,1.3 l -3.2,3.2 C 34,28.9 33.8,29 33.5,29 33.3,29 33,28.9 32.8,28.7 L 32,27.9 31.8,27.8 h -0.2 c -0.2,0 -0.4,0.2 -0.4,0.4 v 1.6 10.6 l 7.68e-4,4.906766 c 9.4e-5,0.6 -0.6,1.2 -1.2,1.2 -0.6,0 -0.957071,-0.484801 -0.957071,-1.184801 0,0 0.0563,-6.496244 0.0563,-9.721965 z"
|
||||||
id="path14"
|
id="path14"
|
||||||
sodipodi:nodetypes="cssccsssccccccssccsssccsscsccsccsssccssccsscc" /><circle
|
/>
|
||||||
|
<circle
|
||||||
cx="42.400002"
|
cx="42.400002"
|
||||||
cy="21"
|
cy="21"
|
||||||
r="1.5"
|
r="1.5"
|
||||||
id="circle16" /><circle
|
id="circle16"/>
|
||||||
|
<circle
|
||||||
cx="42.400002"
|
cx="42.400002"
|
||||||
cy="24.5"
|
cy="24.5"
|
||||||
r="1.5"
|
r="1.5"
|
||||||
id="circle18" /><circle
|
id="circle18"/>
|
||||||
|
<circle
|
||||||
cx="42.400002"
|
cx="42.400002"
|
||||||
cy="28.200001"
|
cy="28.200001"
|
||||||
r="1.5"
|
r="1.5"
|
||||||
id="circle20"/>
|
id="circle20"/>
|
||||||
|
|
||||||
</svg>
|
</svg>
|
||||||
|
|
Before Width: | Height: | Size: 2.7 KiB After Width: | Height: | Size: 2 KiB |
|
@ -17,13 +17,18 @@ function genImages(dryrun = false) {
|
||||||
throw "Non-svg file detected in the svg files: " + path;
|
throw "Non-svg file detected in the svg files: " + path;
|
||||||
}
|
}
|
||||||
|
|
||||||
let svg = fs.readFileSync("./assets/svg/" + path, "utf-8")
|
let svg : string = fs.readFileSync("./assets/svg/" + path, "utf-8")
|
||||||
.replace(/<\?xml.*?>/, "")
|
.replace(/<\?xml.*?>/, "")
|
||||||
.replace(/fill: ?none;/g, "fill: none !important;") // This is such a brittle hack...
|
.replace(/fill: ?none;/g, "fill: none !important;") // This is such a brittle hack...
|
||||||
.replace(/\n/g, " ")
|
.replace(/\n/g, " ")
|
||||||
.replace(/\r/g, "")
|
.replace(/\r/g, "")
|
||||||
.replace(/\\/g, "\\")
|
.replace(/\\/g, "\\")
|
||||||
.replace(/"/g, "\\\"")
|
.replace(/"/g, "\\\"")
|
||||||
|
|
||||||
|
let hasNonAsciiChars = Array.from(svg).some(char => char.charCodeAt(0) > 127);
|
||||||
|
if(hasNonAsciiChars){
|
||||||
|
throw "The svg '"+path+"' has non-ascii characters";
|
||||||
|
}
|
||||||
const name = path.substr(0, path.length - 4)
|
const name = path.substr(0, path.length - 4)
|
||||||
.replace(/[ -]/g, "_");
|
.replace(/[ -]/g, "_");
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue