ctfontref

FontName from CTFontRef

柔情痞子 提交于 2020-01-04 08:23:24
问题 I've a CTFontRef variable. CTFontRef aFontRef; Getting Size of Font was easy : CGFloat aFontSize = CTFontGetSize(aFontRef); Please help me in retrieving the FontName. I'm expecting the FontName to be something like MarkerFelt-Wide . But, when I use methods like CTFontCopyFullName(aFontRef) I get Marker Felt Wide Cheers Roshit 回答1: Looks like you want the PostScript name, which you can obtain through CTFontCopyPostScriptName(). The PostScript name is an internal name, and is generally the

Objective-C - CTFont change font style?

天涯浪子 提交于 2019-11-30 20:46:56
问题 I have a CTFont that contains a font style, and sumbolic traits. I want to create a new font with a new style that inherits the symbolic traits of the first font. How can I achieve this? CTFontRef newFontWithoutTraits = CTFontCreateWithName((CFString)newFontName, CTFontGetSize(font), NULL); CTFontRef newFont = CTFontCreateCopyWithSymbolicTraits(newFontWithoutTraits, CTFontGetSize(font), NULL, 0, CTFontGetSymbolicTraits(font)); the new font is null here I don't know what should I pass to the

Giving Framesetter the correct line spacing adjustment

こ雲淡風輕ζ 提交于 2019-11-30 16:06:41
问题 Several posts have noted difficulties with getting an exact height out of CTFramesetterSuggestFrameSizeWithConstraints, and here, (framesetter post), @Chris DeSalvo gives what looks like the definitive fix: add a paragraph style setting with the correct line spacing adjustment. DeSalvo gets his “leading” by removing UIFont’s ascender and descender from its lineHeight. I wondered how that would compare to CTFontGetLeading . I worked with fonts created like this: CTFontRef fontr =

Giving Framesetter the correct line spacing adjustment

微笑、不失礼 提交于 2019-11-30 15:53:33
Several posts have noted difficulties with getting an exact height out of CTFramesetterSuggestFrameSizeWithConstraints, and here, (framesetter post) , @Chris DeSalvo gives what looks like the definitive fix: add a paragraph style setting with the correct line spacing adjustment. DeSalvo gets his “leading” by removing UIFont’s ascender and descender from its lineHeight. I wondered how that would compare to CTFontGetLeading . I worked with fonts created like this: CTFontRef fontr = CTFontCreateWithName((CFStringRef)@"Helvetica Neue", 16.0f, NULL); UIFont *font = [UIFont fontWithName:@"Helvetica