* Create the visual run. * @param font The font to use for this run. * @param chars The characters to use for this run. * @param char_count The number of characters in this run. * @param char_offset This run's offset from the start of the layout input string. * @param x The initial x position for this run. */
| 110 | * @param x The initial x position for this run. |
| 111 | */ |
| 112 | FallbackParagraphLayout::FallbackVisualRun::FallbackVisualRun(Font *font, const char32_t *chars, int char_count, int char_offset, int x) : |
| 113 | font(font) |
| 114 | { |
| 115 | const bool isbuiltin = font->fc->IsBuiltInFont(); |
| 116 | |
| 117 | this->glyphs.reserve(char_count); |
| 118 | this->glyph_to_char.reserve(char_count); |
| 119 | this->positions.reserve(char_count); |
| 120 | |
| 121 | int advance = x; |
| 122 | for (int i = 0; i < char_count; i++) { |
| 123 | const GlyphID &glyph_id = this->glyphs.emplace_back(font->fc->MapCharToGlyph(chars[i])); |
| 124 | int x_advance = font->fc->GetGlyphWidth(glyph_id); |
| 125 | if (isbuiltin) { |
| 126 | this->positions.emplace_back(advance, advance + x_advance - 1, font->fc->GetAscender()); // Apply sprite font's ascender. |
| 127 | } else if (chars[i] >= SCC_SPRITE_START && chars[i] <= SCC_SPRITE_END) { |
| 128 | this->positions.emplace_back(advance, advance + x_advance - 1, (font->fc->GetHeight() - ScaleSpriteTrad(FontCache::GetDefaultFontHeight(font->fc->GetSize()))) / 2); // Align sprite font to centre |
| 129 | } else { |
| 130 | this->positions.emplace_back(advance, advance + x_advance - 1, 0); // No ascender adjustment. |
| 131 | } |
| 132 | advance += x_advance; |
| 133 | this->glyph_to_char.push_back(char_offset + i); |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | /** |
| 138 | * Get the height of the line. |
nothing calls this directly
no test coverage detected