Search code examples
javaeclipse-pluginfont-sizedraw2dtextflow

I want to change fontsize in textflow or label


I'm implementing multiline Label Figure.

I have a question.

How can i change font size of textflow ?

I tried with the method [textflow.setFont] before I had changed height value of fontdata.

use this code,Font tFont = m_Textflow.getFont(); FontData[] tFontDataList = tFont.getFontData(); tFontDataList[0].setHeight(aSize); m_Textflow.setFont(new Font(null, tFontDataList[0]));

But that didn’t work correctly and made any space on head.

Help me please T^T


Solution

  • See the Font API. You'll find the constructor

    Font(String name, int style, int size) -

    Creates a new Font from the specified name, style and point size.

    So you could do something like

    String family = textFlow.getFont().getFamily();
    int style = textFlow.getFont().getStyle();
    int theNewFontSize = 30;
    textFlow.setFont(new Font(family, style, theNewFontSize));