mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 08:01:30 -07:00
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]
This commit is contained in:
@ -412,7 +412,7 @@ mergeInto(LibraryManager.library, {
|
|||||||
// Find the width of the string
|
// Find the width of the string
|
||||||
var ctx1 = onscreen_canvas.getContext('2d');
|
var ctx1 = onscreen_canvas.getContext('2d');
|
||||||
ctx1.font = font;
|
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
|
// Construct a test canvas of appropriate size, initialise it to
|
||||||
// black, and draw the string on it in white
|
// black, and draw the string on it in white
|
||||||
|
Reference in New Issue
Block a user