Java Code Examples for sun.font.FontUtilities#getCompositeFontUIResource()

The following examples show how to use sun.font.FontUtilities#getCompositeFontUIResource() . 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: StyleContext.java    From jdk8u-dev-jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets a new font.  This returns a Font from a cache
 * if a cached font exists.  If not, a Font is added to
 * the cache.  This is basically a low-level cache for
 * 1.1 font features.
 *
 * @param family the font family (such as "Monospaced")
 * @param style the style of the font (such as Font.PLAIN)
 * @param size the point size >= 1
 * @return the new font
 */
public Font getFont(String family, int style, int size) {
    fontSearch.setValue(family, style, size);
    Font f = fontTable.get(fontSearch);
    if (f == null) {
        // haven't seen this one yet.
        Style defaultStyle =
            getStyle(StyleContext.DEFAULT_STYLE);
        if (defaultStyle != null) {
            final String FONT_ATTRIBUTE_KEY = "FONT_ATTRIBUTE_KEY";
            Font defaultFont =
                (Font) defaultStyle.getAttribute(FONT_ATTRIBUTE_KEY);
            if (defaultFont != null
                  && defaultFont.getFamily().equalsIgnoreCase(family)) {
                f = defaultFont.deriveFont(style, size);
            }
        }
        if (f == null) {
            f = new Font(family, style, size);
        }
        if (! FontUtilities.fontSupportsDefaultEncoding(f)) {
            f = FontUtilities.getCompositeFontUIResource(f);
        }
        FontKey key = new FontKey(family, style, size);
        fontTable.put(key, f);
    }
    return f;
}
 
Example 2
Source File: StyleContext.java    From Java8CN with Apache License 2.0 5 votes vote down vote up
/**
 * Gets a new font.  This returns a Font from a cache
 * if a cached font exists.  If not, a Font is added to
 * the cache.  This is basically a low-level cache for
 * 1.1 font features.
 *
 * @param family the font family (such as "Monospaced")
 * @param style the style of the font (such as Font.PLAIN)
 * @param size the point size >= 1
 * @return the new font
 */
public Font getFont(String family, int style, int size) {
    fontSearch.setValue(family, style, size);
    Font f = fontTable.get(fontSearch);
    if (f == null) {
        // haven't seen this one yet.
        Style defaultStyle =
            getStyle(StyleContext.DEFAULT_STYLE);
        if (defaultStyle != null) {
            final String FONT_ATTRIBUTE_KEY = "FONT_ATTRIBUTE_KEY";
            Font defaultFont =
                (Font) defaultStyle.getAttribute(FONT_ATTRIBUTE_KEY);
            if (defaultFont != null
                  && defaultFont.getFamily().equalsIgnoreCase(family)) {
                f = defaultFont.deriveFont(style, size);
            }
        }
        if (f == null) {
            f = new Font(family, style, size);
        }
        if (! FontUtilities.fontSupportsDefaultEncoding(f)) {
            f = FontUtilities.getCompositeFontUIResource(f);
        }
        FontKey key = new FontKey(family, style, size);
        fontTable.put(key, f);
    }
    return f;
}
 
Example 3
Source File: StyleContext.java    From openjdk-jdk9 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets a new font.  This returns a Font from a cache
 * if a cached font exists.  If not, a Font is added to
 * the cache.  This is basically a low-level cache for
 * 1.1 font features.
 *
 * @param family the font family (such as "Monospaced")
 * @param style the style of the font (such as Font.PLAIN)
 * @param size the point size >= 1
 * @return the new font
 */
public Font getFont(String family, int style, int size) {
    fontSearch.setValue(family, style, size);
    Font f = fontTable.get(fontSearch);
    if (f == null) {
        // haven't seen this one yet.
        Style defaultStyle =
            getStyle(StyleContext.DEFAULT_STYLE);
        if (defaultStyle != null) {
            final String FONT_ATTRIBUTE_KEY = "FONT_ATTRIBUTE_KEY";
            Font defaultFont =
                (Font) defaultStyle.getAttribute(FONT_ATTRIBUTE_KEY);
            if (defaultFont != null
                  && defaultFont.getFamily().equalsIgnoreCase(family)) {
                f = defaultFont.deriveFont(style, size);
            }
        }
        if (f == null) {
            f = new Font(family, style, size);
        }
        if (! FontUtilities.fontSupportsDefaultEncoding(f)) {
            f = FontUtilities.getCompositeFontUIResource(f);
        }
        FontKey key = new FontKey(family, style, size);
        fontTable.put(key, f);
    }
    return f;
}
 
