Skip to content

Commit

Permalink
Added support for fillType evenOdd (API 24+) inloop#44
Browse files Browse the repository at this point in the history
  • Loading branch information
yuraj11 committed Sep 15, 2016
1 parent 4f52442 commit eca2506
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ <h4 class="modal-title">Multiple SVG files (<span id="files-count"></span> files
<script src="js/svg_shape_converter.js"></script>
<script src="js/flatten.js?v=1"></script>
<script src="js/jszip.min.js"></script>
<script src="js/main.js?v=29"></script>
<script src="js/main.js?v=30"></script>

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
Expand Down
10 changes: 9 additions & 1 deletion js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ function checkAttribute(key, val) {
if ((key == "fill" || key == "stroke") && val.startsWith("url")) {
pushUnique(warnings, "found fill(s) or stroke(s) which uses <i>url()</i> (gradients and patterns are not supported in Android)");
} else if ((key == "fill-rule") && val == "evenodd") {
pushUnique(warnings, "found attribute 'fill-rule:evenodd' which is not supported in Android - sometimes can cause that svg will be not rendered correctly (<a target='_blank' href='https://github.com/inloop/svg2android/issues/44'>more info</a>)");
pushUnique(warnings, "found attribute 'fill-rule:evenodd' which is supported only on Android API 24 and higher - (<a target='_blank' href='https://github.com/inloop/svg2android/issues/44'>more info</a>)");
}
}

Expand Down Expand Up @@ -497,6 +497,13 @@ function printPath(pathData, stylesArray, groupLevel, clipPath) {
styles["fill"] = "#000000";
}

//Handle fill-rule
if (typeof styles["fill-rule"] !== "undefined" && styles["fill-rule"].toLowerCase() == "evenodd") {
styles["fill-rule"] = "evenOdd";
} else {
styles["fill-rule"] = "nonZero";
}

//If strokeWidth is needed but omitted, default to 1
var needsStrokeWidth = (typeof styles["stroke"] !== "undefined") ||
(typeof styles["stroke-opacity"] !== "undefined") ||
Expand All @@ -514,6 +521,7 @@ function printPath(pathData, stylesArray, groupLevel, clipPath) {
if (toBool(localStorage.useIdAsName)) generatedOutput += generateAttr('name', styles["id"], groupLevel, "");
generatedOutput += generateAttr('fillColor', parseColorToHex(styles["fill"]), groupLevel, "none");
generatedOutput += generateAttr('fillAlpha', styles["fill-opacity"], groupLevel, "1");
generatedOutput += generateAttr('fillType', styles["fill-rule"], groupLevel, "nonZero");
generatedOutput += generateAttr('strokeColor', parseColorToHex(styles["stroke"]), groupLevel, "none");
generatedOutput += generateAttr('strokeAlpha', styles["stroke-opacity"], groupLevel, "1");
generatedOutput += generateAttr('strokeWidth', removeNonNumeric(styles["stroke-width"]), groupLevel, "0");
Expand Down

0 comments on commit eca2506

Please sign in to comment.