本文整理汇总了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;
}
示例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;
}
示例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);
}