Example 4
Source File: StyleContext.java    From openjdk-jdk8u-backup with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets a new font.  This returns a Font from a cache
 * if a cached font exists.  If not, a Font is added to
 * the cache.  This is basically a low-level cache for
 * 1.1 font features.
 *
 * @param family the font family (such as "Monospaced")
 * @param style the style of the font (such as Font.PLAIN)
 * @param size the point size >= 1
 * @return the new font
 */
public Font getFont(String family, int style, int size) {
    fontSearch.setValue(family, style, size);
    Font f = fontTable.get(fontSearch);
    if (f == null) {
        // haven't seen this one yet.
        Style defaultStyle =
            getStyle(StyleContext.DEFAULT_STYLE);
        if (defaultStyle != null) {
            final String FONT_ATTRIBUTE_KEY = "FONT_ATTRIBUTE_KEY";
            Font defaultFont =
                (Font) defaultStyle.getAttribute(FONT_ATTRIBUTE_KEY);
            if (defaultFont != null
                  && defaultFont.getFamily().equalsIgnoreCase(family)) {
                f = defaultFont.deriveFont(style, size);
            }
        }
        if (f == null) {
            f = new Font(family, style, size);
        }
        if (! FontUtilities.fontSupportsDefaultEncoding(f)) {
            f = FontUtilities.getCompositeFontUIResource(f);
        }
        FontKey key = new FontKey(family, style, size);
        fontTable.put(key, f);
    }
    return f;
}
 
Example 5
Source File: StyleContext.java    From openjdk-jdk8u with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets a new font.  This returns a Font from a cache
 * if a cached font exists.  If not, a Font is added to
 * the cache.  This is basically a low-level cache for
 * 1.1 font features.
 *
 * @param family the font family (such as "Monospaced")
 * @param style the style of the font (such as Font.PLAIN)
 * @param size the point size >= 1
 * @return the new font
 */
public Font getFont(String family, int style, int size) {
    fontSearch.setValue(family, style, size);
    Font f = fontTable.get(fontSearch);
    if (f == null) {
        // haven't seen this one yet.
        Style defaultStyle =
            getStyle(StyleContext.DEFAULT_STYLE);
        if (defaultStyle != null) {
            final String FONT_ATTRIBUTE_KEY = "FONT_ATTRIBUTE_KEY";
            Font defaultFont =
                (Font) defaultStyle.getAttribute(FONT_ATTRIBUTE_KEY);
            if (defaultFont != null
                  && defaultFont.getFamily().equalsIgnoreCase(family)) {
                f = defaultFont.deriveFont(style, size);
            }
        }
        if (f == null) {
            f = new Font(family, style, size);
        }
        if (! FontUtilities.fontSupportsDefaultEncoding(f)) {
            f = FontUtilities.getCompositeFontUIResource(f);
        }
        FontKey key = new FontKey(family, style, size);
        fontTable.put(key, f);
    }
    return f;
}
 
Example 6
Source File: StyleContext.java    From hottub with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets a new font.  This returns a Font from a cache
 * if a cached font exists.  If not, a Font is added to
 * the cache.  This is basically a low-level cache for
 * 1.1 font features.
 *
 * @param family the font family (such as "Monospaced")
 * @param style the style of the font (such as Font.PLAIN)
 * @param size the point size >= 1
 * @return the new font
 */
