[英]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.