org.eclipse.swt.graphics.GC.getCharWidth()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(1.1k)|赞(0)|评价(0)|浏览(134)

本文整理了Java中org.eclipse.swt.graphics.GC.getCharWidth()方法的一些代码示例,展示了GC.getCharWidth()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。GC.getCharWidth()方法的具体详情如下:
包路径:org.eclipse.swt.graphics.GC
类名称:GC
方法名:getCharWidth

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);

相关文章

GC类方法