ctfont

Determine if unicode character has a glyph in UIFont

一笑奈何 提交于 2020-01-12 10:41:54
问题 I want to find out if a certain unicode character has a glyph representation even if by a cascading font. For example, let's say I am using UIFont.systemFont(withSize:18) and a string \u{1CDA} and would like to find out if this font will display the graphical representation of this character, and not a default question mark representation (ie there's no graphical representation, even by the supporting cascade fonts). 回答1: This works for me. Swift 3, XCode 8.6 version: import UIKit import

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

Determine if unicode character has a glyph in UIFont

二次信任 提交于 2019-12-03 20:32:16
I want to find out if a certain unicode character has a glyph representation even if by a cascading font. For example, let's say I am using UIFont.systemFont(withSize:18) and a string \u{1CDA} and would like to find out if this font will display the graphical representation of this character, and not a default question mark representation (ie there's no graphical representation, even by the supporting cascade fonts). This works for me. Swift 3, XCode 8.6 version: import UIKit import CoreText extension Font { public func hasGlyph(utf32 character:UInt32) -> Bool { var code_point: [UniChar] = [

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

iPhone - Convert CTFont to UIFont?

一笑奈何 提交于 2019-11-27 05:29:10
I am trying to convert a CTFont to a UIFont without losing any of the styles and attributes such as: Font Name Font Size Font color Underlines Bold Italic etc CTFontRef ctFont = ...; NSString *fontName = [(NSString *)CTFontCopyName(ctFont, kCTFontPostScriptNameKey) autorelease]; CGFloat fontSize = CTFontGetSize(ctFont); UIFont *font = [UIFont fontWithName:fontName size:fontSize]; Color and underline are not attributes of the font. Bold and italic are part of the font name. With ARC: UIFont *uiFont = [UIFont fontWithName:(__bridge NSString *)CTFontCopyPostScriptName(ctFont) size:CTFontGetSize

iPhone - Convert CTFont to UIFont?

爱⌒轻易说出口 提交于 2019-11-26 11:36:17
问题 I am trying to convert a CTFont to a UIFont without losing any of the styles and attributes such as: Font Name Font Size Font color Underlines Bold Italic etc 回答1: CTFontRef ctFont = ...; NSString *fontName = [(NSString *)CTFontCopyName(ctFont, kCTFontPostScriptNameKey) autorelease]; CGFloat fontSize = CTFontGetSize(ctFont); UIFont *font = [UIFont fontWithName:fontName size:fontSize]; Color and underline are not attributes of the font. Bold and italic are part of the font name. 回答2: With ARC: