1.如何判断Emoji的展示类型,从源代码中可见,正如Unicode Emoji文档中描述通过 0xFE0F 和 0xFE0E 即可判断展示类型。
EmojiProcessor.java
/**
* @param codePoint CodePoint to check
*
* @return {@code true} if the codepoint is a emoji style standardized variation selector
*/
private static boolean isEmojiStyle(int codePoint) {
return codePoint ==0xFE0F;
}
/**
* @param codePoint CodePoint to check
*
* @return {@code true} if the codepoint is a text style standardized variation selector
*/
private static boolean isTextStyle(int codePoint) {
return codePoint ==0xFE0E;
}
}
来判断 文本类型 或 emoji类型
2.如何判断文字宽度,Paint 中已经给出API可以做到。
Paint.java
/**
* Return the width of the text.
*
* @param text The text to measure. Cannot be null.
* @return The width of the text
*/
public float measureText(String text) {
if (text ==null) {
throw new IllegalArgumentException("text cannot be null");
}
return measureText(text, 0, text.length());
}
返回字符串宽度。
网友评论