Fix font PropTypes

This commit is contained in:
Mikael Sand
2017-07-23 22:55:39 +03:00
parent fc61c9dad2
commit 80b9ff9d57
6 changed files with 103 additions and 31 deletions
@@ -122,10 +122,11 @@ class TSpanShadowNode extends TextShadowNode {
ReadableMap font = gc.getFont();
applyTextPropertiesToPaint(paint, font);
double offset = 0;
double distance = 0;
double renderMethodScaling = 1;
final double textMeasure = paint.measureText(line);
double offset = font.hasKey(TEXT_ANCHOR) ?
getTextAnchorShift(textMeasure, font.getString(TEXT_ANCHOR)) : 0;
PathMeasure pm = null;
if (textPath != null) {
@@ -133,7 +134,7 @@ class TSpanShadowNode extends TextShadowNode {
distance = pm.getLength();
final double size = gc.getFontSize();
final String startOffset = textPath.getStartOffset();
offset = PropHelper.fromRelative(startOffset, distance, 0, mScale, size);
offset += PropHelper.fromRelative(startOffset, distance, 0, mScale, size);
// String spacing = textPath.getSpacing(); // spacing = "auto | exact"
final String method = textPath.getMethod(); // method = "align | stretch"
if (STRETCH.equals(method)) {
@@ -141,10 +142,6 @@ class TSpanShadowNode extends TextShadowNode {
}
}
if (font.hasKey(TEXT_ANCHOR)) {
offset += getTextAnchorShift(textMeasure, font.getString(TEXT_ANCHOR));
}
double x;
double y;
double r;
@@ -231,6 +228,11 @@ class TSpanShadowNode extends TextShadowNode {
assert pm != null;
pm.getMatrix((float) midpoint, matrix, POSITION_MATRIX_FLAG | TANGENT_MATRIX_FLAG);
// TODO In the calculation above, if either the startpoint-on-the-path
// or the endpoint-on-the-path is off the end of the path,
// then extend the path beyond its end points with a straight line
// that is parallel to the tangent at the path at its end point
// so that the midpoint-on-the-path can still be calculated.
matrix.preTranslate((float) -halfGlyphWidth, (float) dy);
matrix.preScale((float) renderMethodScaling, (float) renderMethodScaling);