当前位置: 首页>>代码示例>>Java>>正文


Java FontData.setName方法代码示例

本文整理汇总了Java中org.eclipse.swt.graphics.FontData.setName方法的典型用法代码示例。如果您正苦于以下问题:Java FontData.setName方法的具体用法?Java FontData.setName怎么用?Java FontData.setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.eclipse.swt.graphics.FontData的用法示例。


在下文中一共展示了FontData.setName方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setFontFromSettings

import org.eclipse.swt.graphics.FontData; //导入方法依赖的package包/类
private void setFontFromSettings() {
		if (false)
			return;
		
		FontData fd = new FontData();
		
		logger.debug("settings font name: '"+settings.getTranscriptionFontName()
				+"', size:  "+settings.getTranscriptionFontSize()+", style: "+settings.getTranscriptionFontStyle());
		
//		fd.setName(Fonts.getSystemFontName(false, false, false));
//		if (settings.getTranscriptionFontName()==null || settings.getTranscriptionFontName().isEmpty()) {
//			fd.setName(Fonts.getSystemFontName(false, false, false));	
//		} else
//			fd.setName(settings.getTranscriptionFontName());
		
		fd.setName(settings.getTranscriptionFontName());
		fd.setHeight(settings.getTranscriptionFontSize());
		fd.setStyle(settings.getTranscriptionFontStyle());
		
		logger.debug("font name = "+fd.getName());
		
		Font globalTextFont = Fonts.createFont(fd);
		text.setFont(globalTextFont);
	}
 
开发者ID:Transkribus,项目名称:TranskribusSwtGui,代码行数:25,代码来源:ATranscriptionWidget.java

示例2: XYZDisplayComp

import org.eclipse.swt.graphics.FontData; //导入方法依赖的package包/类
public XYZDisplayComp(Composite parent, int style){
	super(parent, style);
	
	this.setLayout(new RowLayout(SWT.HORIZONTAL));
	this.setBackground(AvoColors.COLOR_QSET_BG);
	
	FontData fd = new FontData();
	fd.setHeight(10);
	fd.setStyle(SWT.BOLD);
	fd.setName("Verdana");
	Font f = new Font(this.getDisplay(), fd);		
	
	Label llx = new Label(this, SWT.NO_BACKGROUND);
	llx.setFont(f);
	llx.setText("X:");
	llx.setBackground(AvoColors.COLOR_QSET_BG);
	lX = new Label(this, SWT.NONE);	
	lX.setAlignment(SWT.RIGHT);
	lX.setFont(f);
	lX.setBackground(AvoColors.COLOR_QSET_BG);
	
	Label lly = new Label(this, SWT.NONE);
	lly.setFont(f);
	lly.setText(" Y:");
	lly.setBackground(AvoColors.COLOR_QSET_BG);
	lY = new Label(this, SWT.NONE);
	lY.setAlignment(SWT.RIGHT);
	lY.setFont(f);
	lY.setBackground(AvoColors.COLOR_QSET_BG);
	
	Label llz = new Label(this, SWT.NONE);
	llz.setFont(f);
	llz.setText(" Z:");
	llz.setBackground(AvoColors.COLOR_QSET_BG);
	lZ = new Label(this, SWT.NONE);
	lZ.setAlignment(SWT.RIGHT);
	lZ.setFont(f);
	lZ.setBackground(AvoColors.COLOR_QSET_BG);
	
	updateXYZ();
	
	AvoGlobal.glViewEventHandler.addGLViewListener(new GLViewListener(){
		@Override
		public void cursorMoved() {
			updateXYZ();
		}			
	});
}
 
开发者ID:avoCADo-3d,项目名称:avoCADo,代码行数:49,代码来源:XYZDisplayComp.java

示例3: toSwtFontData

import org.eclipse.swt.graphics.FontData; //导入方法依赖的package包/类
/**
 * Create a <code>FontData</code> object which encapsulate
 * the essential data to create a swt font. The data is taken
 * from the provided awt Font.
 * <p>Generally speaking, given a font size, the returned swt font
 * will display differently on the screen than the awt one.
 * Because the SWT toolkit use native graphical resources whenever
 * it is possible, this fact is platform dependent. To address
 * this issue, it is possible to enforce the method to return
 * a font with the same size (or at least as close as possible)
 * as the awt one.
 * <p>When the object is no more used, the user must explicitly
 * call the dispose method on the returned font to free the
 * operating system resources (the garbage collector won't do it).
 *
 * @param device The swt device to draw on (display or gc device).
 * @param font The awt font from which to get the data.
 * @param ensureSameSize A boolean used to enforce the same size
 * (in pixels) between the awt font and the newly created swt font.
 * @return a <code>FontData</code> object.
 */
public static FontData toSwtFontData(Device device, java.awt.Font font,
        boolean ensureSameSize) {
    FontData fontData = new FontData();
    fontData.setName(font.getFamily());
    // SWT and AWT share the same style constants.
    fontData.setStyle(font.getStyle());
    // convert the font size (in pt for awt) to height in pixels for swt
    int height = (int) Math.round(font.getSize() * 72.0
            / device.getDPI().y);
    fontData.setHeight(height);
    // hack to ensure the newly created swt fonts will be rendered with the
    // same height as the awt one
    if (ensureSameSize) {
        GC tmpGC = new GC(device);
        Font tmpFont = new Font(device, fontData);
        tmpGC.setFont(tmpFont);
        if (tmpGC.textExtent(Az).x
                > DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) {
            while (tmpGC.textExtent(Az).x
                    > DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) {
                tmpFont.dispose();
                height--;
                fontData.setHeight(height);
                tmpFont = new Font(device, fontData);
                tmpGC.setFont(tmpFont);
            }
        }
        else if (tmpGC.textExtent(Az).x
                < DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) {
            while (tmpGC.textExtent(Az).x
                    < DUMMY_PANEL.getFontMetrics(font).stringWidth(Az)) {
                tmpFont.dispose();
                height++;
                fontData.setHeight(height);
                tmpFont = new Font(device, fontData);
                tmpGC.setFont(tmpFont);
            }
        }
        tmpFont.dispose();
        tmpGC.dispose();
    }
    return fontData;
}
 
开发者ID:mdzio,项目名称:ccu-historian,代码行数:65,代码来源:SWTUtils.java

示例4: copyFontData

import org.eclipse.swt.graphics.FontData; //导入方法依赖的package包/类
protected void copyFontData(FontData src, FontData dst){
	dst.setName( src.getName() );
	dst.setStyle( src.getStyle() );
	dst.setHeight( src.getHeight() );
}
 
开发者ID:theokyr,项目名称:TuxGuitar-1.3.1-fork,代码行数:6,代码来源:StylesOption.java


注:本文中的org.eclipse.swt.graphics.FontData.setName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。