I'm writing a tcl/tk application, where i would like to use font-awesome icons.
In principal, this works nicely: just display some string/label with the correct unicode char, and if the proper fonts are installed, it will render)
Now, on my dev machine i have font-awesome installed as an ordinary machine. I cannot expect that on the deployment machines.
So I would like to find out, whether the system can render a given character, or whether it just uses a glyph-not-found placeholder. In the latter case, i would just fallback to some less-nice representation...
(I don't want my users to have to answer a question like "does this string look correct?")
E.g. the symbol "" (
) displays as the stackoverflow-icon in my application. in my browser it is rendered as a glyph-not-found.
So, is there a way to find out programmatically, if any of the (used) system fonts provides the glyph for a given character?
Unfortunately, there isn't; it's outright missing functionality. The closest you can get is to get the actual font info for a character — requires 8.6 I think — or to measure its width, but that doesn't really help:
% font actual TkFixedFont
-family Monaco -size 11 -weight normal -slant roman -underline 0 -overstrike 0
% font actual TkFixedFont \uf16c
-family Monaco -size 11 -weight normal -slant roman -underline 0 -overstrike 0
% font measure TkFixedFont \uf16c
14
(The character renders as the glyph-not-found symbol on this system with that font.)