This commit is contained in:
Mikael Sand
2017-08-23 16:22:49 +03:00
parent ccb8729917
commit 13d5157fc1
4 changed files with 29 additions and 29 deletions
+2 -2
View File
@@ -70,13 +70,13 @@
- (void)pushGlyphContext - (void)pushGlyphContext
{ {
[[[self getTextRoot] getRNSVGGlyphContext] pushContext:self.font]; //[[[self getTextRoot] getRNSVGGlyphContext] pushContext:self.font];
[[[self getTextRoot] getGlyphContext] pushContextWithRNSVGGroup:self font:self.font]; [[[self getTextRoot] getGlyphContext] pushContextWithRNSVGGroup:self font:self.font];
} }
- (void)popGlyphContext - (void)popGlyphContext
{ {
[[[self getTextRoot] getRNSVGGlyphContext] popContext]; //[[[self getTextRoot] getRNSVGGlyphContext] popContext];
[[[self getTextRoot] getGlyphContext] popContext]; [[[self getTextRoot] getGlyphContext] popContext];
} }
+8 -10
View File
@@ -110,15 +110,14 @@
CFArrayRef runs = CTLineGetGlyphRuns(line); CFArrayRef runs = CTLineGetGlyphRuns(line);
GlyphContext* gc = [[self getTextRoot] getGlyphContext]; GlyphContext* gc = [[self getTextRoot] getGlyphContext];
FontData* font = [gc getFont]; FontData* font = [gc getFont];
NSUInteger length = str.length; NSUInteger n = str.length;
NSUInteger n = length;
unichar characters[n];
CFStringGetCharacters((__bridge CFStringRef) str, CFRangeMake(0, n), characters);
CGGlyph glyphs[n];
CGSize glyph_advances[n]; CGSize glyph_advances[n];
unichar characters[n];
CGGlyph glyphs[n];
CFStringGetCharacters((__bridge CFStringRef) str, CFRangeMake(0, n), characters);
CTFontGetGlyphsForCharacters(fontRef, characters, glyphs, n); 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: * Three properties affect the space between characters and words:
@@ -473,7 +472,7 @@
switch (mLengthAdjust) { switch (mLengthAdjust) {
default: default:
case TextLengthAdjustSpacing: case TextLengthAdjustSpacing:
letterSpacing += (author - textMeasure) / (length - 1); letterSpacing += (author - textMeasure) / (n - 1);
break; break;
case TextLengthAdjustSpacingAndGlyphs: case TextLengthAdjustSpacingAndGlyphs:
scaleSpacingAndGlyphs = author / textMeasure; scaleSpacingAndGlyphs = author / textMeasure;
@@ -805,11 +804,11 @@ CGFloat getTextAnchorOffset(enum TextAnchor textAnchor, CGFloat width)
_path = nil; _path = nil;
textPath = nil; textPath = nil;
textPathPath = nil; textPathPath = nil;
__block RNSVGBezierTransformer *bezierTransformer; //_bezierTransformer = nil;
[self traverseTextSuperviews:^(__kindof RNSVGText *node) { [self traverseTextSuperviews:^(__kindof RNSVGText *node) {
if ([node class] == [RNSVGTextPath class]) { if ([node class] == [RNSVGTextPath class]) {
textPath = (RNSVGTextPath*) node; textPath = (RNSVGTextPath*) node;
bezierTransformer = [textPath getBezierTransformer]; //_bezierTransformer = [textPath getBezierTransformer];
textPathPath = [textPath getPath]; textPathPath = [textPath getPath];
_path = [UIBezierPath bezierPathWithCGPath:[textPathPath getPath:nil]]; _path = [UIBezierPath bezierPathWithCGPath:[textPathPath getPath:nil]];
pathLength = [_path length]; pathLength = [_path length];
@@ -817,7 +816,6 @@ CGFloat getTextAnchorOffset(enum TextAnchor textAnchor, CGFloat width)
} }
return YES; return YES;
}]; }];
_bezierTransformer = bezierTransformer;
} }
- (void)traverseTextSuperviews:(BOOL (^)(__kindof RNSVGText *node))block - (void)traverseTextSuperviews:(BOOL (^)(__kindof RNSVGText *node))block
+3 -1
View File
@@ -107,11 +107,12 @@
- (void)pushGlyphContext - (void)pushGlyphContext
{ {
/*
[[[self getTextRoot] getRNSVGGlyphContext] pushContext:self.font [[[self getTextRoot] getRNSVGGlyphContext] pushContext:self.font
deltaX:self.deltaX deltaX:self.deltaX
deltaY:self.deltaY deltaY:self.deltaY
positionX:self.positionX positionX:self.positionX
positionY:self.positionY]; positionY:self.positionY];*/
[[[self getTextRoot] getGlyphContext] pushContextwithRNSVGText:self [[[self getTextRoot] getGlyphContext] pushContextwithRNSVGText:self
reset:false reset:false
font:self.font font:self.font
@@ -124,6 +125,7 @@
- (void)popGlyphContext - (void)popGlyphContext
{ {
//[[[self getTextRoot] getRNSVGGlyphContext] popContext];
[[[self getTextRoot] getGlyphContext] popContext]; [[[self getTextRoot] getGlyphContext] popContext];
} }
+16 -16
View File
@@ -1,18 +1,18 @@
#import <Foundation/Foundation.h> #import "TextPathSpacing.h"
#if !defined (TextPathSpacing_) NSString* TextPathSpacingToString( enum TextPathSpacing fw )
#define TextPathSpacing_ {
return TextPathSpacingStrings[fw];
}
NS_ENUM(NSInteger, TextPathSpacing) { enum TextPathSpacing TextPathSpacingFromString( NSString* s )
TextPathSpacingAutoSpacing, {
TextPathSpacingExact, NSInteger i;
TextPathSpacingDEFAULT = TextPathSpacingAutoSpacing, NSString* fw;
}; for (i = 0; fw = TextPathSpacingStrings[i], fw != nil; i++) {
if ([fw isEqualToString:s]) {
static NSString* const TextPathSpacingStrings[] = {@"auto", @"exact", nil}; return i;
}
NSString* TextPathSpacingToString( enum TextPathSpacing fw ); }
return TextPathSpacingDEFAULT;
enum TextPathSpacing TextPathSpacingFromString( NSString* s ); }
#endif