I'd like to draw symbols contained in exotic fonts such as Wingdings, Webdings (they are called dingbats : http://en.wikipedia.org/wiki/Dingbat) in a java applet. When using Graphics.drawString() I end up with the typical 'square symbol' for each character in the drawn string. I could not find any answer by googling and I guess it's not something common.
In the past I've done it with C# WPF, failed to do it with SVG and HTML. Is it possible in java?
EDIT: Solved. There was a subtlety. Even though the symbol you want in such a font is linked to character 'a'
, it is in fact necessary to pass "\uF061"
to g.drawString() and not "a"
. Otherwise you end up with the square symbol.
Add the
Font
to a Jar (assuming you have the right to distribute it) that is on the run-time class-path of the applet. I.E. Add a reference to the Jar to thearchive
attribute of theapplet
element. Access it via (something like):Then look to the
Font
methods for thecreateFont(int,InputStream)
method.Thereafter is should be possible to use the
Font
in theGraphics
instance.Solved. Even though the symbol you want in such a font is linked to character 'a', it is in fact necessary to pass "\uF061" to g.drawString() and not "a". Otherwise you end up with the square symbol.