ios - How to check if a character is supported by a font -


I am working on an app with a text field. The text written in this field will be printed and I have an issue with some characters like Emoji, Chinese characters ... because the fonts do not provide these letters.

That's the reason I want to get everyone (font is downloaded so I can deal directly with the file or with a UIFont object).

provided character by a font

I have about that is heard CTFontGetGlyphsForCharacters but I'm not sure this function is what I want and I can not do it < / P>

Here is my code:.

  Ktfntrf Fontref = Ktfontkreatavitnme ((Kfstryngrefa) Fontkfontoname, Fontkpointsize, null); NSString * characters = @ "🐯"; // Emoji character NSUInteger count = letters.length; CGGlyph Glyph [Calculation]; If (CTFontGetGlyphsForCharacters (fontRef, (constant unichar *) [characters cStringUsingEncoding: NSUTF8StringEncoding], glyph count) == false) NSLog (@ "CTFontGetGlyphsForCharacters failed.");  

here CTFontGetGlyphsForCharacters return false . This is what I want, because the character '🐯' is not provided by the used font.
problem is when i NSString * Characters = Place @ "🐯" NSString * = by characters @ "ABC" , CTFontGetGlyphsForCharacters Return False . Obviously, my font provides a glyph for all ASCII characters

I finally solved it :.

  - (BOOL) Hacactor: (Unicr) characters supported Bafont: (UIFont *) aFont {UniChar characters [] = {character}; CGGlyph Glyph [1] = {}; CTFontRef ctFont = CTFontCreateWithName ((CFStringRef) aFont.fontName, aFont.pointSize, NULL); BOOL ret = CTFontGetGlyphsForCharacters (CTFonts, Characters, Glyphs, 1); CFRelease (ctFont); Return writ; }  

Comments

Popular posts from this blog

winforms - C# Form - Property Change -

java - Messages from .properties file do not display UTF-8 characters -

javascript - amcharts makechart not working -