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


Java Font2D.canDisplay方法代码示例

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


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

示例1: 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

示例2: 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


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