本文整理了Java中org.eclipse.swt.graphics.Device.getSystemFont()
方法的一些代码示例,展示了Device.getSystemFont()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Device.getSystemFont()
方法的具体详情如下:
包路径:org.eclipse.swt.graphics.Device
类名称:Device
方法名:getSystemFont
[英]Returns a reasonable font for applications to use. On some platforms, this will match the "default font" or "system font" if such can be found. This font should not be freed because it was allocated by the system, not the application.
Typically, applications which want the default look should simply not set the font on the widgets they create. Widgets are always created with the correct default font for the class of user-interface component they represent.
[中]返回应用程序要使用的合理字体。在某些平台上,这将与“默认字体”或“系统字体”匹配(如果可以找到)。不应释放此字体,因为它是由系统而不是应用程序分配的。
通常,想要默认外观的应用程序不应该在它们创建的小部件上设置字体。小部件总是使用它们所代表的用户界面组件类的正确默认字体创建。
代码示例来源:origin: pentaho/pentaho-kettle
public static void setGCFont( GC gc, Device device, FontData fontData ) {
if ( Const.getOS().startsWith( "Windows" ) ) {
Font font = new Font( device, fontData );
gc.setFont( font );
font.dispose();
} else {
gc.setFont( device.getSystemFont() );
}
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
@Override
Font getDefaultFont() {
return device.getSystemFont();
}
代码示例来源:origin: org.eclipse.rap/org.eclipse.rap.rwt
DeviceGC( Device device ) {
this.device = device;
this.background = device.getSystemColor( SWT.COLOR_WHITE );
this.foreground = device.getSystemColor( SWT.COLOR_BLACK );
this.font = device.getSystemFont();
this.alpha = 255;
this.lineWidth = 0;
this.lineCap = SWT.CAP_FLAT;
this.lineJoin = SWT.JOIN_MITER;
}
代码示例来源:origin: com.google.code.maven-play-plugin.org.xhtmlrenderer/core-renderer
private void init() {
_instance_hash = new HashMap();
// system fonts
String system_font_family = _device.getSystemFont().getFontData()[0].getName();
_default_fonts = new HashMap();
// system font is likely to be a good default sans serif font
_default_fonts.put("sans-serif", system_font_family);
for (int i = 0; i < _defaults_serif.length; i++) {
if (_device.getFontList(_defaults_serif[i], true).length > 0) {
_default_fonts.put("serif", _defaults_serif[i]);
break;
}
}
if (_default_fonts.get("serif") == null) {
_default_fonts.put("serif", system_font_family);
}
for (int i = 0; i < _defaults_monospace.length; i++) {
if (_device.getFontList(_defaults_monospace[i], true).length > 0) {
_default_fonts.put("monospace", _defaults_monospace[i]);
break;
}
}
if (_default_fonts.get("monospace") == null) {
_default_fonts.put("monospace", system_font_family);
}
// last resort font
Font systemFont = _device.getSystemFont();
_system_font = new SWTFSFont(systemFont, systemFont.getFontData()[0].getHeight(), true);
}
代码示例来源:origin: de.dentrassi.eclipse.neoscada.chart/org.eclipse.scada.chart.swt
private Font createFont ( final ResourceManager resourceManager )
{
final Font defaultFont = resourceManager.getDevice ().getSystemFont ();
if ( defaultFont == null )
{
return null;
}
final FontData fd[] = FontDescriptor.copy ( defaultFont.getFontData () );
if ( fd == null )
{
return null;
}
for ( final FontData f : fd )
{
if ( this.fontSize > 0 )
{
f.setHeight ( this.fontSize );
}
}
return resourceManager.createFont ( FontDescriptor.createFrom ( fd ) );
}
}
代码示例来源:origin: org.eclipse.neoscada.chart/org.eclipse.scada.chart.swt
private Font createFont ( final ResourceManager resourceManager )
{
final Font defaultFont = resourceManager.getDevice ().getSystemFont ();
if ( defaultFont == null )
{
return null;
}
final FontData fd[] = FontDescriptor.copy ( defaultFont.getFontData () );
if ( fd == null )
{
return null;
}
for ( final FontData f : fd )
{
if ( this.fontSize > 0 )
{
f.setHeight ( this.fontSize );
}
}
return resourceManager.createFont ( FontDescriptor.createFrom ( fd ) );
}
}
代码示例来源:origin: org.eclipse.scout.sdk.deps/org.eclipse.swt.win32.win32.x86
systemFont = getSystemFont();
代码示例来源:origin: org.eclipse.platform/org.eclipse.swt.examples
@Override
public void paint(GC gc, int width, int height) {
if (!example.checkAdvancedGraphics()) return;
Device device = gc.getDevice();
if (image == null) {
image = example.loadImage(device, "irmaos.jpg");
Rectangle rect = image.getBounds();
FontData fd = device.getSystemFont().getFontData()[0];
font = new Font(device, fd.getName(), rect.height / 4, SWT.BOLD);
gc.setFont(font);
Point size = gc.stringExtent(text);
textWidth = size.x;
textHeight = size.y;
}
Path path = new Path(device);
path.addString(text, x, y, font);
gc.setClipping(path);
Rectangle rect = image.getBounds();
gc.drawImage(image, 0, 0, rect.width, rect.height, 0, 0, width, height);
gc.setClipping((Rectangle)null);
gc.setForeground(device.getSystemColor(SWT.COLOR_BLUE));
gc.drawPath(path);
path.dispose();
}
}
内容来源于网络,如有侵权,请联系作者删除!