1

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

Heizel
  • 13
  • 3

1 Answers1

1

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));
Community
  • 1
  • 1
Paul Samsotha
  • 205,037
  • 37
  • 486
  • 720
  • Thanks your comment :) "textFlow.getFont()" returns org.eclipse.swt.graphics.Font type. And I can't use thoes method T^T So I tried like your code. `Font tFont = m_Textflow.getFont(); FontData[] tFontDataList = tFont.getFontData(); String tFontName = tFontDataList[0].getName(); int tFontStyle = tFontDataList[0].getStyle(); m_Textflow.setFont(new Font(Workbench.getInstance().getDisplay(), tFontName, aSize, tFontStyle));` but it didn't work well. – Heizel Mar 20 '14 at 06:42
  • Sorry, I thought you using Swing/AWT. I'm Not familiar with SWT – Paul Samsotha Mar 20 '14 at 06:47
  • thanks peeskillet :) your comment helps me. but i will find another way T^T – Heizel Apr 09 '14 at 07:19