diff options
author | Torbjörn Andersson | 2016-09-05 18:41:40 +0200 |
---|---|---|
committer | Torbjörn Andersson | 2016-09-05 18:41:40 +0200 |
commit | bf851cc5251c61efe449b3b049c1f1b130d96cae (patch) | |
tree | bacf531b543dfecf816c8914c15571f487807c8d /graphics/font.cpp | |
parent | d527a16e2fdb2dcd119ce93d5482ae85f4259e57 (diff) | |
download | scummvm-rg350-bf851cc5251c61efe449b3b049c1f1b130d96cae.tar.gz scummvm-rg350-bf851cc5251c61efe449b3b049c1f1b130d96cae.tar.bz2 scummvm-rg350-bf851cc5251c61efe449b3b049c1f1b130d96cae.zip |
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.
Diffstat (limited to 'graphics/font.cpp')
-rw-r--r-- | graphics/font.cpp | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/graphics/font.cpp b/graphics/font.cpp index 97662dc15d..7768b7362d 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); |