本文整理了Java中org.eclipse.swt.graphics.GC.getCharWidth()
方法的一些代码示例,展示了GC.getCharWidth()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GC.getCharWidth()
方法的具体详情如下:
包路径:org.eclipse.swt.graphics.GC
类名称:GC
方法名:getCharWidth
[英]Returns the width of the specified character in the font selected into the receiver.
The width is defined as the space taken up by the actual character, not including the leading and tailing whitespace or overhang.
[中]返回接收器中选定字体中指定字符的宽度。
宽度定义为实际字符占用的空间,不包括前导和尾随空格或悬垂。
代码示例来源:origin: org.piccolo2d/piccolo2d-swt
/**
* Returns the width of the character provided in the current font.
*
* @param ch character to calculate the width of.
*
* @return width of the character in the current font
*/
public int getCharWidth(final char ch) {
final org.eclipse.swt.graphics.Font scaledFont = gc.getFont();
gc.setFont(curFont);
final int width = gc.getCharWidth(ch);
gc.setFont(scaledFont);
return width;
}
代码示例来源:origin: org.xworker/xworker_swt
int charWidth = 0;
for(char c : text.toCharArray()){
charWidth += gc.getCharWidth(c);
代码示例来源:origin: org.xworker/xworker_swt
charWidth += gc.getCharWidth(ch);
内容来源于网络,如有侵权,请联系作者删除!