diff --git a/android/src/main/java/com/horcrux/svg/TSpanShadowNode.java b/android/src/main/java/com/horcrux/svg/TSpanShadowNode.java index f9467afa..77ef4cba 100644 --- a/android/src/main/java/com/horcrux/svg/TSpanShadowNode.java +++ b/android/src/main/java/com/horcrux/svg/TSpanShadowNode.java @@ -134,7 +134,7 @@ class TSpanShadowNode extends TextShadowNode { if (distance == 0) { return path; } - offset += getAbsoluteStartOffset(distance, gc.getFontSize(), textPath.getStartOffset()); + offset += getAbsoluteStartOffset(textPath.getStartOffset(), distance, gc.getFontSize()); /* TextPathSpacing spacing = textPath.getSpacing(); if (spacing == TextPathSpacing.auto) { @@ -440,8 +440,8 @@ class TSpanShadowNode extends TextShadowNode { return 1; } - private double getAbsoluteStartOffset(double distance, double size, String startOffset) { - return PropHelper.fromRelative(startOffset, distance, 0, mScale, size); + private double getAbsoluteStartOffset(String startOffset, double distance, double fontSize) { + return PropHelper.fromRelative(startOffset, distance, 0, mScale, fontSize); } private double getTextAnchorOffset(TextAnchor textAnchor, double textMeasure) { diff --git a/lib/extract/extractStroke.js b/lib/extract/extractStroke.js index ccc93b71..05da84fe 100644 --- a/lib/extract/extractStroke.js +++ b/lib/extract/extractStroke.js @@ -29,13 +29,18 @@ export default function(props, styleProperties) { const strokeWidth = props.strokeWidth; let strokeDasharray = props.strokeDasharray; - if (typeof strokeDasharray === 'string') { + if (!strokeDasharray || strokeDasharray === 'none') { + strokeDasharray = null; + } else if (typeof strokeDasharray === 'string') { strokeDasharray = strokeDasharray.split(separator).map(dash => +dash); } - // strokeDasharray length must be more than 1. - if (strokeDasharray && strokeDasharray.length === 1) { - strokeDasharray.push(strokeDasharray[0]); + // It's a list of comma and/or white space separated s + // and s that specify the lengths of alternating dashes and gaps. + // If an odd number of values is provided, then the list of values is repeated + // to yield an even number of values. Thus, 5,3,2 is equivalent to 5,3,2,5,3,2. + if (strokeDasharray && (strokeDasharray.length % 2) === 1) { + strokeDasharray.concat(strokeDasharray); } return { @@ -43,7 +48,7 @@ export default function(props, styleProperties) { strokeOpacity: extractOpacity(props.strokeOpacity), strokeLinecap: caps[props.strokeLinecap] || 0, strokeLinejoin: joins[props.strokeLinejoin] || 0, - strokeDasharray: strokeDasharray || null, + strokeDasharray: strokeDasharray, strokeWidth: strokeWidth || '1', strokeDashoffset: strokeDasharray ? (+props.strokeDashoffset || 0) : null, strokeMiterlimit: props.strokeMiterlimit || 4