I have a custom font which is displaying the box character. The font I am using does not support all languages apparently. I want to check if the String I am about to display can be displayed by my custom font. If it cannot then I want to use the standard Android font (which I know can display the characters). I can't find a method to check if my Typeface can display a particular String though. I am sure I have seen a method around that does this somewhere. Anyone know?
As of Android version 23, You can test it like this:
Typeface typeface;
//initialize the custom font here
//enter the character to test
String charToTest="\u0978";
Paint paint=new Paint();
paint.setTypeface(typeface);
boolean hasGlyph=paint.hasGlyph(charToTest);
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