File tree Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Expand file tree Collapse file tree 3 files changed +20
-2
lines changed Original file line number Diff line number Diff line change @@ -1032,18 +1032,22 @@ - (void)setupTextPath:(CGContextRef)context
1032
1032
{
1033
1033
textPath = nil ;
1034
1034
RNSVGText *parent = (RNSVGText*)[self superview ];
1035
+ CGPathRef path;
1035
1036
while (parent) {
1036
1037
if ([parent class ] == [RNSVGTextPath class ]) {
1037
1038
textPath = (RNSVGTextPath*) parent;
1038
1039
RNSVGNode *template = [self .svgView getDefinedTemplate: textPath.href];
1039
- CGPathRef path = [template getPath: nil ];
1040
+ path = [template getPath: context ];
1040
1041
[measure extractPathData: path];
1041
1042
break ;
1042
1043
} else if (![parent isKindOfClass: [RNSVGText class ]]) {
1043
1044
break ;
1044
1045
}
1045
1046
parent = (RNSVGText*)[parent superview ];
1046
1047
}
1048
+ if (!path) {
1049
+ [measure reset ];
1050
+ }
1047
1051
}
1048
1052
1049
1053
@end
Original file line number Diff line number Diff line change 11
11
@interface RNSVGPathMeasure : NSObject
12
12
13
13
@property CGFloat pathLength;
14
- @property CGPathRef textPath ;
14
+ @property CGPathRef path ;
15
15
@property NSMutableArray *lengths;
16
16
@property NSMutableArray *lines;
17
17
@property NSUInteger lineCount;
18
18
@property BOOL isClosed;
19
19
20
+ - (void )reset ;
20
21
- (void )extractPathData : (CGPathRef)path ;
21
22
- (void )getPosAndTan : (CGFloat *)angle midPoint : (CGFloat)midPoint px : (CGFloat *)px py : (CGFloat *)py ;
22
23
Original file line number Diff line number Diff line change @@ -94,7 +94,20 @@ - (void)addLine:(CGPoint *)last next:(const CGPoint *)next {
94
94
*last = *next;
95
95
}
96
96
97
+ - (void )reset {
98
+ _lengths = nil ;
99
+ _lines = nil ;
100
+ _isClosed = NO ;
101
+ _lineCount = 0 ;
102
+ _pathLength = 0 ;
103
+ _path = nil ;
104
+ }
105
+
97
106
- (void )extractPathData : (CGPathRef)path {
107
+ if (path == _path) {
108
+ return ;
109
+ }
110
+ _path = path;
98
111
CGPoint origin = CGPointMake (0.0 , 0.0 );
99
112
CGPoint last = CGPointMake (0.0 , 0.0 );
100
113
_lengths = [NSMutableArray array ];
You can’t perform that action at this time.
0 commit comments