a-student / SvgToVectorDrawableConverter

Batch converter of SVG images to Android vector drawable XML resource files. Online version of the converter is here:
https://svg2vector.com
344 stars 45 forks source link

Missing details in some SVGs #2

Closed olivier65 closed 8 years ago

olivier65 commented 8 years ago

I've been trying to convert the emojis from the Noto font and some conversions are missing some details. For instance this one is missing the two eyes. Another one is emoji_u1f383.svg at the same site: the green stem is missing. I am not sure why; all the paths seem correctly converted.

a-student commented 8 years ago

Are you using the latest version of the converter? What is the Android version you are running your app on? Are you using any libs that may influence handling of vector drawables?

olivier65 commented 8 years ago

Hi,

Are you using the latest version of the converter?

I think so. I downloaded it just a week ago.

What is the Android version you are running your app on?

5.1.1

Are you using any libs that may influence handling of vector drawables?

No, absolutely no libs in this project.

Thanks,

Olivier

a-student commented 8 years ago

Due to the bug in Android 5, which is fixed in 6.0, clip-path-s in vector drawable XMLs are not handled correctly. Workarounds may be:

Thank you for using the converter!

olivier65 commented 8 years ago

I tried moving around the eye paths in 1f600 but could not find a positioning that does not make things worse.

Re. BetterVectorDrawable, is it really a drop-in replacement? I am writing a library (a keyboard, to be precise), so I cannot create a custom Application class.

a-student commented 8 years ago

I'm not sure whether it is possible to use BetterVectorDrawable in a keyboard lib. I didn't test it in such scenario.

