本文整理汇总了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;
}
示例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;
}