public Font getFont(String family, int style, int size) {
    fontSearch.setValue(family, style, size);
    Font f = fontTable.get(fontSearch);
    if (f == null) {
        // haven't seen this one yet.
        Style defaultStyle =
            getStyle(StyleContext.DEFAULT_STYLE);
        if (defaultStyle != null) {
            final String FONT_ATTRIBUTE_KEY = "FONT_ATTRIBUTE_KEY";
            Font defaultFont =
                (Font) defaultStyle.getAttribute(FONT_ATTRIBUTE_KEY);
            if (defaultFont != null
                  && defaultFont.getFamily().equalsIgnoreCase(family)) {
                f = defaultFont.deriveFont(style, size);
            }
        }
        if (f == null) {
            f = new Font(family, style, size);
        }
        if (! FontUtilities.fontSupportsDefaultEncoding(f)) {
            f = FontUtilities.getCompositeFontUIResource(f);
        }
        FontKey key = new FontKey(family, style, size);
        fontTable.put(key, f);
    }
    return f;
}
 
Example 7
Source File: StyleContext.java    From TencentKona-8 with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets a new font.  This returns a Font from a cache
 * if a cached font exists.  If not, a Font is added to
 * the cache.  This is basically a low-level cache for
 * 1.1 font features.
 *
 * @param family the font family (such as "Monospaced")
 * @param style the style of the font (such as Font.PLAIN)
 * @param size the point size >= 1
 * @return the new font
 */
public Font getFont(String family, int style, int size) {
    fontSearch.setValue(family, style, size);
    Font f = fontTable.get(fontSearch);
    if (f == null) {
        // haven't seen this one yet.
        Style defaultStyle =
            getStyle(StyleContext.DEFAULT_STYLE);
        if (defaultStyle != null) {
            final String FONT_ATTRIBUTE_KEY = "FONT_ATTRIBUTE_KEY";
            Font defaultFont =
                (Font) defaultStyle.getAttribute(FONT_ATTRIBUTE_KEY);
            if (defaultFont != null
                  && defaultFont.getFamily().equalsIgnoreCase(family)) {
                f = defaultFont.deriveFont(style, size);
            }
        }
        if (f == null) {
            f = new Font(family, style, size);
        }
        if (! FontUtilities.fontSupportsDefaultEncoding(f)) {
            f = FontUtilities.getCompositeFontUIResource(f);
        }
        FontKey key = new FontKey(family, style, size);
        fontTable.put(key, f);
    }
    return f;
}
 
Example 8
Source File: StyleContext.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets a new font.  This returns a Font from a cache
 * if a cached font exists.  If not, a Font is added to
 * the cache.  This is basically a low-level cache for
 * 1.1 font features.
 *
 * @param family the font family (such as "Monospaced")
 * @param style the style of the font (such as Font.PLAIN)
 * @param size the point size >= 1
 * @return the new font
 */
public Font getFont(String family, int style, int size) {
    fontSearch.setValue(family, style, size);
    Font f = fontTable.get(fontSearch);
    if (f == null) {
        // haven't seen this one yet.
        Style defaultStyle =
            getStyle(StyleContext.DEFAULT_STYLE);
        if (defaultStyle != null) {
            final String FONT_ATTRIBUTE_KEY = "FONT_ATTRIBUTE_KEY";
            Font defaultFont =
                (Font) defaultStyle.getAttribute(FONT_ATTRIBUTE_KEY);
            if (defaultFont != null
                  && defaultFont.getFamily().equalsIgnoreCase(family)) {
                f = defaultFont.deriveFont(style, size);
            }
        }
        if (f == null) {
            f = new Font(family, style, size);
        }
        if (! FontUtilities.fontSupportsDefaultEncoding(f)) {
            f = FontUtilities.getCompositeFontUIResource(f);
        }
        FontKey key = new FontKey(family, style, size);
        fontTable.put(key, f);
    }
    return f;
}
 
Example 9
Source File: StyleContext.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Gets a new font.  This returns a Font from a cache
 * if a cached font exists.  If not, a Font is added to
 * the cache.  This is basically a low-level cache for
 * 1.1 font features.
 *
 * @param family the font family (such as "Monospaced")
 * @param style the style of the font (such as Font.PLAIN)
 * @param size the point size >= 1
 * @return the new font
 */
