On Android, I want to be able to detect if the font used can display a certain character or not, but as I understand it this is not possible with conventional means as indicated by Check if custom font can display character
To detect this I'm writing the character I want to check to a bitmap and then I write another character that I know is missing to another bitmap and compare the content of the bitmaps. If they are equal the character is missing.
The question is, is there any unicode character whose glyph is (more or less) guaranteed to be missing on fonts typically used on Android phones?
The Unicode replacement character sounds promising when reading about it on Wikipedia:
It is used to indicate problems when a system is not able to render a stream of data to a correct symbol. It is most commonly seen when a font does not contain a character, but is also seen when the data is invalid and does not match any character
However after doing a bit of testing I see that this character is not used to represent missing glyphs on either my Windows 7 computer or the Android phone I've tested with (Motorola Atrix).
The easy way to know what is in a font's character set is by viewing the software's glyph panel. For any font, begin by selecting the Entire Font option. From there, view the submenus, investigating categories of glyphs you might be interested in. (These categories closely mirror those in the OpenType panel.)
The hands-down most comprehensive coverage would be Roman Czyborra's GNU Unicode Font project. It is intended to collect a complete and free 8×16/16×16 pixel Unicode font. It currently covers 34,445 characters (out of ~40,000+ defined characters).
The vast majority of modern computer fonts use Unicode mappings, even those fonts which only include glyphs for a single writing system, or even only support the basic Latin alphabet.
Glyphs are also universal, as others may agree with your glyph and its meaning, making it a universal representation of that word. Glyphs are universal and personal, global and local. They unify communication while recognizing our cultural, geographic and personal differences.
There isn't any designated Unicode value for the glyph that is used to render glyphs that are missing in the font used. In the actual font, glyph id 0 should always be the .notdef glyph which is used for all characters that are missing a glyph. However it is not possible this information from the fonts on Android, so it's not possible to use the .notdef glyph directly.
In Unicode there are many reserved/unassigned code points and my limited testing indicate that these code points are rendered using the .notdef glyph. So by using U+0978, which is a reserved code point in the middle of the Devanagari block, I can detect if some other valid, known character exists in the font I want to test.
This is not a future proof solution since new glyphs may be added to reserved code points by the Unicode Consortium in the future. But for my needs it's good enough since what I want to do is a temporary thing that is not relevant any more in the near future.
Update:
The solution to look at U+0978 did not work long. That character was added in the Unicode 7.0 release in June 2014. Another option is to use a glyph that exists in unicode but that is very unlikely to be used in a normal font.
U+124AB in the Early Dynastic Cuneiform block is probably something that doesn't exist in many fonts at all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With