mirror of
https://github.com/zoriya/react-native-svg.git
synced 2025-12-21 14:25:14 +00:00
fix crash when the text letter reaches the end of text-path
This commit is contained in:
@@ -122,14 +122,10 @@ class TextPath extends Component{
|
|||||||
|
|
||||||
render() {
|
render() {
|
||||||
const path = `
|
const path = `
|
||||||
M 0 20
|
M 10 20
|
||||||
h 10
|
C 20 10 30 0 40 10
|
||||||
C 20 10 30 0 40 10
|
C 50 20 60 30 70 20
|
||||||
C 50 20 60 30 70 20
|
C 80 10 90 10 90 10
|
||||||
C 80 10 90 10 90 10
|
|
||||||
C 110 20 120 30 120 20
|
|
||||||
C 140 10 150 10 150 10
|
|
||||||
a 50 50 0 1 1 20 110
|
|
||||||
`;
|
`;
|
||||||
|
|
||||||
return <Svg
|
return <Svg
|
||||||
|
|||||||
@@ -106,7 +106,11 @@ static CGFloat Distance(CGPoint a, CGPoint b) {
|
|||||||
- (CGAffineTransform)transformAtDistance:(CGFloat)distance
|
- (CGAffineTransform)transformAtDistance:(CGFloat)distance
|
||||||
{
|
{
|
||||||
if (_offset == 0) {
|
if (_offset == 0) {
|
||||||
[self setControlPoints];
|
if (_bezierCurves.count == _bezierIndex) {
|
||||||
|
return CGAffineTransformMakeScale(0, 0);
|
||||||
|
} else {
|
||||||
|
[self setControlPoints];
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CGFloat offset = [self offsetAtDistance:distance - _lastX
|
CGFloat offset = [self offsetAtDistance:distance - _lastX
|
||||||
|
|||||||
@@ -112,6 +112,12 @@ static void RNSVGFreeTextFrame(RNSVGTextFrame frame)
|
|||||||
// draw glyphs along path
|
// draw glyphs along path
|
||||||
if (self.path) {
|
if (self.path) {
|
||||||
transform = [bezierPath transformAtDistance:point.x];
|
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);
|
transform = CGAffineTransformScale(transform, 1.0, -1.0);
|
||||||
} else {
|
} else {
|
||||||
transform = CGAffineTransformTranslate(upsideDown, point.x, point.y);
|
transform = CGAffineTransformTranslate(upsideDown, point.x, point.y);
|
||||||
|
|||||||
Reference in New Issue
Block a user