<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
    android:viewportWidth="128"
    android:viewportHeight="128"
    android:width="128dp"
    android:height="128dp">
    <path
        android:pathData="M112.73 37.63l-0.02 0C102.64 23.89 83.68 14.56 64 14.56c-19.69 0 -38.64 9.33 -48.71 23.07l0 0c0 0 -14.99 12.21 -14.99 31.25 0 19.51 12.7 28.78 12.7 28.78 0 0 0.02 0.01 0.06 0.01 5.52 9.04 26.21 15.77 50.94 15.77 24.74 0 45.43 -6.73 50.95 -15.77 0.02 0 0.06 -0.01 0.06 -0.01 0 0 12.69 -9.27 12.69 -28.78 0 -19.04 -14.97 -31.25 -14.97 -31.25z"
        android:fillColor="#fcc21b" />
    <path
        android:pathData="M22.94 53.34c0 0 -0.21 27.63 41.8 27.63 42.02 0 41.85 -27.63 41.85 -27.63 0 0 -12.73 3.58 -41.82 3.58 -29.1 0 -41.83 -3.58 -41.83 -3.58"
        android:fillColor="#ffffff" />
    <path
        android:pathData="M41.83 47.52C37.25 46.07 36.64 40.7 38.94 37c1.82 -2.6 4.7 -3.84 7.08 -3.44 2.51 0.46 4.83 2.73 4.79 6 -0.01 4.86 -3.89 9.48 -8.98 7.96z"
        android:fillColor="#2f2f2f" />
    <path
        android:pathData="M87.5 47.52c4.59 -1.45 5.19 -6.82 2.88 -10.52 -1.81 -2.6 -4.7 -3.84 -7.08 -3.44 -2.51 0.46 -4.82 2.73 -4.8 6 0.03 4.86 3.91 9.48 9 7.96z"
        android:fillColor="#2f2f2f" />
    <group>
        <clip-path
            android:pathData="M22.94 53.34c0 0 -0.21 27.63 41.8 27.63 42.02 0 41.85 -27.63 41.85 -27.63 0 0 -12.73 3.58 -41.82 3.58 -29.1 0 -41.83 -3.58 -41.83 -3.58" />
        <path
            android:pathData="M34.7 93.17c-1.07 0 -1.96 -0.89 -1.96 -2l0 -41.17c0 -1.11 0.88 -2.01 1.96 -2.01 1.08 0 1.94 0.9 1.94 2.01l0 41.17c0 1.11 -0.86 2 -1.94 2z"
            android:fillColor="#2f2f2f" />
    </group>
    <group>
        <clip-path
            android:pathData="M22.94 53.34c0 0 -0.21 27.63 41.8 27.63 42.02 0 41.85 -27.63 41.85 -27.63 0 0 -12.73 3.58 -41.82 3.58 -29.1 0 -41.83 -3.58 -41.83 -3.58" />
        <path
            android:pathData="M49.68 93.18c-1.08 0 -1.95 -0.9 -1.95 -2.01l0 -41.17c0 -1.11 0.88 -2.01 1.95 -2.01 1.08 0 1.94 0.9 1.94 2.01l0 41.18c0 1.1 -0.87 2 -1.94 2z"
            android:fillColor="#2f2f2f" />
    </group>
    <group>
        <clip-path
            android:pathData="M22.94 53.34c0 0 -0.21 27.63 41.8 27.63 42.02 0 41.85 -27.63 41.85 -27.63 0 0 -12.73 3.58 -41.82 3.58 -29.1 0 -41.83 -3.58 -41.83 -3.58" />
        <path
            android:pathData="M64.65 93.18c-1.07 0 -1.95 -0.9 -1.95 -2.01L62.7 50c0 -1.11 0.88 -2.01 1.95 -2.01 1.08 0 1.95 0.9 1.95 2.01l0 41.18c0 1.1 -0.87 2 -1.95 2z"
            android:fillColor="#2f2f2f" />
    </group>
    <group>
        <clip-path
            android:pathData="M22.94 53.34c0 0 -0.21 27.63 41.8 27.63 42.02 0 41.85 -27.63 41.85 -27.63 0 0 -12.73 3.58 -41.82 3.58 -29.1 0 -41.83 -3.58 -41.83 -3.58" />
        <path
            android:pathData="M79.62 93.18c-1.08 0 -1.94 -0.9 -1.94 -2.01l0 -41.17c0 -1.11 0.86 -2.01 1.94 -2.01 1.08 0 1.95 0.9 1.95 2.01l0 41.18c0 1.1 -0.87 2 -1.95 2z"
            android:fillColor="#2f2f2f" />
    </group>
    <group>
        <clip-path
            android:pathData="M22.94 53.34c0 0 -0.21 27.63 41.8 27.63 42.02 0 41.85 -27.63 41.85 -27.63 0 0 -12.73 3.58 -41.82 3.58 -29.1 0 -41.83 -3.58 -41.83 -3.58" />
        <path
            android:pathData="M94.59 93.18c-1.08 0 -1.95 -0.9 -1.95 -2.01l0 -41.17c0 -1.11 0.87 -2.01 1.95 -2.01 1.08 0 1.94 0.9 1.94 2.01l0 41.18c0 1.1 -0.87 2 -1.94 2z"
            android:fillColor="#2f2f2f" />
    </group>
    <path
        android:pathData="M64.74 83.14c-16.06 0 -28.09 -3.92 -35.76 -11.65 -8.19 -8.25 -8.21 -17.76 -8.2 -18.17 0 -0.67 0.33 -1.31 0.86 -1.71 0.54 -0.4 1.25 -0.53 1.89 -0.36 0.13 0.03 12.88 3.5 41.25 3.5 28.35 0 41.11 -3.46 41.23 -3.5 0.64 -0.18 1.35 -0.05 1.89 0.36 0.54 0.41 0.85 1.04 0.86 1.72 0 0.4 -0.03 9.91 -8.23 18.16C92.85 79.22 80.8 83.14 64.74 83.14ZM25.42 56.12c1.25 6.62 7.55 22.68 39.32 22.68 31.78 0 38.11 -16.05 39.37 -22.68 -5.37 1.06 -17.95 2.96 -39.34 2.96 -21.4 0 -33.98 -1.89 -39.35 -2.96z"
        android:fillColor="#2f2f2f" />
</vector>
olivier65 commented 8 years ago

Do you have a reference for the Android bug? I would like to include it in my documentation.

olivier65 commented 8 years ago

Based on your advice I wrote a small utility that puts non-clip paths back in the same order as in the SVG file and at the top of the Android file. That did the trick, so many thanks for that. Isn't it arguably a bug, though, that svg2d reorders elements?

a-student commented 8 years ago

Do you have a reference for the Android bug?

No :(

Isn't it arguably a bug, though, that svg2d reorders elements?

The converter does not reorder elements, otherwise it would radically change an image.

That did the trick, so many thanks for that.

Not at all! But note that it can not be a general solution.

olivier65 commented 8 years ago

You are right. The file with the reordered paths was the one I had been working on manually before writing the tool; I mistakenly put it in the original directory, hence the confusion.