我希望我的 GUI 使我的字體更大,因為我看到使用常規字體非常簡單,但我沒有從檔案中找到任何自定義字體,我當前的代碼如下所示:
InputStream is = App.class.getResourceAsStream("/mycustomfont.ttf");
try {
assert is != null;
font = Font.createFont(Font.TRUETYPE_FONT, is); // I get the font here but I don't have any options to change it's size
} catch (FontFormatException | IOException e) {
e.printStackTrace();
}
uj5u.com熱心網友回復:
font = Font.createFont(Font.TRUETYPE_FONT, is).deriveFont(42f);
詳情請參閱Font.deriveFont(float)。事實上,在提問之前,請務必參考檔案。這就是它的用途。
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/429875.html
上一篇:從文本組件設定列印操作的字體大小
