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

bgK bastien.bouclet at gmail.com
Sat Aug 4 06:45:31 CEST 2018


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

Summary:
7362060c47 GRAPHICS: Improve check to test if text fits in the target surface
ad3feae490 MOHAWK: RIVEN: Fix crash when clicking on a marble with the mouse moving


Commit: 7362060c47f5136ba8ea3cd617ef957057ac4296
    https://github.com/scummvm/scummvm/commit/7362060c47f5136ba8ea3cd617ef957057ac4296
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2018-08-03T22:35:16+02:00

Commit Message:
GRAPHICS: Improve check to test if text fits in the target surface

When rendering text, especially truetype fonts, we would use the next
character avance metric to check if the character fits in the target
surface. This commit changes it to use the bounding box metric. The
bounding box represents the actual pixels that will be touched when
drawing the character.

This fixes an issue noticed on the main menu of Myst ME where the last
character of the string "OPTIONEN" would not be rendered despite there
being enough room to render it. More precisely, this ensures that
calling Font::getBoundingBox for a string, and then passing a surface
exactly the size of the returned bounding box to the draw function
actually renders all the characters.

Changed paths:
    graphics/font.cpp


diff --git a/graphics/font.cpp b/graphics/font.cpp
index b84d690..5f1e68c 100644
--- a/graphics/font.cpp
+++ b/graphics/font.cpp
@@ -60,11 +60,11 @@ Common::Rect getBoundingBoxImpl(const Font &font, const StringType &str, int x,
 		const typename StringType::unsigned_type cur = *i;
 		x += font.getKerningOffset(last, cur);
 		last = cur;
-		w = font.getCharWidth(cur);
-		if (x+w > rightX)
+
+		Common::Rect charBox = font.getBoundingBox(cur);
+		if (x + charBox.right > rightX)
 			break;
-		if (x+w >= leftX) {
-			Common::Rect charBox = font.getBoundingBox(cur);
+		if (x + charBox.right >= leftX) {
 			charBox.translate(x, y);
 			if (first) {
 				bbox = charBox;
@@ -73,7 +73,8 @@ Common::Rect getBoundingBoxImpl(const Font &font, const StringType &str, int x,
 				bbox.extend(charBox);
 			}
 		}
-		x += w;
+
+		x += font.getCharWidth(cur);
 	}
 
 	return bbox;
@@ -113,12 +114,14 @@ void drawStringImpl(const Font &font, Surface *dst, const StringType &str, int x
 		const typename StringType::unsigned_type cur = *i;
 		x += font.getKerningOffset(last, cur);
 		last = cur;
-		w = font.getCharWidth(cur);
-		if (x+w > rightX)
+
+		Common::Rect charBox = font.getBoundingBox(cur);
+		if (x + charBox.right > rightX)
 			break;
-		if (x+w >= leftX)
+		if (x + charBox.right >= leftX)
 			font.drawChar(dst, cur, x, y, color);
-		x += w;
+
+		x += font.getCharWidth(cur);
 	}
 }
 


Commit: ad3feae490f8ed8ac74e8c6597963807bf9e278e
    https://github.com/scummvm/scummvm/commit/ad3feae490f8ed8ac74e8c6597963807bf9e278e
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2018-08-04T06:42:17+02:00

Commit Message:
MOHAWK: RIVEN: Fix crash when clicking on a marble with the mouse moving

In some cases a mouse moved event could be handled between the moment
the xtakeit script was queued and the moment it is executed (on the same
frame), causing the mouse position no longer to be over a marble
rectangle.

Fixes #10647.

Changed paths:
    engines/mohawk/riven_stacks/tspit.cpp


diff --git a/engines/mohawk/riven_stacks/tspit.cpp b/engines/mohawk/riven_stacks/tspit.cpp
index 9546d94..85e4b2f 100644
--- a/engines/mohawk/riven_stacks/tspit.cpp
+++ b/engines/mohawk/riven_stacks/tspit.cpp
@@ -362,8 +362,12 @@ void TSpit::xtakeit(const ArgumentArray &args) {
 		}
 	}
 
-	// xtakeit() shouldn't be called if we're not on a marble hotspot
-	assert(marble != 0);
+	if (marble == 0) {
+		// xtakeit() shouldn't be called if we're not on a marble hotspot,
+		// but maybe another mouse moved event was received between the moment
+		// this script was queued and the moment it was executed.
+		return;
+	}
 
 	// Redraw the background
 	_vm->getCard()->drawPicture(1);





More information about the Scummvm-git-logs mailing list