public Font getFont(String family, int style, int size) {
    fontSearch.setValue(family, style, size);
    Font f = fontTable.get(fontSearch);
    if (f == null) {
        // haven't seen this one yet.
        Style defaultStyle =
            getStyle(StyleContext.DEFAULT_STYLE);
        if (defaultStyle != null) {
            final String FONT_ATTRIBUTE_KEY = "FONT_ATTRIBUTE_KEY";
            Font defaultFont =
                (Font) defaultStyle.getAttribute(FONT_ATTRIBUTE_KEY);
            if (defaultFont != null
                  && defaultFont.getFamily().equalsIgnoreCase(family)) {
                f = defaultFont.deriveFont(style, size);
            }
        }
        if (f == null) {
            f = new Font(family, style, size);
        }
        if (! FontUtilities.fontSupportsDefaultEncoding(f)) {
            f = FontUtilities.getCompositeFontUIResource(f);
        }
        FontKey key = new FontKey(family, style, size);
        fontTable.put(key, f);
    }
    return f;
}
 
Example 10
Source File: WindowsLookAndFeel.java    From jdk8u60 with GNU General Public License v2.0 4 votes vote down vote up
protected Object configureValue(Object value) {
    if (value instanceof Font) {
        Font font = (Font)value;
        if ("MS Sans Serif".equals(font.getName())) {
            int size = font.getSize();
            // 4950968: Workaround to mimic the way Windows maps the default
            // font size of 6 pts to the smallest available bitmap font size.
            // This happens mostly on Win 98/Me & NT.
            int dpi;
            try {
                dpi = Toolkit.getDefaultToolkit().getScreenResolution();
            } catch (HeadlessException ex) {
                dpi = 96;
            }
            if (Math.round(size * 72F / dpi) < 8) {
                size = Math.round(8 * dpi / 72F);
            }
            Font msFont = new FontUIResource("Microsoft Sans Serif",
                                  font.getStyle(), size);
            if (msFont.getName() != null &&
                msFont.getName().equals(msFont.getFamily())) {
                font = msFont;
            } else if (size != font.getSize()) {
                font = new FontUIResource("MS Sans Serif",
                                          font.getStyle(), size);
            }
        }

        if (FontUtilities.fontSupportsDefaultEncoding(font)) {
            if (!(font instanceof UIResource)) {
                font = new FontUIResource(font);
            }
        }
        else {
            font = FontUtilities.getCompositeFontUIResource(font);
        }
        return font;

    }
    return super.configureValue(value);
}
 
Example 11
Source File: WindowsLookAndFeel.java    From jdk8u-dev-jdk with GNU General Public License v2.0 4 votes vote down vote up
protected Object configureValue(Object value) {
    if (value instanceof Font) {
        Font font = (Font)value;
        if ("MS Sans Serif".equals(font.getName())) {
            int size = font.getSize();
            // 4950968: Workaround to mimic the way Windows maps the default
            // font size of 6 pts to the smallest available bitmap font size.
            // This happens mostly on Win 98/Me & NT.
            int dpi;
            try {
                dpi = Toolkit.getDefaultToolkit().getScreenResolution();
            } catch (HeadlessException ex) {
                dpi = 96;
            }
            if (Math.round(size * 72F / dpi) < 8) {
                size = Math.round(8 * dpi / 72F);
            }
            Font msFont = new FontUIResource("Microsoft Sans Serif",
                                  font.getStyle(), size);
            if (msFont.getName() != null &&
                msFont.getName().equals(msFont.getFamily())) {
                font = msFont;
            } else if (size != font.getSize()) {
                font = new FontUIResource("MS Sans Serif",
                                          font.getStyle(), size);
            }
        }

        if (FontUtilities.fontSupportsDefaultEncoding(font)) {
            if (!(font instanceof UIResource)) {
                font = new FontUIResource(font);
            }
        }
        else {
            font = FontUtilities.getCompositeFontUIResource(font);
        }
        return font;

    }
    return super.configureValue(value);
}
 
