/** * Obtain the Unicode script associated with the given Unicode codepoint. * * @param codePoint * @return A Unicode script string, or {@code #UNKNOWN} if unknown */ private static String getUnicodeScript(int codePoint) { ensureValidCodePoint(codePoint); int type = Character.getType(codePoint); if (type == Character.UNASSIGNED) { return UNKNOWN; } int scriptIndex = Arrays.binarySearch(unicodeRangeStarts, codePoint); if (scriptIndex < 0) { scriptIndex = -scriptIndex - 2; } return unicodeRangeScripts[scriptIndex]; }
/** * Obtain the OpenType script tags associated with the given Unicode codepoint. * * The result may contain the special value {@code #INHERITED}, which indicates that the * codepoint's script can only be determined by its context. * * Unknown codepoints are mapped to {@code #TAG_DEFAULT}. * * @param codePoint * @return An array of four-char script tags */ public static String[] getScriptTags(int codePoint) { ensureValidCodePoint(codePoint); String unicode = getUnicodeScript(codePoint); return UNICODE_SCRIPT_TO_OPENTYPE_TAG_MAP.get(unicode); }
/** * Obtain the Unicode script associated with the given Unicode codepoint. * * @param codePoint * @return A Unicode script string, or {@code #UNKNOWN} if unknown */ private static String getUnicodeScript(int codePoint) { ensureValidCodePoint(codePoint); int type = Character.getType(codePoint); if (type == Character.UNASSIGNED) { return UNKNOWN; } int scriptIndex = Arrays.binarySearch(unicodeRangeStarts, codePoint); if (scriptIndex < 0) { scriptIndex = -scriptIndex - 2; } return unicodeRangeScripts[scriptIndex]; }
/** * Obtain the OpenType script tags associated with the given Unicode codepoint. * * The result may contain the special value {@code #INHERITED}, which indicates that the * codepoint's script can only be determined by its context. * * Unknown codepoints are mapped to {@code #TAG_DEFAULT}. * * @param codePoint * @return An array of four-char script tags */ public static String[] getScriptTags(int codePoint) { ensureValidCodePoint(codePoint); String unicode = getUnicodeScript(codePoint); return UNICODE_SCRIPT_TO_OPENTYPE_TAG_MAP.get(unicode); }