Changeset - r26587:86f25608e9b4
[Not reviewed]
master
0 1 0
PeterN - 19 months ago 2022-11-13 17:10:34
peter1138@openttd.org
Fix #10161: Ignore ascender in FallbackLayouter for non-built-in fonts. (#10169)
1 file changed with 9 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/gfx_layout.cpp
Show inline comments
 
@@ -333,18 +333,25 @@ public:
 
FallbackParagraphLayout::FallbackVisualRun::FallbackVisualRun(Font *font, const WChar *chars, int char_count, int x) :
 
		font(font), glyph_count(char_count)
 
{
 
	const bool isbuiltin = font->fc->IsBuiltInFont();
 

	
 
	this->glyphs = MallocT<GlyphID>(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. */
 
	this->positions = MallocT<float>(this->glyph_count * 2 + 2);
 
	this->positions[0] = x;
 
	this->positions[1] = font->fc->GetAscender();
 

	
 
	for (int i = 0; i < this->glyph_count; 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 + 3] = font->fc->GetAscender();
 
		this->glyph_to_char[i] = i;
 
	}
 
}
0 comments (0 inline, 0 general)