From 0e1660700ae22712804966449f9b1e36b3b4d1b1 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Sun, 31 May 2026 11:07:41 +0200 Subject: [PATCH] Use the `MathClamp` helper function in the `src/display/canvas.js` file --- src/display/canvas.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/display/canvas.js b/src/display/canvas.js index e104c9fba..e0c6ac8b7 100644 --- a/src/display/canvas.js +++ b/src/display/canvas.js @@ -45,6 +45,7 @@ import { TilingPattern, } from "./pattern_helper.js"; import { convertBlackAndWhiteToRGBA } from "../shared/image_utils.js"; +import { MathClamp } from "../shared/math_clamp.js"; // contexts store most of the state we need natively. // However, PDF needs a bit more state, which we store here. @@ -2481,12 +2482,7 @@ class CanvasGraphics { // Keeping the font at minimal size and using the fontSizeScale to change // the current transformation matrix before the fillText/strokeText. // See https://bugzilla.mozilla.org/show_bug.cgi?id=726227 - let browserFontSize = size; - if (size < MIN_FONT_SIZE) { - browserFontSize = MIN_FONT_SIZE; - } else if (size > MAX_FONT_SIZE) { - browserFontSize = MAX_FONT_SIZE; - } + const browserFontSize = MathClamp(size, MIN_FONT_SIZE, MAX_FONT_SIZE); this.current.fontSizeScale = size / browserFontSize; this.ctx.font = `${italic} ${bold} ${browserFontSize}px ${typeface}`;