mirror of
https://github.com/OpenTTD/OpenTTD.git
synced 2025-02-01 03:48:43 +00:00
This commit is contained in:
parent
89a2d0a605
commit
cea62ef73d
@ -333,18 +333,25 @@ public:
|
|||||||
FallbackParagraphLayout::FallbackVisualRun::FallbackVisualRun(Font *font, const WChar *chars, int char_count, int x) :
|
FallbackParagraphLayout::FallbackVisualRun::FallbackVisualRun(Font *font, const WChar *chars, int char_count, int x) :
|
||||||
font(font), glyph_count(char_count)
|
font(font), glyph_count(char_count)
|
||||||
{
|
{
|
||||||
|
const bool isbuiltin = font->fc->IsBuiltInFont();
|
||||||
|
|
||||||
this->glyphs = MallocT<GlyphID>(this->glyph_count);
|
this->glyphs = MallocT<GlyphID>(this->glyph_count);
|
||||||
this->glyph_to_char = MallocT<int>(this->glyph_count);
|
this->glyph_to_char = MallocT<int>(this->glyph_count);
|
||||||
|
|
||||||
/* Positions contains the location of the begin of each of the glyphs, and the end of the last one. */
|
/* Positions contains the location of the begin of each of the glyphs, and the end of the last one. */
|
||||||
this->positions = MallocT<float>(this->glyph_count * 2 + 2);
|
this->positions = MallocT<float>(this->glyph_count * 2 + 2);
|
||||||
this->positions[0] = x;
|
this->positions[0] = x;
|
||||||
this->positions[1] = font->fc->GetAscender();
|
|
||||||
|
|
||||||
for (int i = 0; i < this->glyph_count; i++) {
|
for (int i = 0; i < this->glyph_count; i++) {
|
||||||
this->glyphs[i] = font->fc->MapCharToGlyph(chars[i]);
|
this->glyphs[i] = font->fc->MapCharToGlyph(chars[i]);
|
||||||
|
if (isbuiltin) {
|
||||||
|
this->positions[2 * i + 1] = font->fc->GetAscender(); // Apply sprite font's ascender.
|
||||||
|
} else if (chars[i] >= SCC_SPRITE_START && chars[i] <= SCC_SPRITE_END) {
|
||||||
|
this->positions[2 * i + 1] = font->fc->GetAscender() - font->fc->GetGlyph(this->glyphs[i])->height - 1; // Align sprite glyphs to font baseline.
|
||||||
|
} else {
|
||||||
|
this->positions[2 * i + 1] = 0; // No ascender adjustment.
|
||||||
|
}
|
||||||
this->positions[2 * i + 2] = this->positions[2 * i] + font->fc->GetGlyphWidth(this->glyphs[i]);
|
this->positions[2 * i + 2] = this->positions[2 * i] + font->fc->GetGlyphWidth(this->glyphs[i]);
|
||||||
this->positions[2 * i + 3] = font->fc->GetAscender();
|
|
||||||
this->glyph_to_char[i] = i;
|
this->glyph_to_char[i] = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user