标签: ctfontref

(NSCFType set) - iOS 6中无法识别的选择器

我正在使用伟大的TTTAttributedLabel(https://github.com/mattt/TTTAttributedLabel)在iOS 5下工作正常.但是在iOS 6下,我收到错误:

-[__NSCFType set]: unrecognized selector sent to instance 0x200020e0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-  [__NSCFType set]: unrecognized selector sent to instance 0x200020e0'
Run Code Online (Sandbox Code Playgroud)

稍微研究了这个问题后,似乎将设置的消息发送到已经发布的对象.使用调试器,我已经po'd 0x200020e0,它似乎是CTFontRef.

po 0x200020e0
(int) $0 = 536879328 CTFont <name: .HelveticaNeueUI-Bold, size: 20.000000, matrix: 0x0>
CTFontDescriptor <attributes: <CFBasicHash 0x20001900 [0x3c2a4100]>{type = mutable dict, count = 1,
entries =>
1 : <CFString 0x3be2a768 [0x3c2a4100]>{contents = "NSFontNameAttribute"} = <CFString 0x3c292c14 [0x3c2a4100]>{contents = ".HelveticaNeueUI-Bold"}
Run Code Online (Sandbox Code Playgroud)

}

这让我直接找到了设置TTTAttributedLabel的代码:

 [label setText:text afterInheritingLabelAttributesAndConfiguringWithBlock:^ NSMutableAttributedString *(NSMutableAttributedString *mutableAttributedString) …
Run Code Online (Sandbox Code Playgroud)

xcode core-text ios ctfontref ios6

13
推荐指数
2
解决办法
1万
查看次数

由于CTFontRef导致记忆泄漏

我使用下面的代码生成PDF但是导致内存泄漏可以有人帮忙吗?代码如下.

- (void)drawText:(NSString*)textToDraw inFrame:(CGRect)frameRect {


    NSMutableAttributedString *string = [[[NSMutableAttributedString alloc]
                                         initWithString:textToDraw] autorelease];

    // make a few words bold

    CTFontRef helveticaBold = CTFontCreateWithName(CFSTR("Helvetica-Bold"), 8.0, NULL);

    [string addAttribute:(id)kCTFontAttributeName
                   value:(id)helveticaBold
                   range:NSMakeRange(0, [string length])];

    // add some color.
    if (_flag == 1) {

        [string addAttribute:(id)kCTForegroundColorAttributeName
                       value:(id)[UIColor whiteColor].CGColor
                       range:NSMakeRange(0, [string length])];


    } else {

        [string addAttribute:(id)kCTForegroundColorAttributeName
                       value:(id)[UIColor blackColor].CGColor
                       range:NSMakeRange(0, [string length])];
    }

    // layout master
    CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString((CFAttributedStringRef)string);

    CGMutablePathRef framePath = CGPathCreateMutable();
    CGPathAddRect(framePath, NULL, frameRect);

    // Get the frame that will do the rendering. …
Run Code Online (Sandbox Code Playgroud)

memory-leaks ios ctfontref

2
推荐指数
1
解决办法
1216
查看次数

Objective-C - CTFont改变字体样式?

我有一个包含字体样式和sumbolic特征的CTFont.

我想创建一个新样式的新字体,它继承了第一个字体的符号特征.我怎样才能做到这一点?

CTFontRef newFontWithoutTraits = CTFontCreateWithName((CFString)newFontName, CTFontGetSize(font), NULL);
CTFontRef newFont = CTFontCreateCopyWithSymbolicTraits(newFontWithoutTraits, CTFontGetSize(font), NULL, 0, CTFontGetSymbolicTraits(font));
Run Code Online (Sandbox Code Playgroud)

新字体在这里为null我不知道应该传递给4th参数CTFontCreateCopyWithSymbolicTraits.

objective-c ctfont ctfontref

1
推荐指数
1
解决办法
4644
查看次数

CoreText - 创建CTFont时的性能警告?

创建CTFont时,我收到以下警告.

CoreText性能注释:客户端请求"ArialRoundedMTBold"使用名称的PostScript名称字体"Arial Rounded MT Bold".

// Creating Font
CTFontRef fontWithoutTrait = CTFontCreateWithName((__bridge CFStringRef)(name), size, NULL);

// Font names I use to create a font 
[UIFont familyNames];
Run Code Online (Sandbox Code Playgroud)

如果我删除从[UIFont familyNames]获取的任何字体名称中的所有空格,它是否是核心文本的预期字体名称是否安全?

objective-c core-text ctfont ctfontref

1
推荐指数
1
解决办法
4431
查看次数

标签 统计

ctfontref ×4

core-text ×2

ctfont ×2

ios ×2

objective-c ×2

ios6 ×1

memory-leaks ×1

xcode ×1