Я пытаюсь отобразить font awesome иконки на JButton
. Я сделал следующееFont Awsome on JButton
Font font = null;
try
{
font = Font.createFont(Font.TRUETYPE_FONT, new File("../icons/fontawesome-webfont.ttf"));
font = font.deriveFont(18f);
GraphicsEnvironment ge =
GraphicsEnvironment.getLocalGraphicsEnvironment();
ge.registerFont(font);
}
catch (FontFormatException ex){ex.printStackTrace();}
catch (IOException ex){ex.printStackTrace();}
private JButton save_btn = new JButton();
save_btn.setFont(font);
save_btn.setText("\uf0c7");
save_btn.setPreferredSize(buttonDimension);
Но все, что я получаю
Если я использую шрифт с JTextArea, он отлично работает:
JTextArea t = new JTextArea();
t.setRows(2);
t.setColumns(12);
t.setFont(font);
t.setText("\uF0F3 \uF1EC \uf0f3 \uf1ec");
buttonPanel.add(t);
Я получаю
Что выход для 'System.out.println (font.canDisplay ("\ uf0c7"));'? –
Проверить погоду - это шрифт, который поддерживается в нашей системе? – Krishna
Вы ссылались на правильный код символа? Вот аналогичная проблема: http://stackoverflow.com/questions/9639894/add-icons-to-jbutton-using-custom-font-from-awesomefont-and-unicode-characters-i – stuXnet