이상한 일이 있습니다. 나는 기울어 짐 및 비뚤어 짐을 포함하여 일부 서식 지정을 위해 NSAttributedString을 사용하고있었습니다. NSObliquenessAttributeName이 트릭을했습니다. 그러나 텍스트를 실제로 렌더링하는 프레임을 제어하기 위해 CoreText로 확장하려고했습니다. 모든 것을 알아 내기 전에 NSObliquenessAttributeName이 렌더링되지 않는 것을 알았습니다. 내 모든 다른 속성은 여전히 렌더링되므로 약간 혼란 스럽습니다.NSObliquenessAttributeName이 CTFrameDraw()에 의해 무시되었습니다.
- (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);
}
매우 유용한 정보. 그것이 내가 걱정했던 것이었지만 이전에 LOL에서 작업했던 속성이없는 헤더 파일 이외의 다른 문서를 지원하는 좋은 문서를 찾을 수 없었습니다. –
그 말은 기울임 꼴 위에 기울임을 사용해야한다는 것입니다. 이것은 일종의 텍스트 편집기를위한 것이므로 경사가 디자이너의 통제하에 있어야합니다. 글꼴 생성에 대해 살펴 보겠습니다. 이전에 변형 행렬을 사용하여 다른 고유 한 작업을 수행하는 코드를 보았습니다. –
그걸 염두에두고, 당신은 그 지식을 알고 있습니까? 샘플 코드 등 –