mirror of
https://github.com/zoriya/react-native-svg.git
synced 2026-06-06 16:32:24 +00:00
[iOS] Simplify text subtree advance calculation / anchor root resolution
This commit is contained in:
@@ -44,5 +44,6 @@
|
|||||||
- (void)pushContext:(RNSVGGroup*)node
|
- (void)pushContext:(RNSVGGroup*)node
|
||||||
font:(NSDictionary *)font;
|
font:(NSDictionary *)font;
|
||||||
|
|
||||||
|
- (NSArray*)getFontContext;
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|||||||
@@ -107,6 +107,9 @@
|
|||||||
|
|
||||||
@implementation RNSVGGlyphContext
|
@implementation RNSVGGlyphContext
|
||||||
|
|
||||||
|
- (NSArray*)getFontContext {
|
||||||
|
return mFontContext_;
|
||||||
|
}
|
||||||
|
|
||||||
- (CTFontRef)getGlyphFont
|
- (CTFontRef)getGlyphFont
|
||||||
{
|
{
|
||||||
|
|||||||
+10
-15
@@ -253,24 +253,19 @@
|
|||||||
- (RNSVGText*)getTextAnchorRoot
|
- (RNSVGText*)getTextAnchorRoot
|
||||||
{
|
{
|
||||||
RNSVGGlyphContext* gc = [self.textRoot getGlyphContext];
|
RNSVGGlyphContext* gc = [self.textRoot getGlyphContext];
|
||||||
RNSVGFontData* font = [gc getFont];
|
NSArray* font = [gc getFontContext];
|
||||||
enum RNSVGTextAnchor textAnchor = font->textAnchor;
|
RNSVGText* node = self;
|
||||||
if (textAnchor == RNSVGTextAnchorStart) {
|
|
||||||
return self;
|
|
||||||
}
|
|
||||||
UIView* parent = [self superview];
|
UIView* parent = [self superview];
|
||||||
if ([parent isKindOfClass:[RNSVGText class]]) {
|
for (NSInteger i = [font count] - 1; i >= 0; i--) {
|
||||||
RNSVGText *parentText = (RNSVGText*)parent;
|
RNSVGFontData* fontData = [font objectAtIndex:i];
|
||||||
RNSVGGlyphContext* gc = [parentText.textRoot getGlyphContext];
|
if (![parent isKindOfClass:[RNSVGText class]] ||
|
||||||
RNSVGFontData* font = [gc getFont];
|
fontData->textAnchor == RNSVGTextAnchorStart) {
|
||||||
enum RNSVGTextAnchor textAnchor = font->textAnchor;
|
return node;
|
||||||
if (textAnchor == RNSVGTextAnchorStart) {
|
|
||||||
return self;
|
|
||||||
} else {
|
|
||||||
return [parentText getTextAnchorRoot];
|
|
||||||
}
|
}
|
||||||
|
node = (RNSVGText*) parent;
|
||||||
|
parent = [node superview];
|
||||||
}
|
}
|
||||||
return self;
|
return node;
|
||||||
}
|
}
|
||||||
|
|
||||||
- (CGFloat)getSubtreeTextChunksTotalAdvance
|
- (CGFloat)getSubtreeTextChunksTotalAdvance
|
||||||
|
|||||||
Reference in New Issue
Block a user