Example 12
Source File: WindowsLookAndFeel.java    From JDKSourceCode1.8 with MIT License 4 votes vote down vote up
protected Object configureValue(Object value) {
    if (value instanceof Font) {
        Font font = (Font)value;
        if ("MS Sans Serif".equals(font.getName())) {
            int size = font.getSize();
            // 4950968: Workaround to mimic the way Windows maps the default
            // font size of 6 pts to the smallest available bitmap font size.
            // This happens mostly on Win 98/Me & NT.
            int dpi;
            try {
                dpi = Toolkit.getDefaultToolkit().getScreenResolution();
            } catch (HeadlessException ex) {
                dpi = 96;
            }
            if (Math.round(size * 72F / dpi) < 8) {
                size = Math.round(8 * dpi / 72F);
            }
            Font msFont = new FontUIResource("Microsoft Sans Serif",
                                  font.getStyle(), size);
            if (msFont.getName() != null &&
                msFont.getName().equals(msFont.getFamily())) {
                font = msFont;
            } else if (size != font.getSize()) {
                font = new FontUIResource("MS Sans Serif",
                                          font.getStyle(), size);
            }
        }

        if (FontUtilities.fontSupportsDefaultEncoding(font)) {
            if (!(font instanceof UIResource)) {
                font = new FontUIResource(font);
            }
        }
        else {
            font = FontUtilities.getCompositeFontUIResource(font);
        }
        return font;

    }
    return super.configureValue(value);
}
 
Example 13
Source File: WindowsLookAndFeel.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
protected Object configureValue(Object value) {
    if (value instanceof Font) {
        Font font = (Font)value;
        if ("MS Sans Serif".equals(font.getName())) {
            int size = font.getSize();
            // 4950968: Workaround to mimic the way Windows maps the default
            // font size of 6 pts to the smallest available bitmap font size.
            // This happens mostly on Win 98/Me & NT.
            int dpi;
            try {
                dpi = Toolkit.getDefaultToolkit().getScreenResolution();
            } catch (HeadlessException ex) {
                dpi = 96;
            }
            if (Math.round(size * 72F / dpi) < 8) {
                size = Math.round(8 * dpi / 72F);
            }
            Font msFont = new FontUIResource("Microsoft Sans Serif",
                                  font.getStyle(), size);
            if (msFont.getName() != null &&
                msFont.getName().equals(msFont.getFamily())) {
                font = msFont;
            } else if (size != font.getSize()) {
                font = new FontUIResource("MS Sans Serif",
                                          font.getStyle(), size);
            }
        }

        if (FontUtilities.fontSupportsDefaultEncoding(font)) {
            if (!(font instanceof UIResource)) {
                font = new FontUIResource(font);
            }
        }
        else {
            font = FontUtilities.getCompositeFontUIResource(font);
        }
        return font;

    }
    return super.configureValue(value);
}
 
Example 14
Source File: WindowsLookAndFeel.java    From TencentKona-8 with GNU General Public License v2.0 4 votes vote down vote up
protected Object configureValue(Object value) {
    if (value instanceof Font) {
        Font font = (Font)value;
        if ("MS Sans Serif".equals(font.getName())) {
            int size = font.getSize();
            // 4950968: Workaround to mimic the way Windows maps the default
            // font size of 6 pts to the smallest available bitmap font size.
            // This happens mostly on Win 98/Me & NT.
            int dpi;
            try {
                dpi = Toolkit.getDefaultToolkit().getScreenResolution();
            } catch (HeadlessException ex) {
                dpi = 96;
            }
            if (Math.round(size * 72F / dpi) < 8) {
                size = Math.round(8 * dpi / 72F);
            }
            Font msFont = new FontUIResource("Microsoft Sans Serif",
                                  font.getStyle(), size);
            if (msFont.getName() != null &&
                msFont.getName().equals(msFont.getFamily())) {
                font = msFont;
            } else if (size != font.getSize()) {
                font = new FontUIResource("MS Sans Serif",
                                          font.getStyle(), size);
            }
        }

        if (FontUtilities.fontSupportsDefaultEncoding(font)) {
            if (!(font instanceof UIResource)) {
                font = new FontUIResource(font);
            }
        }
        else {
            font = FontUtilities.getCompositeFontUIResource(font);
        }
        return font;

    }
    return super.configureValue(value);
}
 
