中文字符"]; //设置字体属性 CTFontRef font = CTFontCreateWithName(CFSTR("Georgia"), 40, NULL); [mabstring addAttribute :(id)kCTFontAttributeName value:(id)font range:NSMakeRange(0, 4)]; //设置斜体字 CTFontRef font = CTFontCreateWithName dictionaryWithObject:(id)[UIColor redColor].CGColor forKey:(id)kCTForegroundColorAttributeName]; //斜体 CTFontRef kCTCharacterShapeAttributeName value:(id)num range: NSMakeRange(0, 4)]; */ /* //设置字体属性 CTFontRef kCTSuperscriptAttributeName value:(id)num range:NSMakeRange(3, 1)]; */ /* //设置斜体字 CTFontRef
getStrfromMorelineby:(UILabel*)lable withfont:(UIFont*)font withdic:(NSDictionary*)dic withstr:(NSString*)str{ CTFontRef
1、CTFont CTFontRef是CoreText的字体,可以读取字体的版权信息(copyright)、fontFamily、style等信息; CTFontCreateWithName()用于创建字体 CFIndex count ); 获取字体的ascent、descent、leading、bounding box等属性: CGFloat CTFontGetAscent( CTFontRef font ); CGFloat CTFontGetDescent( CTFontRef font ); CGFloat CTFontGetLeading( CTFontRef font ); CGRect CTFontGetBoundingBox( CTFontRef font ); 可以直接对某些字形进行渲染,参数font提供字体相关属性,glyphs数组提供字形,positions数组提供位置(可以通过 CTLine生成); void CTFontDrawGlyphs( CTFontRef font, const CGGlyph glyphs[_Nonnull],
str= CFStringCreateWithCString(kCFAllocatorDefault, “hello world", kCFStringEncodingUTF8); // 创建一个 CTFontRef 对象 CTFontRef fontRef = CTFontCreateWithName((CFStringRef)@"ArialMT", fontSize, NULL); 对于这些对象的引用计数的修改 如下所示: // 创建一个 CTFontRef 对象 CTFontRef fontRef = CTFontCreateWithName((CFStringRef)@"ArialMT", fontSize
.CGColor range:NSMakeRange(5, 10)]; //字体 UIFont * font = [UIFont systemFontOfSize:25]; CTFontRef
CGContextScaleCTM(context,1.0,-1.0); //文字颜色 UIColor* textColor = color; //生成CTFont CTFontRef
这样可以根据你的具体需要来决定字体属性应该是用CGFontRef类型还是CTFontRef类型(Core Text字体)。 同时字体大小也是用fontSize属性单独设置的,因为CTFontRef和CGFontRef并不像UIFont一样包含点大小。 CFStringRef fontName = (__bridge CFStringRef)font.fontName; CGFloat fontSize = font.pointSize; CTFontRef