本文整理汇总了Java中sun.font.FontUtilities.getFont2D方法的典型用法代码示例。如果您正苦于以下问题:Java FontUtilities.getFont2D方法的具体用法?Java FontUtilities.getFont2D怎么用?Java FontUtilities.getFont2D使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sun.font.FontUtilities
的用法示例。
在下文中一共展示了FontUtilities.getFont2D方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createScaler
import sun.font.FontUtilities; //导入方法依赖的package包/类
public static Object createScaler() throws ReflectiveOperationException {
// these APIs are used to reproduce the specific case I encountered
// as closely as possible
Font2D font = FontUtilities.getFont2D(new Font("Noto Sans CJK JP Black", 0, 12));
// this is a reconstruction of what happens at the end of a call stack like:
// - BasicListUI.updateLayoutState()
// - JComponent.getPreferredSize()
// - JComponent.getFontMetrics(Font)
// - TrueTypeFont.getScaler
Constructor<?> constructor = Class
.forName("sun.font.T2KFontScaler")
.getConstructor(Font2D.class, int.class, boolean.class, int.class);
constructor.setAccessible(true);
return constructor.newInstance(font, 0, true, 18604592);
}
示例2: platformFontCount
import sun.font.FontUtilities; //导入方法依赖的package包/类
@Override
protected int platformFontCount(Font font, String str) {
AffineTransform deviceTransform = getTransform();
AffineTransform fontTransform = new AffineTransform(deviceTransform);
fontTransform.concatenate(getFont().getTransform());
int transformType = fontTransform.getType();
/* Test if GDI can handle the transform */
boolean directToGDI = ((transformType !=
AffineTransform.TYPE_GENERAL_TRANSFORM)
&& ((transformType & AffineTransform.TYPE_FLIP)
== 0));
if (!directToGDI) {
return 0;
}
/* Since all windows fonts are available, and the JRE fonts
* are also registered. Only the Font.createFont() case is presently
* unknown to GDI. Those can be registered too, although that
* code does not exist yet, it can be added too, so we should not
* fail that case. Just do a quick check whether its a TrueTypeFont
* - ie not a Type1 font etc, and let drawString() resolve the rest.
*/
Font2D font2D = FontUtilities.getFont2D(font);
if (font2D instanceof CompositeFont ||
font2D instanceof TrueTypeFont) {
return 1;
} else {
return 0;
}
}