如何从现有字体创建新字体?

时间:2010-04-08 12:22:03

标签: java fonts swt

在SWT中,如何创建字体的粗体/斜体变体以及如何缩放字体?我试过了

int fontStyle = SWT.BOLD;
int height = 1200;

FontData[] fds = font.getFontData ();
for (FontData fd: fds)
{
    fd.setStyle (fontStyle);
    fd.setHeight ((fd.getHeight () * height + 500) / 1000);
}
newFont = new Font(font.getDevice (), fds);

但这对“Andale Mono”不起作用,例如。

1 个答案:

答案 0 :(得分:0)

并非所有字体都支持Italic或Bold。您可以在创建字体时设置字体大小:

Font font = new Font(fontFamilyName,fontStyle,fontSize);

相关问题