Example 15
Source File: WindowsLookAndFeel.java    From openjdk-8-source with GNU General Public License v2.0 4 votes vote down vote up
protected Object configureValue(Object value) {
    if (value instanceof Font) {
        Font font = (Font)value;
        if ("MS Sans Serif".equals(font.getName())) {
            int size = font.getSize();
            // 4950968: Workaround to mimic the way Windows maps the default
            // font size of 6 pts to the smallest available bitmap font size.
            // This happens mostly on Win 98/Me & NT.
            int dpi;
            try {
                dpi = Toolkit.getDefaultToolkit().getScreenResolution();
            } catch (HeadlessException ex) {
                dpi = 96;
            }
            if (Math.round(size * 72F / dpi) < 8) {
                size = Math.round(8 * dpi / 72F);
            }
            Font msFont = new FontUIResource("Microsoft Sans Serif",
                                  font.getStyle(), size);
            if (msFont.getName() != null &&
                msFont.getName().equals(msFont.getFamily())) {
                font = msFont;
            } else if (size != font.getSize()) {
                font = new FontUIResource("MS Sans Serif",
                                          font.getStyle(), size);
            }
        }

        if (FontUtilities.fontSupportsDefaultEncoding(font)) {
            if (!(font instanceof UIResource)) {
                font = new FontUIResource(font);
            }
        }
        else {
            font = FontUtilities.getCompositeFontUIResource(font);
        }
        return font;

    }
    return super.configureValue(value);
}
 
Example 16
Source File: WindowsLookAndFeel.java    From jdk8u_jdk with GNU General Public License v2.0 4 votes vote down vote up
protected Object configureValue(Object value) {
    if (value instanceof Font) {
        Font font = (Font)value;
        if ("MS Sans Serif".equals(font.getName())) {
            int size = font.getSize();
            // 4950968: Workaround to mimic the way Windows maps the default
            // font size of 6 pts to the smallest available bitmap font size.
            // This happens mostly on Win 98/Me & NT.
            int dpi;
            try {
                dpi = Toolkit.getDefaultToolkit().getScreenResolution();
            } catch (HeadlessException ex) {
                dpi = 96;
            }
            if (Math.round(size * 72F / dpi) < 8) {
                size = Math.round(8 * dpi / 72F);
            }
            Font msFont = new FontUIResource("Microsoft Sans Serif",
                                  font.getStyle(), size);
            if (msFont.getName() != null &&
                msFont.getName().equals(msFont.getFamily())) {
                font = msFont;
            } else if (size != font.getSize()) {
                font = new FontUIResource("MS Sans Serif",
                                          font.getStyle(), size);
            }
        }

        if (FontUtilities.fontSupportsDefaultEncoding(font)) {
            if (!(font instanceof UIResource)) {
                font = new FontUIResource(font);
            }
        }
        else {
            font = FontUtilities.getCompositeFontUIResource(font);
        }
        return font;

    }
    return super.configureValue(value);
}
 
Example 17
Source File: WindowsLookAndFeel.java    From openjdk-jdk9 with GNU General Public License v2.0 4 votes vote down vote up
protected Object configureValue(Object value) {
    if (value instanceof Font) {
        Font font = (Font)value;
        if ("MS Sans Serif".equals(font.getName())) {
            int size = font.getSize();
            // 4950968: Workaround to mimic the way Windows maps the default
            // font size of 6 pts to the smallest available bitmap font size.
            // This happens mostly on Win 98/Me & NT.
            int dpi;
            try {
                dpi = Toolkit.getDefaultToolkit().getScreenResolution();
            } catch (HeadlessException ex) {
                dpi = 96;
            }
            if (Math.round(size * 72F / dpi) < 8) {
                size = Math.round(8 * dpi / 72F);
            }
            Font msFont = new FontUIResource("Microsoft Sans Serif",
                                  font.getStyle(), size);
            if (msFont.getName() != null &&
                msFont.getName().equals(msFont.getFamily())) {
                font = msFont;
            } else if (size != font.getSize()) {
                font = new FontUIResource("MS Sans Serif",
                                          font.getStyle(), size);
            }
        }

        if (FontUtilities.fontSupportsDefaultEncoding(font)) {
            if (!(font instanceof UIResource)) {
                font = new FontUIResource(font);
            }
        }
        else {
            font = FontUtilities.getCompositeFontUIResource(font);
        }
        return font;

    }
    return super.configureValue(value);
}
 
