0

I have created a Birt report in which I defined a Segoeuii font-family to the text it works fine in windows but when it come of Unix OS it change all the fonts to the Times new Roman it is somehow because the font is not present in the Unix file system and Birt does not register the font that is not in the file system so we need to register the fonts first so using FontFactory I register the font and than set this font in the property but still it displaying Times new Roman .
Here is my code.

public void testCode() {
    URL font = Thread.currentThread().getContextClassLoader().getResource("segoeuii.ttf"); // getResourceAsStream("segoeuii.ttf");
    TextItemHandle text = (TextItemHandle) designHandle.findElement("TextProbingAttacks");
    FontFactory.register(font.toString(), "test_font");
    Font myfont = FontFactory.getFont("test_font");
    try {
        text.setProperty("fontFamily", myfont);
    } catch (SemanticException e) {
        // TODO Auto-generated catch block
        e.printStackTrace();
    }
}
4

1 回答 1

0

您需要在 Unix 操作系统中安装字体。

例如,如果您使用 Ubuntu(Linux 操作系统),那么

sudo apt-get install ttf-mscorefonts-installer

重新启动您的 Eclipse,所有 Microsoft 字体都将反映在您的 BIRT 报告透视图中

于 2016-05-04T05:02:46.693 回答