diff --git a/ios/Text/RNSVGSpan.m b/ios/Text/RNSVGSpan.m index 2581741c..383b44c9 100644 --- a/ios/Text/RNSVGSpan.m +++ b/ios/Text/RNSVGSpan.m @@ -17,6 +17,7 @@ { [self setBoundingBox:CGContextGetClipBoundingBox(context)]; CGMutablePathRef path = CGPathCreateMutable(); + RNSVGText *text = [self getText]; if (![self.content isEqualToString:@""]) { // Create a dictionary for this font @@ -37,7 +38,6 @@ CGFloat px = self.px ? [self getWidthRelatedValue:self.px] : 0; CGFloat py = self.py ? [self getHeightRelatedValue:self.py] : 0; - RNSVGText *text = [self getText]; if (self.px) { text.offsetX = px; } @@ -55,6 +55,9 @@ CGPathAddPath(path, &offset, linePath); CGPathRelease(linePath); + } else { + text.offsetX += self.dx; + text.offsetY += self.dy; } return (CGPathRef)CFAutorelease(path); diff --git a/ios/Text/RNSVGText.m b/ios/Text/RNSVGText.m index bc1d24c3..8c3e12d9 100644 --- a/ios/Text/RNSVGText.m +++ b/ios/Text/RNSVGText.m @@ -41,20 +41,30 @@ { CGMutablePathRef path = CGPathCreateMutable(); - CGPathRef collection = [super getPath:context]; - CGFloat shift = [self getShift:context path:collection]; + CGPathRef collection = [self getPathFromSuper:context]; + // get alignment shift and Translate CGPath by it. + CGFloat shift = [self getShift:context path:collection]; CGAffineTransform align = CGAffineTransformMakeTranslation(shift, 0); CGPathAddPath(path, &align, collection); CGPathRelease(collection); + return (CGPathRef)CFAutorelease(path); } +- (CGPathRef)getPathFromSuper:(CGContextRef)context +{ + CGPathRef path = [super getPath:context]; + // reset offsetX and offsetY + self.offsetX = self.offsetY = 0; + return path; +} + - (CGFloat)getShift:(CGContextRef)context path:(CGPathRef)path { if (!path) { - path = [super getPath:context]; + path = [self getPathFromSuper:context]; } CGFloat width = CGPathGetBoundingBox(path).size.width;