本文整理匯總了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;
}