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

sev- sev at scummvm.org
Thu Aug 2 18:54:17 CEST 2018


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:
d9b3853dec COMMON: Fix kerning issue in wordWrapText.


Commit: d9b3853decc2d3ac3b500ef3b76f950bd6a6ef4a
    https://github.com/scummvm/scummvm/commit/d9b3853decc2d3ac3b500ef3b76f950bd6a6ef4a
Author: Ľubomír Remák (lubomirr at lubomirr.eu)
Date: 2018-08-02T18:54:13+02:00

Commit Message:
COMMON: Fix kerning issue in wordWrapText.

Changed paths:
    graphics/font.cpp


diff --git a/graphics/font.cpp b/graphics/font.cpp
index 3446619..b84d690 100644
--- a/graphics/font.cpp
+++ b/graphics/font.cpp
@@ -174,7 +174,8 @@ int wordWrapTextImpl(const Font &font, const StringType &str, int maxWidth, Comm
 			c = '\n';
 		}
 
-		const int w = font.getCharWidth(c) + font.getKerningOffset(last, c);
+		const int currentCharWidth = font.getCharWidth(c);
+		const int w = currentCharWidth + font.getKerningOffset(last, c);
 		last = c;
 		const bool wouldExceedWidth = (lineWidth + tmpWidth + w > maxWidth);
 
@@ -212,6 +213,15 @@ int wordWrapTextImpl(const Font &font, const StringType &str, int maxWidth, Comm
 					// assure we do not mess something up because of kerning.
 					tmpWidth = font.getStringWidth(tmpStr);
 				}
+
+				if (tmpStr.empty()) {
+					// If tmpStr is empty, we might have removed the space before 'c'.
+					// That means we have to recompute the kerning.
+
+					tmpWidth += currentCharWidth + font.getKerningOffset(0, c);
+					tmpStr += c;
+					continue;
+				}
 			} else {
 				wrapper.add(tmpStr, tmpWidth);
 			}





More information about the Scummvm-git-logs mailing list