MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / ItemizeScript

Function ItemizeScript

src/gfx_layout_icu.cpp:302–324  ·  view source on GitHub ↗

* Itemize the string into runs per script, based on the previous created runs. * * Basically, this always returns the same or more runs than given. * * @param buff The string to itemize. * @param length The length of the string. * @param runs_current The current runs. * @return The runs. */

Source from the content-addressed store, hash-verified

300 * @return The runs.
301 */
302std::vector<ICURun> ItemizeScript(UChar *buff, size_t length, std::vector<ICURun> &runs_current)
303{
304 std::vector<ICURun> runs;
305 icu::ScriptRun script_itemizer(buff, length);
306
307 int cur_pos = 0;
308 auto cur_run = runs_current.begin();
309 while (true) {
310 while (cur_pos < script_itemizer.getScriptEnd() && cur_run != runs_current.end()) {
311 int stop_pos = std::min(script_itemizer.getScriptEnd(), cur_run->start + cur_run->length);
312 assert(stop_pos - cur_pos > 0);
313
314 runs.emplace_back(cur_pos, stop_pos - cur_pos, cur_run->level, script_itemizer.getScriptCode());
315
316 if (stop_pos == cur_run->start + cur_run->length) cur_run++;
317 cur_pos = stop_pos;
318 }
319
320 if (!script_itemizer.next()) break;
321 }
322
323 return runs;
324}
325
326/**
327 * Itemize the string into runs per style, based on the previous created runs.

Callers 1

GetParagraphLayoutMethod · 0.85

Calls 5

getScriptEndMethod · 0.80
getScriptCodeMethod · 0.80
beginMethod · 0.45
endMethod · 0.45
nextMethod · 0.45

Tested by

no test coverage detected