Java Code Examples for org.eclipse.swt.graphics.FontData#setHeight()
The following examples show how to use
org.eclipse.swt.graphics.FontData#setHeight() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CDateTimePropertyHandler.java From nebula with Eclipse Public License 2.0 | 6 votes |
private void applyCSSPropertySize(final Control widget, final CSSValue value, final boolean picker) throws Exception { if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { final FontData fd = CSSEngineHelper.getFontData(widget); final Measure m = (Measure) value; final int newSize = Math.round(m.getFloatValue((short) 0)); final boolean modified = fd.getHeight() != newSize; if (modified) { fd.setHeight(newSize); if (picker) { applyFontForPicker((CDateTime) widget, fd); } else { applyFont(widget, fd); } } } }
Example 2
Source File: Utils.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * Takes a font and gives it the typeface of the given style. * * @param font Font to modify * @param style the new style for the given font (e.g. SWT.BOLD|SWT.ITALIC) * @param size New font size * @return Font with the given typeface and size */ public static Font applyFontData(final Font font, int style, int size) { if (font == null) { return null; } final FontData[] fontDataArray = font.getFontData(); if (fontDataArray == null) { return null; } for (int index = 0; index < fontDataArray.length; index++) { final FontData fData = fontDataArray[index]; fData.setStyle(style); fData.setHeight(size); } return new Font(Display.getDefault(), fontDataArray); }
Example 3
Source File: Utils.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * Applies a certain font size to a font. * * @param font Font to modify * @param size New font size * @return Font with new font size */ public static Font applyFontSize(final Font font, final int size) { if (font == null) { return null; } final FontData[] fontDataArray = font.getFontData(); if (fontDataArray == null) { return null; } for (int index = 0; index < fontDataArray.length; index++) { final FontData fData = fontDataArray[index]; fData.setHeight(size); } return new Font(Display.getDefault(), fontDataArray); }
Example 4
Source File: FontAwesome.java From nebula with Eclipse Public License 2.0 | 6 votes |
/** * Return a FontAwesome font for SWT. * * @param size * @return */ public static Font getFont(int size) { if (!fonts.containsKey(size)) { // GetFont() may return null, so handle this case. Font font = getFont(); if (font == null) { return null; } FontData[] data = font.getFontData(); for (FontData d : data) { d.setHeight(size); } fonts.put(size, new Font(Display.getDefault(), data)); } return fonts.get(size); }
Example 5
Source File: TitleRenderer.java From neoscada with Eclipse Public License 1.0 | 6 votes |
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 ) ); }
Example 6
Source File: MultilineButton.java From SWET with MIT License | 6 votes |
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)); }
Example 7
Source File: ThemeUIComposite.java From APICloud-Studio with GNU General Public License v3.0 | 6 votes |
private void setDefaultFont(Font newFont) { String[] fontIds = { "org.eclipse.jface.textfont", "org.eclipse.ui.workbench.texteditor.blockSelectionModeFont" }; FontData[] newData = newFont.getFontData(); for (String fontId : fontIds) { setFont(fontId, newData); } newData = newFont.getFontData(); FontData[] smaller = new FontData[newData.length]; int j = 0; for (FontData fd : newData) { int height = fd.getHeight(); if (height >= 12) { fd.setHeight(height - 2); } else if (height >= 10) { fd.setHeight(height - 1); } smaller[(j++)] = fd; } setFont("com.aptana.explorer.font", smaller); }
Example 8
Source File: HierarchyWizardEditorRenderer.java From arx with Apache License 2.0 | 5 votes |
/** * Returns the font. * * @return */ private static Font getFont(){ FontData fontdata = GUIHelper.DEFAULT_FONT.getFontData()[0]; fontdata.setHeight(9); return GUIHelper.getFont(fontdata); }
Example 9
Source File: GridPropertyHandler.java From nebula with Eclipse Public License 2.0 | 5 votes |
private boolean applyCSSPropertySize(final Object element, final Grid grid, final CSSValue value, String target) throws Exception { if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { final FontData fd = CSSEngineHelper.getFontData(grid); final Measure m = (Measure) value; final int newSize = Math.round(m.getFloatValue((short) 0)); final boolean modified = fd.getHeight() != newSize; if (modified) { fd.setHeight(newSize); applyFont(grid, fd, target); } } return true; }
Example 10
Source File: GeneralPage.java From birt with Eclipse Public License 1.0 | 5 votes |
public void refresh( ) { if ( input instanceof List && DEUtil.getMultiSelectionHandle( (List) input ) .isExtendedElements( ) ) { librarySection.setHidden( false ); if ( hasLocalProperties( ) ) { noteSection.setHidden( false ); Font font = JFaceResources.getDialogFont( ); FontData fData = font.getFontData( )[0]; fData.setHeight( fData.getHeight( ) - 1 ); noteSection.getTextControl( ) .setFont( FontManager.getFont( fData ) ); } else noteSection.setHidden( true ); seperatorSection.setHidden( false ); librarySection.load( ); } else { librarySection.setHidden( true ); noteSection.setHidden( true ); seperatorSection.setHidden( true ); } super.refresh( ); container.layout( true ); container.redraw( ); }
Example 11
Source File: Activator.java From tmxeditor8 with GNU General Public License v2.0 | 5 votes |
public void start(BundleContext context) throws Exception { super.start(context); plugin = this; String fontName = getPreferenceStore().getString(IPreferenceConstants.TMX_EDITOR_FONT_NAME); int size = getPreferenceStore().getInt(IPreferenceConstants.TMX_EDITOR_FONT_SIZE); FontData fontData = new FontData(); fontData.setHeight(size); fontData.setName(fontName); JFaceResources.getFontRegistry().put(Constants.TMX_EDITOR_TEXT_FONT, new FontData[]{fontData}); System.setProperty("user.name", getPreferenceStore().getString(IPreferenceConstants.SYSTEM_USER)); }
Example 12
Source File: SWTUtils.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * Returns a version of the specified FontData, resized by the requested size. * * @param fontData * the font-data to resize * @param size * the font size * @return resized font data */ public static FontData[] resizeFont(FontData[] fontData, int size) { for (FontData data : fontData) { data.setHeight(data.getHeight() + size); } return fontData; }
Example 13
Source File: SWTUtils.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
/** * Returns a version of the specified font, resized by the requested size. * * @param font * the font to resize * @param size * the font size * @return resized font data */ public static FontData[] resizeFont(Font font, int size) { FontData[] datas = font.getFontData(); for (FontData data : datas) { data.setHeight(data.getHeight() + size); } return datas; }
Example 14
Source File: ThemePreferencePage.java From APICloud-Studio with GNU General Public License v3.0 | 5 votes |
protected void performOkFonts() { final String[] fontIds = new String[] { JFaceResources.TEXT_FONT, "org.eclipse.ui.workbench.texteditor.blockSelectionModeFont" }; //$NON-NLS-1$ FontData[] data = fFont.getFontData(); for (String fontId : fontIds) { setFont(fontId, data); } // Shrink by 2 for views! data = fFont.getFontData(); FontData[] smaller = new FontData[data.length]; int i = 0; for (FontData fd : data) { int height = fd.getHeight(); if (height >= 12) { fd.setHeight(height - 2); } else if (height >= 10) { fd.setHeight(height - 1); } smaller[i++] = fd; } setFont(IThemeManager.VIEW_FONT_NAME, smaller); }
Example 15
Source File: EditboxPreferencePage.java From gama with GNU General Public License v3.0 | 5 votes |
@Override protected Control createContents(final Composite parent) { noDefaultAndApplyButton(); final Composite c = new Composite(parent, SWT.NONE); c.setLayout(new GridLayout(1, false)); final Link link = new Link(c, SWT.NONE); link.setText("Turn off current line highlighting <A>here</A>."); final FontData[] fontData = link.getFont().getFontData(); for (final FontData fd : fontData) { fd.setHeight(10); fd.setStyle(SWT.BOLD); } link.setFont(new Font(getShell().getDisplay(), fontData)); link.addSelectionListener(new SelectionAdapter() { @Override public void widgetSelected(final SelectionEvent e) { final IWorkbenchPreferenceContainer container = (IWorkbenchPreferenceContainer) getContainer(); container.openPage("org.eclipse.ui.preferencePages.GeneralTextEditor", null); } }); folder = new TabFolder(c, SWT.NONE); folder.setLayoutData(new GridData(GridData.FILL_BOTH)); final TabItem ti = new TabItem(folder, SWT.NONE); ti.setText("Themes"); ti.setControl(createCategoryControl(folder)); folder.pack(); return c; }
Example 16
Source File: TableComboPropertyHandler.java From nebula with Eclipse Public License 2.0 | 5 votes |
private boolean applyCSSPropertySize(final Object element, final Control widget, final CSSValue value) throws Exception { if (value.getCssValueType() == CSSValue.CSS_PRIMITIVE_VALUE) { final FontData fd = CSSEngineHelper.getFontData(widget); final Measure m = (Measure) value; final int newSize = Math.round(m.getFloatValue((short) 0)); final boolean modified = fd.getHeight() != newSize; if (modified) { fd.setHeight(newSize); applyFont(widget, fd); } } return true; }
Example 17
Source File: ResourceHelper.java From nebula with Eclipse Public License 2.0 | 5 votes |
public static Font getFont(Font currentFont, String name, Integer size) { FontData[] original = currentFont.getFontData(); FontData[] fontData = Arrays.copyOf(original, original.length); for (FontData data : fontData) { if (name != null) { data.setName(name); } if (size != null) { data.setHeight(size); } } return getFont(fontData); }