[Scummvm-git-logs] scummvm master -> bf851cc5251c61efe449b3b049c1f1b130d96cae
eriktorbjorn
eriktorbjorn at telia.com
Mon Sep 5 18:42:44 CEST 2016
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:
bf851cc525 GRAPHICS: Handle Windows and Mac line breaks when word-wrapping text
Commit: bf851cc5251c61efe449b3b049c1f1b130d96cae
https://github.com/scummvm/scummvm/commit/bf851cc5251c61efe449b3b049c1f1b130d96cae
Author: Torbjörn Andersson (eriktorbjorn at users.sourceforge.net)
Date: 2016-09-05T18:41:40+02:00
Commit Message:
GRAPHICS: Handle Windows and Mac line breaks when word-wrapping text
This seems like the right place to do it. Hopefully it's also the
right way. It fixes line breaks in the MacVenture engine, where the
text apparently uses Mac line breaks.
Changed paths:
graphics/font.cpp
diff --git a/graphics/font.cpp b/graphics/font.cpp
index 97662dc..7768b73 100644
--- a/graphics/font.cpp
+++ b/graphics/font.cpp
@@ -164,7 +164,16 @@ int wordWrapTextImpl(const Font &font, const StringType &str, int maxWidth, Comm
typename StringType::unsigned_type last = 0;
for (typename StringType::const_iterator x = str.begin(); x != str.end(); ++x) {
- const typename StringType::unsigned_type c = *x;
+ typename StringType::unsigned_type c = *x;
+
+ // Convert Windows and Mac line breaks into plain \n
+ if (c == '\r') {
+ if (x != str.end() && *(x + 1) == '\n') {
+ ++x;
+ }
+ c = '\n';
+ }
+
const int w = font.getCharWidth(c) + font.getKerningOffset(last, c);
last = c;
const bool wouldExceedWidth = (lineWidth + tmpWidth + w > maxWidth);
More information about the Scummvm-git-logs
mailing list