mirror of
https://github.com/mozilla/pdf.js.git
synced 2026-08-02 20:37:21 +02:00
Use the MathClamp helper function in the src/display/canvas.js file
This commit is contained in:
parent
145feeaa3f
commit
0e1660700a
@ -45,6 +45,7 @@ import {
|
|||||||
TilingPattern,
|
TilingPattern,
|
||||||
} from "./pattern_helper.js";
|
} from "./pattern_helper.js";
|
||||||
import { convertBlackAndWhiteToRGBA } from "../shared/image_utils.js";
|
import { convertBlackAndWhiteToRGBA } from "../shared/image_utils.js";
|
||||||
|
import { MathClamp } from "../shared/math_clamp.js";
|
||||||
|
|
||||||
// <canvas> contexts store most of the state we need natively.
|
// <canvas> contexts store most of the state we need natively.
|
||||||
// However, PDF needs a bit more state, which we store here.
|
// 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
|
// Keeping the font at minimal size and using the fontSizeScale to change
|
||||||
// the current transformation matrix before the fillText/strokeText.
|
// the current transformation matrix before the fillText/strokeText.
|
||||||
// See https://bugzilla.mozilla.org/show_bug.cgi?id=726227
|
// See https://bugzilla.mozilla.org/show_bug.cgi?id=726227
|
||||||
let browserFontSize = size;
|
const browserFontSize = MathClamp(size, MIN_FONT_SIZE, MAX_FONT_SIZE);
|
||||||
if (size < MIN_FONT_SIZE) {
|
|
||||||
browserFontSize = MIN_FONT_SIZE;
|
|
||||||
} else if (size > MAX_FONT_SIZE) {
|
|
||||||
browserFontSize = MAX_FONT_SIZE;
|
|
||||||
}
|
|
||||||
this.current.fontSizeScale = size / browserFontSize;
|
this.current.fontSizeScale = size / browserFontSize;
|
||||||
|
|
||||||
this.ctx.font = `${italic} ${bold} ${browserFontSize}px ${typeface}`;
|
this.ctx.font = `${italic} ${bold} ${browserFontSize}px ${typeface}`;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user