finish basic Text features on iOS

This commit is contained in:
Horcrux
2016-09-17 17:14:31 +08:00
parent a37c3ceee6
commit 5f4ff90c2a
6 changed files with 33 additions and 46 deletions
+1 -42
View File
@@ -17,13 +17,6 @@
[self invalidate];
_alignment = alignment;
}
//
//- (void)setTextFrame:(RNSVGTextFrame)textFrame
//{
// RNSVGFreeTextFrame(_textFrame);
// [self invalidate];
// _textFrame = textFrame;
//}
- (void)setPath:(NSArray *)path
{
@@ -34,15 +27,10 @@
_path = path;
}
//- (void)dealloc
//{
// RNSVGFreeTextFrame(_textFrame);
//}
- (void)renderLayerTo:(CGContextRef)context
{
CGFloat shift = [self getShift:context path:nil];
// translate path by alignment offset
// Translate path by alignment offset
CGContextSaveGState(context);
CGContextConcatCTM(context, CGAffineTransformMakeTranslation(-shift, 0));
[super renderLayerTo:context];
@@ -86,33 +74,4 @@
return shift;
}
//- (CGPathRef)getPath:(CGContextRef)context
//{
// CGMutablePathRef path = CGPathCreateMutable();
// RNSVGTextFrame frame = self.textFrame;
// for (int i = 0; i < frame.count; i++) {
// CGFloat shift;
// CGFloat width = frame.widths[i];
// switch (self.alignment) {
// case kCTTextAlignmentRight:
// shift = width;
// break;
// case kCTTextAlignmentCenter:
// shift = width / 2;
// break;
// default:
// shift = 0;
// break;
// }
// // We should consider snapping this shift to device pixels to improve rendering quality
// // when a line has subpixel width.
// CGAffineTransform offset = CGAffineTransformMakeTranslation(-shift, frame.baseLine + frame.lineHeight * i + (self.path ? -frame.lineHeight : 0));
//
// CGMutablePathRef line = [self setLinePath:frame.lines[i]];
// CGPathAddPath(path, &offset, line);
// CGPathRelease(line);
// }
// return (CGPathRef)CFAutorelease(path);
//}
@end