私はラインあたりCTFrameRefのみ8文字で描くしようとしているが、私はCTFrameRefでこれを行う方法を知りません。CTFrameRefで1行に8文字しか描画できないのですか?
私は "Manual Line Breaking"と読みましたが、CTLineを使用しています。私はCTFrameRefを使う方が簡単だと思います。
多分フレームセッターやCGPathを変更することで可能かもしれません。
これが今の私のコードです(私はこの問題についての私のテストコードとコメント行を削除した):
// Prepare font
CTFontRef font = CTFontCreateWithName(CFSTR("LucidaSansUnicode"), 16, NULL);
// Create path
CGMutablePathRef gpath = CGPathCreateMutable();
CGPathAddRect(gpath, NULL, CGRectMake(0, 0, 200, 200));
// Create an attributed string
CGContextSetTextDrawingMode (newcontext, kCGTextFillStroke);
CGContextSetGrayFillColor(newcontext, 0.0, 1.0);
CFStringRef keys[] = { kCTFontAttributeName };
CFTypeRef values[] = { font };
CFDictionaryRef attr = CFDictionaryCreate(NULL, (const void **)&keys,
(const void **)&values, sizeof(keys)/sizeof(keys[0]),
&kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
CFAttributedStringRef attrString = CFAttributedStringCreate(NULL,
CFSTR("Aenean lacinia bibendum nulla sed consectetur."), attr);
CTFramesetterRef framesetter =
CTFramesetterCreateWithAttributedString((CFAttributedStringRef)attrString);
CTFrameRef theFrame =
CTFramesetterCreateFrame(framesetter, CFRangeMake(0,
CFAttributedStringGetLength(attrString)), gpath, NULL);
CTFrameDraw(theFrame, newcontext);
// Clean up... CFRelease...
// Getting TIFF image
私は、次の画像を取得する:
しかし、私このようなものが欲しいです(この画像はPhotoshopで作成されているため、違いがあります)。
ありがとう、ごめんなさい。