android.graphics.Paint#hasGlyph ( )源码实例Demo

下面列出了android.graphics.Paint#hasGlyph ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openboard   文件: EmojiCategory.java
private static boolean canShowFlagEmoji() {
    Paint paint = new Paint();
    String switzerland = "\uD83C\uDDE8\uD83C\uDDED"; //  U+1F1E8 U+1F1ED Flag for Switzerland
    try {
        return paint.hasGlyph(switzerland);
    } catch (NoSuchMethodError e) {
        // Compare display width of single-codepoint emoji to width of flag emoji to determine
        // whether flag is rendered as single glyph or two adjacent regional indicator symbols.
        float flagWidth = paint.measureText(switzerland);
        float standardWidth = paint.measureText("\uD83D\uDC27"); //  U+1F427 Penguin
        return flagWidth < standardWidth * 1.25;
        // This assumes that a valid glyph for the flag emoji must be less than 1.25 times
        // the width of the penguin.
    }
}
 
源代码2 项目: openboard   文件: EmojiCategory.java
private static boolean canShowUnicodeEightEmoji() {
    Paint paint = new Paint();
    String cheese = "\uD83E\uDDC0"; //  U+1F9C0 Cheese wedge
    try {
        return paint.hasGlyph(cheese);
    } catch (NoSuchMethodError e) {
        float cheeseWidth = paint.measureText(cheese);
        float tofuWidth = paint.measureText("\uFFFE");
        return cheeseWidth > tofuWidth;
        // This assumes that a valid glyph for the cheese wedge must be greater than the width
        // of the noncharacter.
    }
}
 
源代码3 项目: AOSP-Kayboard-7.1.2   文件: EmojiCategory.java
private static boolean canShowFlagEmoji() {
    Paint paint = new Paint();
    String switzerland = "\uD83C\uDDE8\uD83C\uDDED"; //  U+1F1E8 U+1F1ED Flag for Switzerland
    try {
        return paint.hasGlyph(switzerland);
    } catch (NoSuchMethodError e) {
        // Compare display width of single-codepoint emoji to width of flag emoji to determine
        // whether flag is rendered as single glyph or two adjacent regional indicator symbols.
        float flagWidth = paint.measureText(switzerland);
        float standardWidth = paint.measureText("\uD83D\uDC27"); //  U+1F427 Penguin
        return flagWidth < standardWidth * 1.25;
        // This assumes that a valid glyph for the flag emoji must be less than 1.25 times
        // the width of the penguin.
    }
}
 
源代码4 项目: AOSP-Kayboard-7.1.2   文件: EmojiCategory.java
private static boolean canShowUnicodeEightEmoji() {
    Paint paint = new Paint();
    String cheese = "\uD83E\uDDC0"; //  U+1F9C0 Cheese wedge
    try {
        return paint.hasGlyph(cheese);
    } catch (NoSuchMethodError e) {
        float cheeseWidth = paint.measureText(cheese);
        float tofuWidth = paint.measureText("\uFFFE");
        return cheeseWidth > tofuWidth;
        // This assumes that a valid glyph for the cheese wedge must be greater than the width
        // of the noncharacter.
    }
}
 
源代码5 项目: Indic-Keyboard   文件: EmojiCategory.java
private static boolean canShowFlagEmoji() {
    Paint paint = new Paint();
    String switzerland = "\uD83C\uDDE8\uD83C\uDDED"; //  U+1F1E8 U+1F1ED Flag for Switzerland
    try {
        return paint.hasGlyph(switzerland);
    } catch (NoSuchMethodError e) {
        // Compare display width of single-codepoint emoji to width of flag emoji to determine
        // whether flag is rendered as single glyph or two adjacent regional indicator symbols.
        float flagWidth = paint.measureText(switzerland);
        float standardWidth = paint.measureText("\uD83D\uDC27"); //  U+1F427 Penguin
        return flagWidth < standardWidth * 1.25;
        // This assumes that a valid glyph for the flag emoji must be less than 1.25 times
        // the width of the penguin.
    }
}
 
源代码6 项目: Indic-Keyboard   文件: EmojiCategory.java
private static boolean canShowUnicodeEightEmoji() {
    Paint paint = new Paint();
    String cheese = "\uD83E\uDDC0"; //  U+1F9C0 Cheese wedge
    try {
        return paint.hasGlyph(cheese);
    } catch (NoSuchMethodError e) {
        float cheeseWidth = paint.measureText(cheese);
        float tofuWidth = paint.measureText("\uFFFE");
        return cheeseWidth > tofuWidth;
        // This assumes that a valid glyph for the cheese wedge must be greater than the width
        // of the noncharacter.
    }
}