This explains font metrics
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 ?
GC#textExtent()
returns extent in pixels, while FontData
returns in font points. The units are different here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With