[英]How can I implement a custom java synth button style if I have a button style that already exists?
[英]How to set custom font in synth style
我自己想通了。 對於搜索此主題的每個人,這是解決方案。 創建一個新類:
public class CustomFontResource {
public static FontUIResource createFont(String path, final int size) {
Font font = Font.createFont(Font.TRUETYPE_FONT,
new FileInputStream(path));
FontUIResource fontResource = new FontUIResource(font.deriveFont(
Font.PLAIN, size));
return fontResource;
}
}
將其添加到style.xml:
<object id="your_font_id" class="yourpackage.CustomFontResource"
method="createFont">
<string>fontpath</string>
<int>desired size</int>
</object>
<style ...>
<font idref="your_font_id" />
</style>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.