Find the longest sequence of characters from 0 and up to length that have at least one common UScriptCode value. Writes the common script value to script and returns the length of the sequence. Takes the characters' script extensions into account. http://www.unicode.org/reports/tr24/#ScriptX Consider 3 characters with the script values {Kana}, {Hira, Kana}, {Kana}. Without script extensions only
| 101 | // Consider 3 characters with the script values {Kana}, {Hira, Kana}, {Kana}. Without script extensions only the first |
| 102 | // script in each set would be taken into account, resulting in 3 segments where 1 would be enough. |
| 103 | size_t ScriptInterval(std::u16string const & text, int32_t start, size_t length, UScriptCode & outScript) |
| 104 | { |
| 105 | ASSERT_GREATER(length, 0U, ()); |
| 106 | |
| 107 | auto const begin = text.begin() + start; |
| 108 | auto const end = text.begin() + start + static_cast<int32_t>(length); |
| 109 | auto iterator = begin; |
| 110 | |
| 111 | auto c32 = utf8::unchecked::next16(iterator); |
| 112 | |
| 113 | TScriptsArray scripts; |
| 114 | size_t scriptsSize = GetScriptExtensions(c32, scripts); |
| 115 | |
| 116 | while (iterator != end) |
| 117 | { |
| 118 | c32 = utf8::unchecked::next16(iterator); |
| 119 | scriptsSize = ScriptSetIntersect(c32, scripts, scriptsSize); |
| 120 | if (scriptsSize == 0U) |
| 121 | { |
| 122 | length = iterator - begin - 1; |
| 123 | break; |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | outScript = scripts[0]; |
| 128 | return length; |
| 129 | } |
| 130 | |
| 131 | // A copy of hb_icu_script_to_script to avoid direct ICU dependency. |
| 132 | hb_script_t ICUScriptToHarfbuzzScript(UScriptCode script) |
no test coverage detected