question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Nested circle paths break on Android

See original GitHub issue

I ran into this issue when trying to put social icons inside some circles, but found out the issue was generated when there was a path that had a circle cut out of another circle (cutting a rectangle out didn’t seem to reproduce it).

Here is some simple svg that causes the issue (created with Sketch. I’ve used svgo to get rid of extraneous stuff but the issue occurs with or without the optimisation)

<svg width="50" height="50" viewBox="0 0 50 50" xmlns="http://www.w3.org/2000/svg">
    <title>facebook-logo</title>
    <desc>Created with Sketch.</desc>
    <g fill="none" fill-rule="evenodd">
        <g fill="#D8D8D8">
            <path d="M25 50c13.807 0 25-11.193 25-25S38.807 0 25 0 0 11.193 0 25s11.193 25 25 25zm0-6c10.493 0 19-8.507 19-19S35.493 6 25 6 6 14.507 6 25s8.507 19 19 19z"/>
        </g>
    </g>
</svg>

Expected output (Chrome in OSX): image

Damaged output (Chrome in Android 5.0) image

The really interesting thing is that this happens in every browser on Android. I tried Firefox and the default AOSP browser (in the emulator) and I got a similar result. I think this is a collision of an Android bug and an interesting handling of ttf files from Fontello.

I originally discovered this using gulp-fonticon, but I’m assuming that the error is happening here because the TTF and WOFF files are affected, and the same issue happens when using the Fontello website.

I’m just charging up an Android 4 device in the house to see if the same thing happens.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
Pinpicklecommented, Mar 19, 2015

This did occur on Android 4 as well. Interestingly enough, the culprit SVG files rendered incorrectly in Illustrator as well - even though it was a compound path with one circle inside another.

Turns out its the path direction thats causing all of these issues. Sketch exports with the “evenodd” fill rule for path cutouts but it would seem that no matter what, the Android font renderer and Illustrator will interpret that as “nonzero”. In evenodd, path direction doesn’t matter but in nonzero it does - the paths need to be in alternating direction for the cutouts to be successful. I have no idea how these fill rules translate to the ttf spec.

In any case, reversing the path direction in Sketch manually fixes the issue. I would call this a bug with Illustrator/Android (and likely many other programs), but its a bug that Sketch should account for so I’ve filed a bug report.

I’m not sure what this library could do, maybe it can make sure paths are in alternating directions or just leave it to us? I feel like if the library took matters into its own hands, it would just cause more problems.

0reactions
mediafreakchcommented, Apr 16, 2015

@Pinpickle Do you have a Sketch issue# to follow up?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Draw circular sector using Path - android - Stack Overflow
So on each photo I would like to put a circular sector (cut arc) with black area. How can I achieve that with...
Read more >
Path | Android Developers
Summary: Nested Classes | Ctors | Methods | Inherited Methods ... x, float : The x-coordinate of the center of a circle to...
Read more >
SVG Circle Decomposition To Paths - Smashing Magazine
This article will show you how to turn SVG circles into paths which you can use in animation and text paths, as well...
Read more >
Using Android Images with the Machine Executor - CircleCI
The Android machine image supports nested virtualization and x86 Android emulators, so it can be used for Android UI testing. It also comes...
Read more >
Compound paths and shapes in InDesign - Adobe Support
Choose Object > Paths > Reverse Path. Click Reverse Path in the Pathfinder panel. Break up a compound ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found