Determining if a font can display a Unicode character in Cocoa Touch

Is there a way to determine if a font can display a specific Unicode character in Cocoa? Alternatively, can I specify a default replacement character?

+4
source share
3 answers

You can use CGFontGetGlyphWithGlyphName () for earlier versions of iOS (2.0) for iOS. Apple doesn't seem to document glyph names, but I believe they match this Adobe list:

http://partners.adobe.com/public/developer/en/opentype/glyphlist.txt

For example, the glyph for Γ© (U + 00E9) is called "eacute", and the code for the glyph is:

CFStringRef name = CFStringCreateWithCString(NULL, "eacute", kCFStringEncodingUTF8); CGGlyph glyph = CGFontGetGlyphWithGlyphName(font, name); 
+3
source

Check CTFontGetGlyphsForCharacters in the body of the body text. If it returns zero for a given Unicode character character index, then this character is not supported in this font. The function returns false if any of the glyphs is not found.

+3
source

Since this is on iOS, you may need to create or find an application that will do this. Ultimately, if the information is present for any single glyph, it is in the tables of the font file itself, and this is a fairly low level of C.

It is much easier to create a tool that checks the font and displays the glyph and glyph index (CGGlyph or NSGlyph value), then use the glyph index.

+1
source

Source: https://habr.com/ru/post/1307613/


All Articles