Skip to content

Conversation

@oznogon
Copy link
Contributor

@oznogon oznogon commented Jul 24, 2025

When the final line of a GuiScrollText box ends with characters containing descenders, such as j, y, p, and q, the descender is cut off. Extend the scrolling height of GuiScrollText and GuiScrollFormattedText by 25% of a single line's height to accommodate these descenders.

Before (final line of the Doomed Outpost description on the scenario selection screen):

Screenshot_20250723_224749

After:

Screenshot_20250723_224722

When the final line of a GuiScrollText box ends
with characters containing descenders, such as j,
y, p, and q, the descender is cut off. Extend the
total height of the text for scrolling purposes by
25% of a single line's height to accomodate these
descenders.
@daid
Copy link
Owner

daid commented Jul 24, 2025

Isn't the usedarea from the prepared text wrong then? Not sure where else this is used

@oznogon
Copy link
Contributor Author

oznogon commented Jul 24, 2025

It's wrong for calculating the height of the last line of scrolling text, but it's correct for the line height everywhere else. Consequently fonts without descenders, such as the old all-uppercase font that EE formerly used, never looked wrong.

SeriousProton uses the glyph's horiBearingX and horiBearingY metrics for the bounds position in FreetypeFont::getGlyphInfo. The bearingY value extends only from the font's baseline, so it never includes the descender:

https://freetype.org/freetype2/docs/tutorial/step2.html:

horiBearingY
For horizontal text layouts, this is the vertical distance from the current cursor position (on the baseline) to the topmost border of the glyph image's bounding box.

image

Since getUsedAreaSize relies on the glyph's position y coordinate for the height, it measures the glyph height only from the baseline, ignoring the descender. So we can either track the glyph's height metric which includes ascenders and descenders, or track a descender value (height - horiBearingY) and tack it onto the max_y value in getUsedAreaSize.

FreeType's metrics designed for descenders aren't reliable across fonts since fonts aren't obligated to follow FreeType's standards:

Unfortunately, font formats don't define the descender in a uniform way. For some formats, it represents the descent of all capital latin characters (without accents), for others it is the ascent of the lowest accented character, and finally, other formats define it as being equal to bbox.yMin. ... Notice that the values of the ascender and the descender are not reliable (due to various discrepancies in font formats), unfortunately.

So I'm not sure if there's a better solution. Filed daid/SeriousProton#271.

@oznogon oznogon closed this Jul 24, 2025
@oznogon oznogon deleted the scrolltext-cutoff branch July 24, 2025 19:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants