GC和FontData在获取字体高度方面有什么区别? [英] What's the difference between GC and FontData for getting font height?

查看:72
本文介绍了GC和FontData在获取字体高度方面有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这说明了字体指标

我认为我们可以像这样在SWT中获得字体高度";

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()返回范围以像素为单位,而FontData返回字体为 points .这里的单位不同.

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

这篇关于GC和FontData在获取字体高度方面有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