[Scummvm-git-logs] scummvm master -> cb224864fc88819a2a8ae994ba43f1bb00383a6f

stevenhoefel stevenhoefel at hotmail.com
Sun Apr 5 03:27:12 UTC 2020


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
cb224864fc GRAPHICS: MACGUI: Align text to bottom if font-size changes during chunk.


Commit: cb224864fc88819a2a8ae994ba43f1bb00383a6f
    https://github.com/scummvm/scummvm/commit/cb224864fc88819a2a8ae994ba43f1bb00383a6f
Author: stevenhoefel (stevenhoefel at hotmail.com)
Date: 2020-04-05T13:27:03+10:00

Commit Message:
GRAPHICS: MACGUI: Align text to bottom if font-size changes during chunk.

Changed paths:
    graphics/macgui/mactext.cpp


diff --git a/graphics/macgui/mactext.cpp b/graphics/macgui/mactext.cpp
index 56e5a75fbb..3cdb67da28 100644
--- a/graphics/macgui/mactext.cpp
+++ b/graphics/macgui/mactext.cpp
@@ -346,6 +346,12 @@ void MacText::render(int from, int to) {
 		else if (_textAlignment == kTextAlignCenter)
 			xOffset = (_textMaxWidth / 2) - (getLineWidth(i) / 2);
 
+		int maxHeightForRow = 0;
+		for (uint j = 0; j < _textLines[i].chunks.size(); j++) {
+			if (_textLines[i].chunks[j].font->getFontHeight() > maxHeightForRow)
+				maxHeightForRow = _textLines[i].chunks[j].font->getFontHeight();
+		}
+
 		// TODO: _textMaxWidth, when -1, was not rendering ANY text.
 		for (uint j = 0; j < _textLines[i].chunks.size(); j++) {
 			debug(9, "MacText::render: line %d[%d] h:%d at %d,%d (%s) fontid: %d on %dx%d",
@@ -355,7 +361,14 @@ void MacText::render(int from, int to) {
 			if (_textLines[i].chunks[j].text.empty())
 				continue;
 
-			_textLines[i].chunks[j].getFont()->drawString(_surface, _textLines[i].chunks[j].text, xOffset, _textLines[i].y, w, _fgcolor);
+			//TODO: There might be a vertical alignment setting somewhere for differing font sizes in a single row?
+			int yOffset = 0;
+			if (_textLines[i].chunks[j].font->getFontHeight() < maxHeightForRow) {
+				//TODO: determine where the magic value 2 comes from
+				yOffset = maxHeightForRow - _textLines[i].chunks[j].font->getFontHeight() - 2;
+			}
+
+			_textLines[i].chunks[j].getFont()->drawString(_surface, _textLines[i].chunks[j].text, xOffset, _textLines[i].y + yOffset, w, _fgcolor);
 			xOffset += _textLines[i].chunks[j].getFont()->getStringWidth(_textLines[i].chunks[j].text);
 		}
 	}




More information about the Scummvm-git-logs mailing list