This question could be generalized to any character, I suppose; but my specific use-case are emoji.
I'm writing a command-line program, and I want to detect if the computer on which it is running has a font installed that can display emoji; and whether the current terminal application will display them in that font.
At the moment, I have a hack in place that simply filters them out on non-OS X; but I don't want to short-change Linux users who have an emoji-enabled setup. I'd prefer to do this the โright way.โ
Thanks! ๐
Your script would have to:
If you're into PHP, you could calculate the bounding box of the TTF fonts that are known for the Emoji, and see if the value is what is to be expected of a font that supports it.
You could also simulate the font use by drawing in a black in-memory image with a white colored font using GD, and calculate the (average) amount of white pixels to see if it fits an expected threshold.
You also asked for a check if the current terminal application will display them. For that you need to be able to check the config, which is non trivial since you'd need to be able to differentiate on all terminal applications. A practical solution would be to display some Emoji with the current font and just ask the user if it is visable. After all, you need to rely on the user anyway if the terminal application needs to support Emoji?
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