aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Snover2016-03-01 09:35:34 -0600
committerColin Snover2016-03-01 09:39:57 -0600
commitf397a7313810f2538a7474aa1f7040252617a2ba (patch)
treeed5791f1398c241ffd5d815c60bf0ff1e2e00f51
parent3c2bec3f3a9e7738b9ec95f860d7f7d095d00f90 (diff)
downloadscummvm-rg350-f397a7313810f2538a7474aa1f7040252617a2ba.tar.gz
scummvm-rg350-f397a7313810f2538a7474aa1f7040252617a2ba.tar.bz2
scummvm-rg350-f397a7313810f2538a7474aa1f7040252617a2ba.zip
SCI32: Fix text size calculation scaling to match SCI
The previous code works correctly only for ratios like 2:1 that do not generate remainders.
-rw-r--r--engines/sci/graphics/text32.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/engines/sci/graphics/text32.cpp b/engines/sci/graphics/text32.cpp
index e393a1c68f..d7738b22c9 100644
--- a/engines/sci/graphics/text32.cpp
+++ b/engines/sci/graphics/text32.cpp
@@ -449,7 +449,8 @@ Common::Rect GfxText32::getTextSize(const Common::String &text, int16 maxWidth,
// weird in the original engine. The initial result rectangle was actually
// a 1x1 rectangle (0, 0, 0, 0), which was then "fixed" after the main
// text size loop finished running by subtracting 1 from the right and
- // bottom edges.
+ // bottom edges. Like other functions in SCI32, this has been converted
+ // to use exclusive rects with inclusive rounding.
Common::Rect result;
@@ -495,18 +496,18 @@ Common::Rect GfxText32::getTextSize(const Common::String &text, int16 maxWidth,
}
} else {
result.right = getTextWidth(0, 10000);
+ // NOTE: In the original engine code, the bottom was not decremented
+ // by 1, which means that the rect was actually a pixel taller than
+ // the height of the font. This was not the case in the other branch,
+ // which decremented the bottom by 1 at the end of the loop.
result.bottom = _font->getHeight() + 1;
}
if (doScaling) {
- // NOTE: The original code did some more complex stuff for edge
- // rounding. The right edge was designed to always round down,
- // and the bottom edge was designed to always round up. It seems
- // we are able to get away with simpler rounding, but it is
- // possible that there are still some edge cases here.
- mul(result, Ratio(scriptWidth, _scaledWidth), Ratio(scriptHeight, _scaledHeight));
- result.right += 1;
- result.bottom += 1;
+ // NOTE: The original engine code also scaled top/left but these are
+ // always zero so there is no reason to do that.
+ result.right = ((result.right - 1) * scriptWidth + _scaledWidth - 1) / _scaledWidth + 1;
+ result.bottom = ((result.bottom - 1) * scriptHeight + _scaledHeight - 1) / _scaledHeight + 1;
}
return result;