private void setHelpLink( Display display, String helpLink, int maxTextWidth, EnvironmentCase environment ) { link = new Link( shell, SWT.SINGLE | SWT.WRAP ); link.setText( helpLink ); if ( environment == EnvironmentCase.MAC_OS_X || environment == EnvironmentCase.MAC_OS_X_THIN ) { FontData[] fD = link.getFont().getFontData(); fD[0].setHeight( 13 ); link.setFont( new Font( display, fD[0] ) ); } FormData fdlink = new FormData(); fdlink.left = new FormAttachment( warningIcon, margin ); // Link should be below description right of icon fdlink.top = new FormAttachment( description, margin ); fdlink.width = maxTextWidth; link.setLayoutData( fdlink ); props.setLook( link ); link.addListener( SWT.Selection, new Listener() { public void handleEvent( Event event ) { if ( Desktop.isDesktopSupported() ) { try { Desktop.getDesktop().browse( new URI( Const.getDocUrl( URI_PATH ) ) ); } catch ( Exception e ) { log.logError( "Error opening external browser", e ); } } } } ); }
public static void setFontDataHeight(FontData[] fd, float fontSize) { if (mFontData_SetHeight != null) { try { mFontData_SetHeight.invoke(fd[0], fontSize); return; } catch (Throwable ignore) { } } fd[0].setHeight((int) fontSize); }
public Font loadDigitalFont(int policeSize) { URL fontFile = YouClassName.class .getResource("/fonts/DS-DIGI.TTF"); boolean isLoaded = Display.getCurrent().loadFont(fontFile.getPath()); if (isLoaded) { FontData[] fd = Display.getCurrent().getFontList(null, true); FontData fontdata = null; for (int i = 0; i < fd.length; i++) { if (fd[i].getName().equals("DS-Digital")) { fontdata = fd[i]; break; }} if (fontdata != null) { fontdata.setHeight(policeSize); fontdata.setStyle(SWT.BOLD);return new Font(getDisplay(), fontdata));} }return null; }
/*public*/ FontData(String name, float height, int style) { setName(name); setHeight(height); setStyle(style); }
/*public*/ FontData(String name, float height, int style) { setName(name); setHeight(height); setStyle(style); }
/*public*/ FontData(String name, float height, int style) { setName(name); setHeight(height); setStyle(style); }
/*public*/ FontData(String name, float height, int style) { setName(name); setHeight(height); setStyle(style); }
/** * Constructs a new font data given a font name, * the height of the desired font in points, * and a font style. * * @param name the name of the font (must not be null) * @param height the font height in points * @param style a bit or combination of NORMAL, BOLD, ITALIC * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - when the font name is null</li> * <li>ERROR_INVALID_ARGUMENT - if the height is negative</li> * </ul> */ public FontData(String name, int height, int style) { setName(name); setHeight(height); setStyle(style); }
/** * Constructs a new font data given a font name, * the height of the desired font in points, * and a font style. * * @param name the name of the font (must not be null) * @param height the font height in points * @param style a bit or combination of NORMAL, BOLD, ITALIC * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - when the font name is null</li> * <li>ERROR_INVALID_ARGUMENT - if the height is negative</li> * </ul> */ public FontData(String name, int height, int style) { setName(name); setHeight(height); setStyle(style); }
/** * Constructs a new font data given a font name, * the height of the desired font in points, * and a font style. * * @param name the name of the font (must not be null) * @param height the font height in points * @param style a bit or combination of NORMAL, BOLD, ITALIC * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - when the font name is null</li> * <li>ERROR_INVALID_ARGUMENT - if the height is negative</li> * </ul> */ public FontData(String name, int height, int style) { setName(name); setHeight(height); setStyle(style); }
/** * Constructs a new font data given a font name, * the height of the desired font in points, * and a font style. * * @param name the name of the font (must not be null) * @param height the font height in points * @param style a bit or combination of NORMAL, BOLD, ITALIC * * @exception IllegalArgumentException <ul> * <li>ERROR_NULL_ARGUMENT - when the font name is null</li> * <li>ERROR_INVALID_ARGUMENT - if the height is negative</li> * </ul> */ public FontData(String name, int height, int style) { setName(name); setHeight(height); setStyle(style); }
private static Font createCodeFont(Display display, Font regularFont, Font textFont) { FontData[] rfontData = regularFont.getFontData(); FontData[] tfontData = textFont.getFontData(); int height = 0; for (int i=0; i<rfontData.length; i++) { FontData data = rfontData[i]; height = Math.max(height, data.getHeight()); } for (int i = 0; i < tfontData.length; i++) { tfontData[i].setHeight(height); } return new Font(display, tfontData); }
private void createStatusLabel(final String statusFieldText, Color foreground, Color background) { fStatusLabel= new Label(fStatusComposite, SWT.RIGHT); fStatusLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); fStatusLabel.setText(statusFieldText); FontData[] fontDatas= JFaceResources.getDialogFont().getFontData(); for (FontData fontData : fontDatas) { fontData.setHeight(fontData.getHeight() * 9 / 10); } fStatusLabelFont= new Font(fStatusLabel.getDisplay(), fontDatas); fStatusLabel.setFont(fStatusLabelFont); setStatusLabelColors(foreground, background); setColor(fStatusComposite, foreground, background); }
/*public*/ FontData(String name, float height, int style) { if (name == null) SWT.error(SWT.ERROR_NULL_ARGUMENT); data = OS.IsUnicode ? (LOGFONT)new LOGFONTW() : new LOGFONTA(); setName(name); setHeight(height); setStyle(style); // We set the charset field so that // wildcard searching will work properly // out of the box data.lfCharSet = (byte)OS.DEFAULT_CHARSET; }
private void createStatusLabel(final String statusFieldText, Color foreground, Color background) { fStatusLabel= new Label(fStatusComposite, SWT.RIGHT); fStatusLabel.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false)); fStatusLabel.setText(statusFieldText); FontData[] fontDatas= JFaceResources.getDialogFont().getFontData(); for (int i= 0; i < fontDatas.length; i++) { fontDatas[i].setHeight(fontDatas[i].getHeight() * 9 / 10); } fStatusLabelFont= new Font(fStatusLabel.getDisplay(), fontDatas); fStatusLabel.setFont(fStatusLabelFont); fStatusLabelForeground= new Color(fStatusLabel.getDisplay(), Colors.blend(background.getRGB(), foreground.getRGB(), 0.56f)); setColor(fStatusLabel, fStatusLabelForeground, background); setColor(fStatusComposite, foreground, background); }
private FontData[] applyFontState(FontState fontState, FontData[] fontData) { boolean bold = fontState.isBold(); boolean italics = fontState.isItalic(); int fontHeight = computeFontHeight(fontState); for (FontData data : fontData) { data.setHeight(fontHeight); int style = data.getStyle(); if (bold) { style |= SWT.BOLD; } if (italics) { style |= SWT.ITALIC; } data.setStyle(style); } return fontData; }
protected void applyFonts(final Composite composite) { Dialog.applyDialogFont(composite); if (info != null) { final Font font = info.getFont(); final FontData[] fontDatas = font.getFontData(); for (int i = 0; i < fontDatas.length; i++) { fontDatas[i].setHeight(fontDatas[i].getHeight() * 9 / 10); } infoFont = new Font(info.getDisplay(), fontDatas); info.setFont(infoFont); } }
@Override public Font getFont(Object element) { Display display = tree.getDisplay(); if (element instanceof FontDefinition) { int parentHeight = tree.getViewer().getControl().getFont() .getFontData()[0].getHeight(); Font baseFont = fontRegistry.get(((FontDefinition) element) .getId()); Font font = (Font) fonts.get(baseFont); if (font == null) { FontData[] data = baseFont.getFontData(); for (FontData fontData : data) { fontData.setHeight(parentHeight); } font = new Font(display, data); fonts.put(baseFont, font); } return font; } return JFaceResources.getDialogFont(); }
/** * Configures big font for this. * @param c the control to increase font for. Not <code>null</code>. */ private void configureBigFont(final Control c) { final FontData[] fontData = c.getFont().getFontData(); for (int i = 0; i < fontData.length; i++) { fontData[i].setHeight(fontData[i].getHeight() * FONT_INCREASE_MULT); } final Font newFont = new Font(getDisplay(), fontData); c.setFont(newFont); c.addDisposeListener(new DestroyFontDisposeListener(newFont)); }
protected static Font setHeaderFontSizeAndStyle(Control text) { float sizeFactor = 1.2f; Font initialFont = text.getFont(); FontData[] fontData = initialFont.getFontData(); for (FontData element : fontData) { element.setHeight((int) (element.getHeight() * sizeFactor)); element.setStyle(element.getStyle() | SWT.BOLD); } final Font textFont = new Font(text.getDisplay(), fontData); text.setFont(textFont); text.addDisposeListener(new DisposeListener() { public void widgetDisposed(DisposeEvent e) { textFont.dispose(); } }); Color color = CommonsWorkbenchPlugin.getDefault().getFormColors(text.getDisplay()).getColor(IFormColors.TITLE); text.setForeground(color); return textFont; }