当前位置: 首页>>代码示例>>Java>>正文


Java FontUtilities.getCompositeFontUIResource方法代码示例

本文整理汇总了Java中sun.font.FontUtilities.getCompositeFontUIResource方法的典型用法代码示例。如果您正苦于以下问题:Java FontUtilities.getCompositeFontUIResource方法的具体用法?Java FontUtilities.getCompositeFontUIResource怎么用?Java FontUtilities.getCompositeFontUIResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sun.font.FontUtilities的用法示例。


在下文中一共展示了FontUtilities.getCompositeFontUIResource方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFont

import sun.font.FontUtilities; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:39,代码来源:StyleContext.java

示例2: getFont

import sun.font.FontUtilities; //导入方法依赖的package包/类
/**
 * 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;
}
 
开发者ID:openjdk,项目名称:jdk7-jdk,代码行数:39,代码来源:StyleContext.java

示例3: configureValue

import sun.font.FontUtilities; //导入方法依赖的package包/类
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);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:42,代码来源:WindowsLookAndFeel.java


注:本文中的sun.font.FontUtilities.getCompositeFontUIResource方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。