本文整理汇总了Java中java.awt.Font.canDisplayUpTo方法的典型用法代码示例。如果您正苦于以下问题:Java Font.canDisplayUpTo方法的具体用法?Java Font.canDisplayUpTo怎么用?Java Font.canDisplayUpTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.awt.Font
的用法示例。
在下文中一共展示了Font.canDisplayUpTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createCompatibleFont
import java.awt.Font; //导入方法依赖的package包/类
/**
* Create a scaled {@code Font} which can display all characters
* inside the given text string.
* This is mostly necessary for the header font. Thats because the currently
* used ShadowedBlack is missing support for CJK and others. Even some
* special glyphs for European languages like the triple-dot are missing.
*
* @param string The text to find a compatible font for.
* @param fontType How the font should look like.
* @param fontSize Its relative size.
* @param style The font style for choosing plain, bold or italic.
* @param scaleFactor The applied scale factor.
* @return The created Font.
*/
public static Font createCompatibleFont(String string, FontType fontType,
FontSize fontSize,
int style, float scaleFactor) {
// TODO: Consider testing the normal font for compatibility and try
// some or all other available fonts for complete/longest match:
// header/simple->main->normal->simple/header->emergency
float scaledSize = calcScaledSize(fontSize, scaleFactor);
String fontKey = getFontKey(fontType);
Font font = null;
if(fontType != FontType.NORMAL) {
font = ResourceManager.getFont(fontKey);
if(font.canDisplayUpTo(string) != -1)
font = null;
}
if(font == null) {
fontKey = getFontKey(FontType.NORMAL);
font = (fontKey == null)
? mainFont
: ResourceManager.getFont(fontKey);
}
font = font.deriveFont(style, scaledSize);
return font;
}