Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between GC and FontData for getting font height?

This explains font metrics enter image description here

I think we can get "Font height" in SWT like these;

GC gc = new GC(label);
System.out.println( gc.textExtent(label.getText()) );
System.out.println( label.getFont().getFontData()[0].getHeight() );

Why this two outs aren't same? And which one is correct height for a string ?

like image 315
miqbal Avatar asked Nov 28 '12 11:11

miqbal


1 Answers

GC#textExtent() returns extent in pixels, while FontData returns in font points. The units are different here.

like image 76
Waqas Ilyas Avatar answered Oct 21 '22 23:10

Waqas Ilyas