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

Method GetGlyphToCharMap

src/os/windows/string_uniscribe.cpp:493–514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

491}
492
493std::span<const int> UniscribeParagraphLayout::UniscribeVisualRun::GetGlyphToCharMap() const
494{
495 if (this->glyph_to_char.empty()) {
496 this->glyph_to_char.resize(this->GetGlyphCount());
497
498 /* The char to glyph array contains the first glyph index of the cluster that is associated
499 * with each character. It is possible for a cluster to be formed of several chars. */
500 for (int c = 0; c < (int)this->char_to_glyph.size(); c++) {
501 /* If multiple chars map to one glyph, only refer back to the first character. */
502 if (this->glyph_to_char[this->char_to_glyph[c]] == 0) this->glyph_to_char[this->char_to_glyph[c]] = c + this->start_pos;
503 }
504
505 /* We only marked the first glyph of each cluster in the loop above. Fill the gaps. */
506 int last_char = this->glyph_to_char[0];
507 for (int g = 0; g < this->GetGlyphCount(); g++) {
508 if (this->glyph_to_char[g] != 0) last_char = this->glyph_to_char[g];
509 this->glyph_to_char[g] = last_char;
510 }
511 }
512
513 return this->glyph_to_char;
514}
515
516
517/* virtual */ void UniscribeStringIterator::SetString(std::string_view s)

Callers 2

GetCharPositionMethod · 0.45
GetCharAtPositionMethod · 0.45

Calls 4

GetGlyphCountMethod · 0.95
resizeMethod · 0.80
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected