Java Code Examples for android.graphics.Paint#hasGlyph()
The following examples show how to use
android.graphics.Paint#hasGlyph() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EmojiCategory.java From openboard with GNU General Public License v3.0 | 5 votes |
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. } }
Example 2
Source File: EmojiCategory.java From openboard with GNU General Public License v3.0 | 5 votes |
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. } }
Example 3
Source File: EmojiCategory.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 5 votes |
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. } }
Example 4
Source File: EmojiCategory.java From AOSP-Kayboard-7.1.2 with Apache License 2.0 | 5 votes |
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. } }
Example 5
Source File: EmojiCategory.java From Indic-Keyboard with Apache License 2.0 | 5 votes |
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. } }
Example 6
Source File: EmojiCategory.java From Indic-Keyboard with Apache License 2.0 | 5 votes |
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. } }