当我尝试使用 Wingdings 字体(或其他符号字体)时,文本显示为矩形而不是正确的文本。如何获得正确的字符显示?
import java.awt.*;
import javax.swing.*;
public class WingdingsFontDisplay extends JFrame
{
public static void main(String[] args)
{
new WingdingsFontDisplay();
}
public WingdingsFontDisplay()
{
this.setSize(500,150);
this.setTitle("Fun with Fonts");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
//This shows that I do have "Wingdings" available
GraphicsEnvironment g;
g = GraphicsEnvironment.getLocalGraphicsEnvironment();
String[] fonts = g.getAvailableFontFamilyNames();
for(String f : fonts)
{
System.out.println(f);
}
//Displaying text in the Wingdings font shows rectangles
JLabel wingdingsText = new JLabel("All work and no play makes Jack a dull boy");
Font f1 = new …Run Code Online (Sandbox Code Playgroud) 当我使用Windgings作为字体在Word中写出一些文本(标准英语,没有花哨的字符)时,复制文本并粘贴到html文本字段会导致操作系统的"我不知道这是什么字符"字符(小方块)在Windows上).
似乎更改字体(应该是仅显示属性)会阻止文本正确粘贴到输入字段中.
为什么不直接粘贴文本?有什么办法可以阻止"小方块"的问题吗?