SHERLOCK: Calculate font height/width more accurately

Each character in a font can have an X and Y offset. This was not
considered when calculating the width and height of the font. One way
this could be noticed was in Serrated Scalpel, when talking to a
character with a lot of conversation options. Scrolling down would
highlight the "Up" button. Selecting a conversation option would then
dim the button, but the bottommost pixel of the "p" was still
highlighted.

Hopefully this does not negatively affect anything else.
This commit is contained in:
Torbjörn Andersson 2021-12-14 16:47:31 +01:00 committed by Paul Gilbert
parent d97779fc25
commit 748ba7353a

View file

@ -131,8 +131,8 @@ void Fonts::setFont(int fontNum) {
// Iterate through the frames to find the widest and tallest font characters
_fontHeight = _widestChar = 0;
for (uint idx = 0; idx < MIN<uint>(_charCount, 128 - 32); ++idx) {
_fontHeight = MAX((int16)_fontHeight, (*_font)[idx]._frame.h);
_widestChar = MAX((int16)_widestChar, (*_font)[idx]._frame.w);
_fontHeight = MAX(_fontHeight, (*_font)[idx]._frame.h + (*_font)[idx]._offset.y);
_widestChar = MAX(_widestChar, (*_font)[idx]._frame.w + (*_font)[idx]._offset.x);
}
// Initialize the Y offset table for the extended character set