aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Tatham <anakin@pobox.com>2014-06-21 17:40:29 +0000
committerSimon Tatham <anakin@pobox.com>2014-06-21 17:40:29 +0000
commitff8a9fbc541b714e64fc089f75ec712a04cbd90f (patch)
tree5737d5de67df85038926e744ce667bf09100def3
parenta7ddd6337517864d8ae44a20b8225046b6d6fdf3 (diff)
downloadpuzzles-ff8a9fbc541b714e64fc089f75ec712a04cbd90f.zip
puzzles-ff8a9fbc541b714e64fc089f75ec712a04cbd90f.tar.gz
puzzles-ff8a9fbc541b714e64fc089f75ec712a04cbd90f.tar.bz2
puzzles-ff8a9fbc541b714e64fc089f75ec712a04cbd90f.tar.xz
Fix vertically misaligned text in Javascript puzzles.
When I constructed my test canvas to measure the vertical extent of a text string for ALIGN_VCENTRE, I forgot to ensure that the 'width' variable was an integer, as a result of which the loop over canvas pixels kept trying to use fractional array indices and returning undefined :-) [originally from svn r10196]
-rw-r--r--emcclib.js2
1 files changed, 1 insertions, 1 deletions
diff --git a/emcclib.js b/emcclib.js
index 7d001c3..385281a 100644
--- a/emcclib.js
+++ b/emcclib.js
@@ -412,7 +412,7 @@ mergeInto(LibraryManager.library, {
// Find the width of the string
var ctx1 = onscreen_canvas.getContext('2d');
ctx1.font = font;
- var width = ctx1.measureText(midpoint_test_str).width;
+ var width = (ctx1.measureText(midpoint_test_str).width + 1) | 0;
// Construct a test canvas of appropriate size, initialise it to
// black, and draw the string on it in white