javax.swing.plaf.FontUIResource Java Examples
The following examples show how to use
javax.swing.plaf.FontUIResource.
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: X11FontManager.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Override protected FontUIResource getFontConfigFUIR(String family, int style, int size) { CompositeFont font2D = getFontConfigManager().getFontConfigFont(family, style); if (font2D == null) { // Not expected, just a precaution. return new FontUIResource(family, style, size); } /* The name of the font will be that of the physical font in slot, * but by setting the handle to that of the CompositeFont it * renders as that CompositeFont. * It also needs to be marked as a created font which is the * current mechanism to signal that deriveFont etc must copy * the handle from the original font. */ FontUIResource fuir = new FontUIResource(font2D.getFamilyName(null), style, size); FontAccess.getFontAccess().setFont2D(fuir, font2D.handle); FontAccess.getFontAccess().setCreatedFont(fuir); return fuir; }
Example #2
Source File: X11FontManager.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
@Override protected FontUIResource getFontConfigFUIR(String family, int style, int size) { CompositeFont font2D = getFontConfigManager().getFontConfigFont(family, style); if (font2D == null) { // Not expected, just a precaution. return new FontUIResource(family, style, size); } /* The name of the font will be that of the physical font in slot, * but by setting the handle to that of the CompositeFont it * renders as that CompositeFont. * It also needs to be marked as a created font which is the * current mechanism to signal that deriveFont etc must copy * the handle from the original font. */ FontUIResource fuir = new FontUIResource(font2D.getFamilyName(null), style, size); FontAccess.getFontAccess().setFont2D(fuir, font2D.handle); FontAccess.getFontAccess().setCreatedFont(fuir); return fuir; }
Example #3
Source File: NeonFontSet.java From radiance with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * Returns Neon-specific font resource. * * @param systemFont The default system font. * @param toBoldify If <code>true</code>, the original font (the first parameter) is * boldified. * @param extraFontSize Extra font size in pixels. * @return Neon-specific font resource. */ private FontUIResource getNeonFont(FontUIResource systemFont, boolean toBoldify, int extraFontSize) { boolean isOrigItalic = systemFont.isItalic(); int newStyle = systemFont.getStyle(); if (toBoldify) { if (isOrigItalic) { newStyle = Font.ITALIC + Font.BOLD; } else { newStyle = Font.BOLD; } } Font derived = systemFont.deriveFont((float) (systemFont.getSize() + extraFontSize)) .deriveFont(newStyle); if (derived instanceof FontUIResource) { return (FontUIResource) derived; } return new FontUIResource(derived); }
Example #4
Source File: X11FontManager.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
@Override protected FontUIResource getFontConfigFUIR(String family, int style, int size) { CompositeFont font2D = getFontConfigManager().getFontConfigFont(family, style); if (font2D == null) { // Not expected, just a precaution. return new FontUIResource(family, style, size); } /* The name of the font will be that of the physical font in slot, * but by setting the handle to that of the CompositeFont it * renders as that CompositeFont. * It also needs to be marked as a created font which is the * current mechanism to signal that deriveFont etc must copy * the handle from the original font. */ FontUIResource fuir = new FontUIResource(font2D.getFamilyName(null), style, size); FontAccess.getFontAccess().setFont2D(fuir, font2D.handle); FontAccess.getFontAccess().setCreatedFont(fuir); return fuir; }
Example #5
Source File: FlatLaf.java From FlatLaf with Apache License 2.0 | 6 votes |
@Override public Object createValue( UIDefaults table ) { Font defaultFont = UIManager.getFont( "defaultFont" ); if( lastDefaultFont != defaultFont ) { lastDefaultFont = defaultFont; if( scaleFactor != 1 ) { // scale font int newFontSize = Math.round( defaultFont.getSize() * scaleFactor ); font = new FontUIResource( defaultFont.deriveFont( (float) newFontSize ) ); } else { // make sure that font is a UIResource for LaF switching font = (defaultFont instanceof UIResource) ? defaultFont : new FontUIResource( defaultFont ); } } return font; }
Example #6
Source File: X11FontManager.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
@Override protected FontUIResource getFontConfigFUIR(String family, int style, int size) { CompositeFont font2D = getFontConfigManager().getFontConfigFont(family, style); if (font2D == null) { // Not expected, just a precaution. return new FontUIResource(family, style, size); } /* The name of the font will be that of the physical font in slot, * but by setting the handle to that of the CompositeFont it * renders as that CompositeFont. * It also needs to be marked as a created font which is the * current mechanism to signal that deriveFont etc must copy * the handle from the original font. */ FontUIResource fuir = new FontUIResource(font2D.getFamilyName(null), style, size); FontAccess.getFontAccess().setFont2D(fuir, font2D.handle); FontAccess.getFontAccess().setCreatedFont(fuir); return fuir; }
Example #7
Source File: OpenStegoFrame.java From openstego with GNU General Public License v2.0 | 6 votes |
/** * This method initializes the UI resources like fonts, size, etc. */ private void setupUI() { // Special handling to ensure that Japanese fonts are readable if (Locale.getDefault().getLanguage().equals(Locale.JAPANESE.getLanguage())) { Object key = null; Object value = null; Enumeration<?> keys = UIManager.getDefaults().keys(); while (keys.hasMoreElements()) { key = keys.nextElement(); value = UIManager.get(key); if (value instanceof FontUIResource) { UIManager.put(key, ((FontUIResource) value).deriveFont(12.0f)); } } getMainContentPane().setFont(new Font("Japanese", Font.PLAIN, 12)); } }
Example #8
Source File: SwingUtil.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
/** * Sets default Swing font. * IMPORTANT! Needs to be called before main frame creation * * @param font the new font to use */ public static void setFont(@Nonnull final Font font) { final FontUIResource f = new FontUIResource(font); final Enumeration keys = UIManager.getDefaults().keys(); while (keys.hasMoreElements()) { final Object key = keys.nextElement(); final Object value = UIManager.get(key); if (value instanceof FontUIResource) { UIManager.put(key, f); } } }
Example #9
Source File: CFontManager.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
@Override protected FontUIResource getFontConfigFUIR( String family, int style, int size) { String mappedName = FontUtilities.mapFcName(family); if (mappedName == null) { mappedName = "sansserif"; } return new FontUIResource(mappedName, style, size); }
Example #10
Source File: javax_swing_plaf_FontUIResource.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
protected FontUIResource getObject() { return new FontUIResource( new Font( Collections.singletonMap( TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON))); }
Example #11
Source File: DefaultSynthStyleFactory.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
/** * Returns the style to use if there are no matching styles. */ private SynthStyle getDefaultStyle() { if (_defaultStyle == null) { _defaultStyle = new DefaultSynthStyle(); ((DefaultSynthStyle)_defaultStyle).setFont( new FontUIResource(Font.DIALOG, Font.PLAIN,12)); } return _defaultStyle; }
Example #12
Source File: DefaultTreeCellEditor.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public Font getFont() { Font font = super.getFont(); // Prefer the parent containers font if our font is a // FontUIResource if(font instanceof FontUIResource) { Container parent = getParent(); if(parent != null && parent.getFont() != null) font = parent.getFont(); } return font; }
Example #13
Source File: DefaultTreeCellEditor.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public Font getFont() { Font font = super.getFont(); // Prefer the parent containers font if our font is a // FontUIResource if(font instanceof FontUIResource) { Container parent = getParent(); if(parent != null && parent.getFont() != null) font = parent.getFont(); } return font; }
Example #14
Source File: javax_swing_plaf_FontUIResource.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
protected FontUIResource getObject() { return new FontUIResource( new Font( Collections.singletonMap( TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON))); }
Example #15
Source File: DefaultSynthStyleFactory.java From jdk8u-jdk with GNU General Public License v2.0 | 5 votes |
/** * Returns the style to use if there are no matching styles. */ private SynthStyle getDefaultStyle() { if (_defaultStyle == null) { _defaultStyle = new DefaultSynthStyle(); ((DefaultSynthStyle)_defaultStyle).setFont( new FontUIResource(Font.DIALOG, Font.PLAIN,12)); } return _defaultStyle; }
Example #16
Source File: GUIUtil.java From mybatis-generator-gui with MIT License | 5 votes |
public static void setFont(Font font) { FontUIResource fontRes = new FontUIResource(font); for (Enumeration<Object> keys = UIManager.getDefaults().keys(); keys.hasMoreElements(); ) { Object key = keys.nextElement(); Object value = UIManager.get(key); if (value instanceof FontUIResource) { UIManager.put(key, fontRes); } } }
Example #17
Source File: EnhancedTreeCellRenderer.java From visualvm with GNU General Public License v2.0 | 5 votes |
/** * Subclassed to map <code>FontUIResource</code>s to null. If * <code>font</code> is null, or a <code>FontUIResource</code>, this * has the effect of letting the font of the JTree show * through. On the other hand, if <code>font</code> is non-null, and not * a <code>FontUIResource</code>, the font becomes <code>font</code>. */ public void setFont(Font font) { if (font instanceof FontUIResource) { font = null; } super.setFont(font); }
Example #18
Source File: DefaultSynthStyleFactory.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
/** * Returns the style to use if there are no matching styles. */ private SynthStyle getDefaultStyle() { if (_defaultStyle == null) { _defaultStyle = new DefaultSynthStyle(); ((DefaultSynthStyle)_defaultStyle).setFont( new FontUIResource(Font.DIALOG, Font.PLAIN,12)); } return _defaultStyle; }
Example #19
Source File: javax_swing_plaf_FontUIResource.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
protected FontUIResource getObject() { return new FontUIResource( new Font( Collections.singletonMap( TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON))); }
Example #20
Source File: DefaultSynthStyleFactory.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * Returns the style to use if there are no matching styles. */ private SynthStyle getDefaultStyle() { if (_defaultStyle == null) { _defaultStyle = new DefaultSynthStyle(); ((DefaultSynthStyle)_defaultStyle).setFont( new FontUIResource(Font.DIALOG, Font.PLAIN,12)); } return _defaultStyle; }
Example #21
Source File: LafManagerImpl.java From consulo with Apache License 2.0 | 5 votes |
public static void installMacOSXFonts(UIDefaults defaults) { final String face = "Helvetica Neue"; final FontUIResource uiFont = getFont(face, 13, Font.PLAIN); initFontDefaults(defaults, uiFont); for (Object key : new HashSet<>(defaults.keySet())) { if (!(key instanceof String)) continue; if (!StringUtil.endsWithIgnoreCase(((String)key), "font")) continue; Object value = defaults.get(key); if (value instanceof FontUIResource) { FontUIResource font = (FontUIResource)value; if (font.getFamily().equals("Lucida Grande") || font.getFamily().equals("Serif")) { if (!key.toString().contains("Menu")) { defaults.put(key, getFont(face, font.getSize(), font.getStyle())); } } } } FontUIResource uiFont11 = getFont(face, 11, Font.PLAIN); defaults.put("TableHeader.font", uiFont11); FontUIResource buttonFont = getFont("Helvetica Neue", 13, Font.PLAIN); defaults.put("Button.font", buttonFont); Font menuFont = getFont("Lucida Grande", 14, Font.PLAIN); defaults.put("Menu.font", menuFont); defaults.put("MenuItem.font", menuFont); defaults.put("MenuItem.acceleratorFont", menuFont); defaults.put("PasswordField.font", defaults.getFont("TextField.font")); }
Example #22
Source File: ModernDarkLaf.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override public UIDefaults getDefaultsImpl(UIDefaults superDefaults) { try { final Method superMethod = BasicLookAndFeel.class.getDeclaredMethod("getDefaults"); superMethod.setAccessible(true); final UIDefaults metalDefaults = (UIDefaults)superMethod.invoke(new MetalLookAndFeel()); final UIDefaults defaults = (UIDefaults)superMethod.invoke(base); if (SystemInfo.isLinux && !Registry.is("darcula.use.native.fonts.on.linux")) { Font font = findFont("DejaVu Sans"); if (font != null) { for (Object key : defaults.keySet()) { if (key instanceof String && ((String)key).endsWith(".font")) { defaults.put(key, new FontUIResource(font.deriveFont(13f))); } } } } LafManagerImplUtil.initInputMapDefaults(defaults); defaults.put(SupportTextBoxWithExpandActionExtender.class, SupportTextBoxWithExpandActionExtender.INSTANCE); defaults.put(SupportTextBoxWithExtensionsExtender.class, SupportTextBoxWithExtensionsExtender.INSTANCE); initIdeaDefaults(defaults); patchStyledEditorKit(defaults); patchComboBox(metalDefaults, defaults); defaults.remove("Spinner.arrowButtonBorder"); defaults.put("Spinner.arrowButtonSize", new Dimension(16, 5)); MetalLookAndFeel.setCurrentTheme(createMetalTheme()); defaults.put("EditorPane.font", defaults.getFont("TextField.font")); return defaults; } catch (Exception e) { log(e); } return super.getDefaultsImpl(superDefaults); }
Example #23
Source File: CFontManager.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@Override protected FontUIResource getFontConfigFUIR( String family, int style, int size) { String mappedName = FontUtilities.mapFcName(family); if (mappedName == null) { mappedName = "sansserif"; } return new FontUIResource(mappedName, style, size); }
Example #24
Source File: Main.java From FCMFrame with Apache License 2.0 | 5 votes |
public static void initGlobalFontSetting(Font fnt) { FontUIResource fontRes = new FontUIResource(fnt); for (Enumeration<?> keys = UIManager.getDefaults().keys(); keys.hasMoreElements(); ) { Object key = keys.nextElement(); Object value = UIManager.get(key); if (value instanceof FontUIResource) { UIManager.put(key, fontRes); } } }
Example #25
Source File: DefaultSynthStyleFactory.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** * Returns the style to use if there are no matching styles. */ private SynthStyle getDefaultStyle() { if (_defaultStyle == null) { _defaultStyle = new DefaultSynthStyle(); ((DefaultSynthStyle)_defaultStyle).setFont( new FontUIResource(Font.DIALOG, Font.PLAIN,12)); } return _defaultStyle; }
Example #26
Source File: DarculaLaf.java From consulo with Apache License 2.0 | 5 votes |
@Nonnull @Override public UIDefaults getDefaultsImpl(UIDefaults superDefaults) { try { final UIDefaults metalDefaults = new MetalLookAndFeel().getDefaults(); final UIDefaults defaults = base.getDefaults(); if (SystemInfo.isLinux && !Registry.is("darcula.use.native.fonts.on.linux")) { Font font = findFont("DejaVu Sans"); if (font != null) { for (Object key : defaults.keySet()) { if (key instanceof String && ((String)key).endsWith(".font")) { defaults.put(key, new FontUIResource(font.deriveFont(13f))); } } } } LafManagerImplUtil.initInputMapDefaults(defaults); defaults.put(SupportTextBoxWithExpandActionExtender.class, SupportTextBoxWithExpandActionExtender.INSTANCE); defaults.put(SupportTextBoxWithExtensionsExtender.class, SupportTextBoxWithExtensionsExtender.INSTANCE); initIdeaDefaults(defaults); patchStyledEditorKit(defaults); patchComboBox(metalDefaults, defaults); defaults.remove("Spinner.arrowButtonBorder"); defaults.put("Spinner.arrowButtonSize", JBUI.size(16, 5).asUIResource()); MetalLookAndFeel.setCurrentTheme(createMetalTheme()); defaults.put("EditorPane.font", defaults.getFont("TextField.font")); return defaults; } catch (Exception e) { log(e); } return super.getDefaultsImpl(superDefaults); }
Example #27
Source File: javax_swing_plaf_FontUIResource.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
protected FontUIResource getObject() { return new FontUIResource( new Font( Collections.singletonMap( TextAttribute.STRIKETHROUGH, TextAttribute.STRIKETHROUGH_ON))); }
Example #28
Source File: CFontManager.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
@Override protected FontUIResource getFontConfigFUIR( String family, int style, int size) { String mappedName = FontUtilities.mapFcName(family); if (mappedName == null) { mappedName = "sansserif"; } return new FontUIResource(mappedName, style, size); }
Example #29
Source File: DefaultSynthStyleFactory.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * Returns the style to use if there are no matching styles. */ private SynthStyle getDefaultStyle() { if (_defaultStyle == null) { _defaultStyle = new DefaultSynthStyle(); ((DefaultSynthStyle)_defaultStyle).setFont( new FontUIResource(Font.DIALOG, Font.PLAIN,12)); } return _defaultStyle; }
Example #30
Source File: StyledLookAndFeel.java From stendhal with GNU General Public License v2.0 | 5 votes |
/** * Set the default font size used in components. * * @param size new font size */ public void setDefaultFontSize(final int size) { UIDefaults defaults = getDefaults(); for (Object key : defaults.keySet()) { if ((key instanceof String) && (((String) key).endsWith(".font"))) { FontUIResource font = (FontUIResource) defaults.get(key); // For some reason changing it in defaults does not work // reliably. Going through UIManager fixes it. UIManager.put(key, new FontUIResource(font.getName(), font.getStyle(), size)); } } }