Example 18
Source File: WindowsLookAndFeel.java    From dragonwell8_jdk with GNU General Public License v2.0 4 votes vote down vote up
protected Object configureValue(Object value) {
    if (value instanceof Font) {
        Font font = (Font)value;
        if ("MS Sans Serif".equals(font.getName())) {
            int size = font.getSize();
            // 4950968: Workaround to mimic the way Windows maps the default
            // font size of 6 pts to the smallest available bitmap font size.
            // This happens mostly on Win 98/Me & NT.
            int dpi;
            try {
                dpi = Toolkit.getDefaultToolkit().getScreenResolution();
            } catch (HeadlessException ex) {
                dpi = 96;
            }
            if (Math.round(size * 72F / dpi) < 8) {
                size = Math.round(8 * dpi / 72F);
            }
            Font msFont = new FontUIResource("Microsoft Sans Serif",
                                  font.getStyle(), size);
            if (msFont.getName() != null &&
                msFont.getName().equals(msFont.getFamily())) {
                font = msFont;
            } else if (size != font.getSize()) {
                font = new FontUIResource("MS Sans Serif",
                                          font.getStyle(), size);
            }
        }

        if (FontUtilities.fontSupportsDefaultEncoding(font)) {
            if (!(font instanceof UIResource)) {
                font = new FontUIResource(font);
            }
        }
        else {
            font = FontUtilities.getCompositeFontUIResource(font);
        }
        return font;

    }
    return super.configureValue(value);
}
 
Example 19
Source File: WindowsLookAndFeel.java    From jdk8u-jdk with GNU General Public License v2.0 4 votes vote down vote up
protected Object configureValue(Object value) {
    if (value instanceof Font) {
        Font font = (Font)value;
        if ("MS Sans Serif".equals(font.getName())) {
            int size = font.getSize();
            // 4950968: Workaround to mimic the way Windows maps the default
            // font size of 6 pts to the smallest available bitmap font size.
            // This happens mostly on Win 98/Me & NT.
            int dpi;
            try {
                dpi = Toolkit.getDefaultToolkit().getScreenResolution();
            } catch (HeadlessException ex) {
                dpi = 96;
            }
            if (Math.round(size * 72F / dpi) < 8) {
                size = Math.round(8 * dpi / 72F);
            }
            Font msFont = new FontUIResource("Microsoft Sans Serif",
                                  font.getStyle(), size);
            if (msFont.getName() != null &&
                msFont.getName().equals(msFont.getFamily())) {
                font = msFont;
            } else if (size != font.getSize()) {
                font = new FontUIResource("MS Sans Serif",
                                          font.getStyle(), size);
            }
        }

        if (FontUtilities.fontSupportsDefaultEncoding(font)) {
            if (!(font instanceof UIResource)) {
                font = new FontUIResource(font);
            }
        }
        else {
            font = FontUtilities.getCompositeFontUIResource(font);
        }
        return font;

    }
    return super.configureValue(value);
}
 
Example 20
Source File: WindowsLookAndFeel.java    From hottub with GNU General Public License v2.0 4 votes vote down vote up
protected Object configureValue(Object value) {
    if (value instanceof Font) {
        Font font = (Font)value;
        if ("MS Sans Serif".equals(font.getName())) {
            int size = font.getSize();
            // 4950968: Workaround to mimic the way Windows maps the default
            // font size of 6 pts to the smallest available bitmap font size.
            // This happens mostly on Win 98/Me & NT.
            int dpi;
            try {
                dpi = Toolkit.getDefaultToolkit().getScreenResolution();
            } catch (HeadlessException ex) {
                dpi = 96;
            }
            if (Math.round(size * 72F / dpi) < 8) {
                size = Math.round(8 * dpi / 72F);
            }
            Font msFont = new FontUIResource("Microsoft Sans Serif",
                                  font.getStyle(), size);
            if (msFont.getName() != null &&
                msFont.getName().equals(msFont.getFamily())) {
                font = msFont;
            } else if (size != font.getSize()) {
                font = new FontUIResource("MS Sans Serif",
                                          font.getStyle(), size);
            }
        }

        if (FontUtilities.fontSupportsDefaultEncoding(font)) {
            if (!(font instanceof UIResource)) {
                font = new FontUIResource(font);
            }
        }
        else {
            font = FontUtilities.getCompositeFontUIResource(font);
        }
        return font;

    }
    return super.configureValue(value);
}