How to change the Font of the text in Birt DEAPI

603 Views Asked by At

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();
    }
}
1

There are 1 best solutions below

2
On

You need to install fonts in Unix OS.

For example, if you use Ubuntu (linux OS) then

sudo apt-get install ttf-mscorefonts-installer

Restart your eclipse all Microsoft fonts will reflect in your BIRT report perspective