mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-05 07:59:28 +00:00
Refactor: simplify glyph translate calculation
This commit is contained in:
@@ -186,11 +186,12 @@ class TSpanShadowNode extends TextShadowNode {
|
|||||||
dy = gc.nextDeltaY();
|
dy = gc.nextDeltaY();
|
||||||
matrix = new Matrix();
|
matrix = new Matrix();
|
||||||
|
|
||||||
float start = offset + x + dx - width;
|
float xSum = offset + x + dx - width;
|
||||||
|
float ySum = y + dy;
|
||||||
|
|
||||||
if (textPath != null) {
|
if (textPath != null) {
|
||||||
float halfway = width / 2;
|
float halfway = width / 2;
|
||||||
float midpoint = start + halfway;
|
float midpoint = xSum + halfway;
|
||||||
|
|
||||||
if (midpoint > distance) {
|
if (midpoint > distance) {
|
||||||
break;
|
break;
|
||||||
@@ -201,11 +202,11 @@ class TSpanShadowNode extends TextShadowNode {
|
|||||||
assert pm != null;
|
assert pm != null;
|
||||||
pm.getMatrix(midpoint, matrix, POSITION_MATRIX_FLAG | TANGENT_MATRIX_FLAG);
|
pm.getMatrix(midpoint, matrix, POSITION_MATRIX_FLAG | TANGENT_MATRIX_FLAG);
|
||||||
|
|
||||||
matrix.preTranslate(-halfway, dy);
|
matrix.preTranslate(-halfway, 0);
|
||||||
matrix.preScale(renderMethodScaling, 1);
|
matrix.preScale(renderMethodScaling, renderMethodScaling);
|
||||||
matrix.postTranslate(0, y);
|
matrix.postTranslate(0, ySum);
|
||||||
} else {
|
} else {
|
||||||
matrix.setTranslate(start, y + dy);
|
matrix.setTranslate(xSum, ySum);
|
||||||
}
|
}
|
||||||
|
|
||||||
matrix.preRotate(r);
|
matrix.preRotate(r);
|
||||||
|
|||||||
Reference in New Issue
Block a user