From 13d5157fc1684df16db9d67bbd514a3abc32cf66 Mon Sep 17 00:00:00 2001 From: Mikael Sand Date: Wed, 23 Aug 2017 16:22:49 +0300 Subject: [PATCH] Cleanup. --- ios/Elements/RNSVGGroup.m | 4 ++-- ios/Text/RNSVGTSpan.m | 18 ++++++++---------- ios/Text/RNSVGText.m | 4 +++- ios/Text/TextPathSpacing.m | 32 ++++++++++++++++---------------- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/ios/Elements/RNSVGGroup.m b/ios/Elements/RNSVGGroup.m index 8e4d5540..0515048b 100644 --- a/ios/Elements/RNSVGGroup.m +++ b/ios/Elements/RNSVGGroup.m @@ -70,13 +70,13 @@ - (void)pushGlyphContext { - [[[self getTextRoot] getRNSVGGlyphContext] pushContext:self.font]; + //[[[self getTextRoot] getRNSVGGlyphContext] pushContext:self.font]; [[[self getTextRoot] getGlyphContext] pushContextWithRNSVGGroup:self font:self.font]; } - (void)popGlyphContext { - [[[self getTextRoot] getRNSVGGlyphContext] popContext]; + //[[[self getTextRoot] getRNSVGGlyphContext] popContext]; [[[self getTextRoot] getGlyphContext] popContext]; } diff --git a/ios/Text/RNSVGTSpan.m b/ios/Text/RNSVGTSpan.m index d5f8edd6..a7fc3844 100644 --- a/ios/Text/RNSVGTSpan.m +++ b/ios/Text/RNSVGTSpan.m @@ -110,15 +110,14 @@ CFArrayRef runs = CTLineGetGlyphRuns(line); GlyphContext* gc = [[self getTextRoot] getGlyphContext]; FontData* font = [gc getFont]; - NSUInteger length = str.length; - NSUInteger n = length; - unichar characters[n]; - CFStringGetCharacters((__bridge CFStringRef) str, CFRangeMake(0, n), characters); - CGGlyph glyphs[n]; + NSUInteger n = str.length; CGSize glyph_advances[n]; + unichar characters[n]; + CGGlyph glyphs[n]; + CFStringGetCharacters((__bridge CFStringRef) str, CFRangeMake(0, n), characters); CTFontGetGlyphsForCharacters(fontRef, characters, glyphs, n); - CTFontGetAdvancesForGlyphs(fontRef, kCTFontDefaultOrientation, glyphs, glyph_advances, n); + CTFontGetAdvancesForGlyphs(fontRef, kCTFontOrientationHorizontal, glyphs, glyph_advances, n); /* * * Three properties affect the space between characters and words: @@ -473,7 +472,7 @@ switch (mLengthAdjust) { default: case TextLengthAdjustSpacing: - letterSpacing += (author - textMeasure) / (length - 1); + letterSpacing += (author - textMeasure) / (n - 1); break; case TextLengthAdjustSpacingAndGlyphs: scaleSpacingAndGlyphs = author / textMeasure; @@ -805,11 +804,11 @@ CGFloat getTextAnchorOffset(enum TextAnchor textAnchor, CGFloat width) _path = nil; textPath = nil; textPathPath = nil; - __block RNSVGBezierTransformer *bezierTransformer; + //_bezierTransformer = nil; [self traverseTextSuperviews:^(__kindof RNSVGText *node) { if ([node class] == [RNSVGTextPath class]) { textPath = (RNSVGTextPath*) node; - bezierTransformer = [textPath getBezierTransformer]; + //_bezierTransformer = [textPath getBezierTransformer]; textPathPath = [textPath getPath]; _path = [UIBezierPath bezierPathWithCGPath:[textPathPath getPath:nil]]; pathLength = [_path length]; @@ -817,7 +816,6 @@ CGFloat getTextAnchorOffset(enum TextAnchor textAnchor, CGFloat width) } return YES; }]; - _bezierTransformer = bezierTransformer; } - (void)traverseTextSuperviews:(BOOL (^)(__kindof RNSVGText *node))block diff --git a/ios/Text/RNSVGText.m b/ios/Text/RNSVGText.m index cf94e240..328e617b 100644 --- a/ios/Text/RNSVGText.m +++ b/ios/Text/RNSVGText.m @@ -107,11 +107,12 @@ - (void)pushGlyphContext { + /* [[[self getTextRoot] getRNSVGGlyphContext] pushContext:self.font deltaX:self.deltaX deltaY:self.deltaY positionX:self.positionX - positionY:self.positionY]; + positionY:self.positionY];*/ [[[self getTextRoot] getGlyphContext] pushContextwithRNSVGText:self reset:false font:self.font @@ -124,6 +125,7 @@ - (void)popGlyphContext { + //[[[self getTextRoot] getRNSVGGlyphContext] popContext]; [[[self getTextRoot] getGlyphContext] popContext]; } diff --git a/ios/Text/TextPathSpacing.m b/ios/Text/TextPathSpacing.m index 30c7e5a5..b62139ee 100644 --- a/ios/Text/TextPathSpacing.m +++ b/ios/Text/TextPathSpacing.m @@ -1,18 +1,18 @@ -#import +#import "TextPathSpacing.h" -#if !defined (TextPathSpacing_) -#define TextPathSpacing_ +NSString* TextPathSpacingToString( enum TextPathSpacing fw ) +{ + return TextPathSpacingStrings[fw]; +} -NS_ENUM(NSInteger, TextPathSpacing) { - TextPathSpacingAutoSpacing, - TextPathSpacingExact, - TextPathSpacingDEFAULT = TextPathSpacingAutoSpacing, -}; - -static NSString* const TextPathSpacingStrings[] = {@"auto", @"exact", nil}; - -NSString* TextPathSpacingToString( enum TextPathSpacing fw ); - -enum TextPathSpacing TextPathSpacingFromString( NSString* s ); - -#endif +enum TextPathSpacing TextPathSpacingFromString( NSString* s ) +{ + NSInteger i; + NSString* fw; + for (i = 0; fw = TextPathSpacingStrings[i], fw != nil; i++) { + if ([fw isEqualToString:s]) { + return i; + } + } + return TextPathSpacingDEFAULT; +}