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

View File

@@ -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

View File

@@ -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];
}

View File

@@ -1,18 +1,18 @@
#import <Foundation/Foundation.h>
#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;
}