何か奇妙なことが起こっています。傾斜や傾斜など、いくつかの書式設定のために NSAttributedString を使用していました。NSObliquenessAttributeName はトリックを行いました。しかし、その後、テキストが実際にレンダリングされるフレームを制御するために CoreText に拡張したいと考えました。他のすべての属性はまだレンダリングされているため、少し混乱しています。
- (void)drawSlanted
{
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);
[[UIColor blackColor] setFill];
NSAttributedString *text = [[NSAttributedString alloc] initWithString:@"This isn't slanted... but is stroked" attributes:@{NSObliquenessAttributeName: @10.0,
NSStrokeWidthAttributeName: @2.0}];
// Flip Coordinates
CGContextSetTextMatrix(context, CGAffineTransformIdentity);
CGContextTranslateCTM(context, 0.0, CGRectGetHeight(self.bounds));
CGContextScaleCTM(context, 1.0, -1.0);
CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString((CFAttributedStringRef)text);
CTFrameRef frame = CTFramesetterCreateFrame(framesetter, CFRangeMake(0, text.length), [UIBezierPath bezierPathWithRect:self.bounds].CGPath, NULL);
CTFrameDraw(frame, context);
CFRelease(frame);
CGContextRestoreGState(context);
}