/** * Dispose all of the cached {@link Font}'s. */ public static void disposeFonts() { // clear fonts for (Font font : m_fontMap.values()) { font.dispose(); } m_fontMap.clear(); // clear bold fonts for (Font font : m_fontToBoldFontMap.values()) { font.dispose(); } m_fontToBoldFontMap.clear(); } ////////////////////////////////////////////////////////////////////////////
/** * Free the managed resource if it hasn't already been done and if this is not a system font * */ public void dispose() { // System color and already disposed off colors don't need to be disposed! if ( !systemFont && !font.isDisposed() ) { font.dispose(); } }
@Override public void widgetDisposed( DisposeEvent e ) { if ( clipboard != null ) { clipboard.dispose(); clipboard = null; } if ( gridFont != null ) { gridFont.dispose(); } } } );
public void setFont( String fontName, int fontSize, boolean fontBold, boolean fontItalic ) { int swt = SWT.NORMAL; if ( fontBold ) { swt = SWT.BOLD; } if ( fontItalic ) { swt = swt | SWT.ITALIC; } Font font = new Font( PropsUI.getDisplay(), fontName, fontSize, swt ); int index = fonts.indexOf( font ); if ( index < 0 ) { fonts.add( font ); } else { font.dispose(); font = fonts.get( index ); } gc.setFont( font ); }
public void setFont( String fontName, int fontSize, boolean fontBold, boolean fontItalic ) { int swt = SWT.NORMAL; if ( fontBold ) { swt = SWT.BOLD; } if ( fontItalic ) { swt = swt | SWT.ITALIC; } Font font = new Font( PropsUI.getDisplay(), fontName, fontSize, swt ); int index = fonts.indexOf( font ); if ( index < 0 ) { fonts.add( font ); } else { font.dispose(); font = fonts.get( index ); } gc.setFont( font ); }
public void widgetSelected( SelectionEvent arg0 ) { graphFont.dispose(); graphFontData = props.getDefaultFontData(); graphFont = new Font( display, graphFontData ); wGFont.redraw(); } } );
public void widgetSelected( SelectionEvent arg0 ) { noteFontData = props.getDefaultFontData(); noteFont.dispose(); noteFont = new Font( display, noteFontData ); wNFont.redraw(); } } );
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() ); } }
public void dispose() { gc.dispose(); if ( transform != null && transform.isDisposed() == false ) { transform.dispose(); } for ( Color color : colors ) { color.dispose(); } for ( Font font : fonts ) { font.dispose(); } }
public void dispose() { gc.dispose(); if ( transform != null && transform.isDisposed() == false ) { transform.dispose(); } for ( Color color : colors ) { color.dispose(); } for ( Font font : fonts ) { font.dispose(); } }
public void widgetSelected( SelectionEvent arg0 ) { FontDialog fd = new FontDialog( shell ); fd.setFontList( new FontData[] { fixedFontData } ); FontData newfd = fd.open(); if ( newfd != null ) { fixedFontData = newfd; fixedFont.dispose(); fixedFont = new Font( display, fixedFontData ); wFFont.redraw(); } } } );
public void widgetSelected( SelectionEvent arg0 ) { FontDialog fd = new FontDialog( shell ); fd.setFontList( new FontData[] { graphFontData } ); FontData newfd = fd.open(); if ( newfd != null ) { graphFontData = newfd; graphFont.dispose(); graphFont = new Font( display, graphFontData ); wGFont.redraw(); } } } );
public void widgetSelected( SelectionEvent arg0 ) { FontDialog fd = new FontDialog( shell ); fd.setFontList( new FontData[] { noteFontData } ); FontData newfd = fd.open(); if ( newfd != null ) { noteFontData = newfd; noteFont.dispose(); noteFont = new Font( display, noteFontData ); wNFont.redraw(); } } } );
private void refreshTextNote() { int swt = SWT.NORMAL; if ( wFontBold.getSelection() ) { swt = SWT.BOLD; } if ( wFontItalic.getSelection() ) { swt = swt | SWT.ITALIC; } // dispose of old font only after setting it on wDesc Font oldFont = font; font = new Font( shell.getDisplay(), wFontName.getText(), wFontSize.getSelection(), swt ); wDesc.setFont( font ); if ( oldFont != null && !oldFont.isDisposed() ) { oldFont.dispose(); } for ( Control control : wDesc.getChildren() ) { control.setBackground( bgColor ); } wFontColor.setBackground( fontColor ); wBackGroundColor.setBackground( bgColor ); wBorderColor.setBackground( borderColor ); } }
public void dispose() { props.setScreen( new WindowProperty( shell ) ); fontColor.dispose(); bgColor.dispose(); borderColor.dispose(); if ( font != null && !font.isDisposed() ) { font.dispose(); } shell.dispose(); }
licFontSize--; if ( licFont != null ) { licFont.dispose();
public void widgetSelected( SelectionEvent arg0 ) { fixedFontData = new FontData( PropsUI.getInstance().getFixedFont().getName(), PropsUI.getInstance().getFixedFont().getHeight(), PropsUI.getInstance().getFixedFont().getStyle() ); fixedFont.dispose(); fixedFont = new Font( display, fixedFontData ); wFFont.redraw(); } } );
Display display = new Display(); Shell shell = new Shell(display); shell.setLayout(new GridLayout()); Label label = new Label(shell, SWT.NONE); label.setText("I am italic"); FontData fontData = label.getFont().getFontData()[0]; Font font = new Font(display, new FontData(fontData.getName(), fontData .getHeight(), SWT.ITALIC)); label.setFont(font); shell.open(); while (!shell.isDisposed()) { if (!display.readAndDispatch()) display.sleep(); } font.dispose(); display.dispose();