simon-git: puzzles (main): Simon Tatham
Commits to Tartarus hosted VCS
tartarus-commits at lists.tartarus.org
Fri May 26 21:36:56 BST 2023
TL;DR:
b6c842a Emscripten: fix edge case of js_canvas_find_font_midpoint.
Repository: https://git.tartarus.org/simon/puzzles.git
On the web: https://git.tartarus.org/?p=simon/puzzles.git
Branch updated: main
Committer: Simon Tatham <anakin at pobox.com>
Date: 2023-05-26 21:36:56
commit b6c842a28cf6597df063fcff35079c3e3982381e
web diff https://git.tartarus.org/?p=simon/puzzles.git;a=commitdiff;h=b6c842a28cf6597df063fcff35079c3e3982381e;hp=8237b02be4e6f92a9e1aebbed23d7b5de0e3543c
Author: Simon Tatham <anakin at pobox.com>
Date: Fri May 26 21:29:29 2023 +0100
Emscripten: fix edge case of js_canvas_find_font_midpoint.
If the puzzle canvas is at a ludicrously small size, so that you
attempt to use a zero-height font, then obviously nothing sensible
will appear in the way of text, but you'd at least like to avoid a
crash. But currently, js_canvas_find_font_midpoint will make a canvas,
print some height-0 text into it, and try to retrieve the image pixels
to see what the actual font height was - and this will involve asking
getImageData for a zero-sized rectangle of pixels, which is an error.
Of course, there's only one possible return value from this function
if the font height is 0, so we can just return it without going via
getImageData at all.
(This crash can be provoked by trying to resize the puzzle canvas to
Far Too Small, or by interleaving canvas resizes with browser-tab
zooming. I've had one report that it also occurs in less silly
situations, which I haven't been able to reproduce. However, this
seems like a general improvement anyway.)
emcclib.js | 6 ++++++
1 file changed, 6 insertions(+)
More information about the tartarus-commits
mailing list