在 Java 小程序中绘制异国情调的字体 [英] Drawing exotic fonts in a java applet
问题描述
我想绘制包含在异国情调字体中的符号,例如 Wingdings、Webdings(它们被称为 dingbats:http://en.wikipedia.org/wiki/Dingbat) 在 Java 小程序中.使用 Graphics.drawString() 时,我最终得到了绘制字符串中每个字符的典型方形符号".我通过谷歌搜索找不到任何答案,我想这不常见.
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.
过去我用 C# WPF 完成过,但用 SVG 和 HTML 没能做到.在java中可以吗?
In the past I've done it with C# WPF, failed to do it with SVG and HTML. Is it possible in java?
解决了.有一个微妙之处.即使你想要在这种字体中的符号链接到字符'a'
,实际上它是有必要传递"\uF061"
到 g.drawString() 而不是 "a"
.否则,您最终会得到方形符号.
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.
推荐答案
已解决.即使您想要在这种字体中的符号链接到字符 'a',实际上有必要将 "\uF061" 传递给 g.drawString() 而不是 "a".否则,您最终会得到方形符号.
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.
这篇关于在 Java 小程序中绘制异国情调的字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!