0

キャンバスで gc.setText() メソッドを使用してテキストを表示しています。ただし、gc オブジェクトが変更されると、テキストの幅も変更されます。

gc.setFont(font) を使用して GC に同じフォントを適用しています。

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'));

gc のオブジェクトが変わると、異なる文字幅を返しています。

誰でもこの問題を解決するのを手伝ってくれますか?

ありがとうイシャン・ジェイン

4

0 に答える 0