fix crash when the text letter reaches the end of text-path

This commit is contained in:
Horcrux
2016-08-26 10:15:59 +08:00
parent 42b0c75378
commit 001835b7c1
3 changed files with 15 additions and 9 deletions
+5 -1
View File
@@ -106,7 +106,11 @@ static CGFloat Distance(CGPoint a, CGPoint b) {
- (CGAffineTransform)transformAtDistance:(CGFloat)distance
{
if (_offset == 0) {
[self setControlPoints];
if (_bezierCurves.count == _bezierIndex) {
return CGAffineTransformMakeScale(0, 0);
} else {
[self setControlPoints];
}
}
CGFloat offset = [self offsetAtDistance:distance - _lastX
+6
View File
@@ -112,6 +112,12 @@ static void RNSVGFreeTextFrame(RNSVGTextFrame frame)
// draw glyphs along path
if (self.path) {
transform = [bezierPath transformAtDistance:point.x];
// break loop if line reaches the end of the Path.
if (!transform.a || !transform.d) {
CGPathRelease(letter);
break;
}
transform = CGAffineTransformScale(transform, 1.0, -1.0);
} else {
transform = CGAffineTransformTranslate(upsideDown, point.x, point.y);