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


Java Font2D类代码示例

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


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

示例1: createScaler

import sun.font.Font2D; //导入依赖的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);
}
 
开发者ID:CodeFX-org,项目名称:java-9-wtf,代码行数:17,代码来源:NotoSans.java

示例2: getFont2D

import sun.font.Font2D; //导入依赖的package包/类
private Font2D getFont2D() {
    FontManager fm = FontManagerFactory.getInstance();
    if (fm.usingPerAppContextComposites() &&
        font2DHandle != null &&
        font2DHandle.font2D instanceof CompositeFont &&
        ((CompositeFont)(font2DHandle.font2D)).isStdComposite()) {
        return fm.findFont2D(name, style,
                                      FontManager.LOGICAL_FALLBACK);
    } else if (font2DHandle == null) {
        font2DHandle =
            fm.findFont2D(name, style,
                          FontManager.LOGICAL_FALLBACK).handle;
    }
    /* Do not cache the de-referenced font2D. It must be explicitly
     * de-referenced to pick up a valid font in the event that the
     * original one is marked invalid
     */
    return font2DHandle.font2D;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:20,代码来源:Font.java

示例3: canDisplayUpTo

import sun.font.Font2D; //导入依赖的package包/类
/**
 * Indicates whether or not this <code>Font</code> can display a
 * specified <code>String</code>.  For strings with Unicode encoding,
 * it is important to know if a particular font can display the
 * string. This method returns an offset into the <code>String</code>
 * <code>str</code> which is the first character this
 * <code>Font</code> cannot display without using the missing glyph
 * code. If the <code>Font</code> can display all characters, -1 is
 * returned.
 * @param str a <code>String</code> object
 * @return an offset into <code>str</code> that points
 *          to the first character in <code>str</code> that this
 *          <code>Font</code> cannot display; or <code>-1</code> if
 *          this <code>Font</code> can display all characters in
 *          <code>str</code>.
 * @since 1.2
 */
public int canDisplayUpTo(String str) {
    Font2D font2d = getFont2D();
    int len = str.length();
    for (int i = 0; i < len; i++) {
        char c = str.charAt(i);
        if (font2d.canDisplay(c)) {
            continue;
        }
        if (!Character.isHighSurrogate(c)) {
            return i;
        }
        if (!font2d.canDisplay(str.codePointAt(i))) {
            return i;
        }
        i++;
    }
    return -1;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:36,代码来源:Font.java

示例4: Font

import sun.font.Font2D; //导入依赖的package包/类
private Font(File fontFile, int fontFormat,
             boolean isCopy, CreatedFontTracker tracker)
    throws FontFormatException {
    this.createdFont = true;
    /* Font2D instances created by this method track their font file
     * so that when the Font2D is GC'd it can also remove the file.
     */
    FontManager fm = FontManagerFactory.getInstance();
    Font2D[] fonts =
        fm.createFont2D(fontFile, fontFormat, false, isCopy, tracker);
    this.font2DHandle = fonts[0].handle;
    this.name = this.font2DHandle.font2D.getFontName(Locale.getDefault());
    this.style = Font.PLAIN;
    this.size = 1;
    this.pointSize = 1f;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:17,代码来源:Font.java

示例5: canDisplayUpTo

import sun.font.Font2D; //导入依赖的package包/类
/**
 * Indicates whether or not this {@code Font} can display a
 * specified {@code String}.  For strings with Unicode encoding,
 * it is important to know if a particular font can display the
 * string. This method returns an offset into the {@code String}
 * {@code str} which is the first character this
 * {@code Font} cannot display without using the missing glyph
 * code. If the {@code Font} can display all characters, -1 is
 * returned.
 * @param str a {@code String} object
 * @return an offset into {@code str} that points
 *          to the first character in {@code str} that this
 *          {@code Font} cannot display; or {@code -1} if
 *          this {@code Font} can display all characters in
 *          {@code str}.
 * @since 1.2
 */
public int canDisplayUpTo(String str) {
    Font2D font2d = getFont2D();
    int len = str.length();
    for (int i = 0; i < len; i++) {
        char c = str.charAt(i);
        if (font2d.canDisplay(c)) {
            continue;
        }
        if (!Character.isHighSurrogate(c)) {
            return i;
        }
        if (!font2d.canDisplay(str.codePointAt(i))) {
            return i;
        }
        i++;
    }
    return -1;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:36,代码来源:Font.java

示例6: getFont2D

import sun.font.Font2D; //导入依赖的package包/类
private Font2D getFont2D() {
    if (FontManager.usingPerAppContextComposites &&
        font2DHandle != null &&
        font2DHandle.font2D instanceof CompositeFont &&
        ((CompositeFont)(font2DHandle.font2D)).isStdComposite()) {
        return FontManager.findFont2D(name, style,
                                      FontManager.LOGICAL_FALLBACK);
    } else if (font2DHandle == null) {
        font2DHandle =
            FontManager.findFont2D(name, style,
                                   FontManager.LOGICAL_FALLBACK).handle;
    }
    /* Do not cache the de-referenced font2D. It must be explicitly
     * de-referenced to pick up a valid font in the event that the
     * original one is marked invalid
     */
    return font2DHandle.font2D;
}
 
开发者ID:jgaltidor,项目名称:VarJ,代码行数:19,代码来源:Font.java


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