自定义字体和系统字体之间的区别?

时间:2017-03-09 05:44:12

标签: ios objective-c nsattributedstring core-text

我正在使用核心文字根据内容长度绘制字符串,而我正在使用 CTFramesetterCreateWithAttributedString

自定义字体和系统字体有什么区别吗?

我将属性 kCTFontAttributeName 添加到 NSMutableAttributedString 。每种字体的工作方式都不一样......当我使用systemFont时,它会非常快速地更新视图,但是如果我使用plist中包含的自定义字体,则需要很长时间才能更新视图。

    if (self.text != nil)
    {

        self.attributedString = [[NSMutableAttributedString alloc] initWithString:self.text];
        NSRange range = NSMakeRange(0, [self.text length]);
        // Regarding Fixed font
        //        [ self.attributedString addAttribute:NSFontAttributeName value:[UIFont fontWithName:@"TAUN_Elango_Abirami" size:20] range:range];//This is my custom font


        // Regarding custom Font using below code
        if (self.font != nil) {


             //************************* working fine only system font *******************
//            UIFont *fonts = [UIFont systemFontOfSize:24 weight:0];
//            [self.attributedString addAttribute:(NSString *)kCTFontAttributeName
//                                          value:fonts
//                                          range:range];

          //  self.font is a custom font from superclass

            //************************* here i am facing problem *******************
            [self.attributedString addAttribute:(NSString *)kCTFontAttributeName
                                          value:self.font
                                          range:range];
        }
    }

为什么我使用自定义UIFont 需要更多时间?

0 个答案:

没有答案
相关问题