Improve spec conformance of text.

Clear dx if x or dy if y is set in a GlyphContext.
Make glyph preTranslate by dy instead of postTranslate.
Scale glyph delta correctly.
This commit is contained in:
Mikael Sand
2017-06-19 18:47:38 +03:00
parent 1e8ce2be58
commit fe1b9b2ea8
2 changed files with 10 additions and 5 deletions
@@ -56,23 +56,27 @@ public class GlyphContext {
public void pushContext(@Nullable ReadableMap font, @Nullable ReadableArray deltaX, @Nullable ReadableArray deltaY, @Nullable String positionX, @Nullable String positionY) {
PointF location = mCurrentLocation;
mDeltaContext.add(mCurrentDelta);
if (positionX != null) {
location.x = PropHelper.fromPercentageToFloat(positionX, mWidth, 0, mScale);
mCurrentDelta.x = 0;
}
if (positionY != null) {
location.y = PropHelper.fromPercentageToFloat(positionY, mHeight, 0, mScale);
mCurrentDelta.y = 0;
}
mCurrentDelta = clonePointF(mCurrentDelta);
mLocationContext.add(location);
mDeltaContext.add(mCurrentDelta);
mFontContext.add(font);
mDeltaXContext.add(getFloatArrayListFromReadableArray(deltaX));
mDeltaYContext.add(getFloatArrayListFromReadableArray(deltaY));
mXContext.add(location.x);
mYContext.add(location.y);
mCurrentDelta = clonePointF(mCurrentDelta);
mCurrentLocation = clonePointF(location);
mContextLength++;
}
@@ -110,8 +114,8 @@ public class GlyphContext {
}
public PointF getNextGlyphDelta() {
float dx = getNextDelta(mDeltaXContext);
float dy = getNextDelta(mDeltaYContext);
float dx = mScale * getNextDelta(mDeltaXContext);
float dy = mScale * getNextDelta(mDeltaYContext);
if (mContextLength > 0) {
for (PointF point: mDeltaContext) {
@@ -114,7 +114,8 @@ public class TSpanShadowNode extends TextShadowNode {
continue;
}
matrix.postTranslate(0, glyphPoint.y + glyphDelta.y);
matrix.preTranslate(0, glyphDelta.y);
matrix.postTranslate(0, glyphPoint.y);
} else {
matrix.setTranslate(glyphPoint.x + glyphDelta.x, glyphPoint.y + glyphDelta.y);
}