Eclipse plugin: gc.getCharWidth is giving different size when gc object changes

30 Views Asked by At

I am displaying text using gc.setText() method on canvas. But if the gc object changes then width of the text also changes.

I am applying the same font to GC using gc.setFont(font).

Font font = new Font(gc.getDevice(), fontFamily, (int) fontSize,     swtFontStyle);
    if (color != null) {
        gc.setForeground(color);
    } else {
        gc.setForeground(ColorConstants.black);
    }
    gc.setFont(font);
System.out.println("char width in gc: "+gc.getCharWidth('a'));

It is returning different character width when object of gc changes.

Can anyone help me to resolve this issue.

Thanks Ishan Jain

0

There are 0 best solutions below