misakuo / svgtoandroid

Converting SVG to VectorDrawable
https://plugins.jetbrains.com/plugin/8103
MIT License
528 stars 45 forks source link

Corrupt drawable XML is generated in locale with comma as decimal separator #26

Closed rillig closed 7 years ago

rillig commented 7 years ago

When I convert the following SVG, the generated XML is corrupt:

Input:

<svg xmlns="http://www.w3.org/2000/svg" width="48" height="48" viewBox="0 0 48 48" version="1.1">
    <rect width="48" height="48" x="0" y="0" rx="5" ry="5"
          style="fill:#d48e00;fill-opacity:1;stroke-width:0" />
</svg>

Output:

<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
        android:viewportWidth="48"
        android:viewportHeight="48"
        android:width="48dp"
        android:height="48dp">
    <path android:fillColor="#D48E00" android:name="background" android:strokeWidth="0"
          android:fillAlpha="1"
          android:pathData="M5,00,0,00,L43,00,0,00,Q48,00,0,00,48,00,5,00,L48,00,43,00,Q48,00,48,00,43,00,48,00,L5,00,48,00,Q0,00,48,00,0,00,43,00,L0,00,5,00,Q0,00,0,00,5,00,0,00z"/>
</vector>

When generating the path data, the decimal separator must be a point, not a comma. When a point is used instead of a comma, the converted drawable displays correctly.

Furthermore, it would be nice if the coordinates would stay exactly as they are in the original SVG, having the same number of decimal places, or none at all in the above case.