1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 22:58:07 +02:00

Correctly compute the font size when printing a text field with an auto font size (bug 1917734)

This commit is contained in:
Calixte Denizet 2024-09-25 09:16:22 +02:00
parent 529906c74f
commit fc1564f476
2 changed files with 6 additions and 5 deletions

View file

@ -2526,12 +2526,13 @@ class WidgetAnnotation extends Annotation {
const roundWithTwoDigits = x => Math.floor(x * 100) / 100;
if (lineCount === -1) {
// Get the text width for a font size of 1.
const textWidth = this._getTextWidth(text, font);
// width / textWidth is the max font size to fit the width.
// height / LINE_FACTOR is the max font size to fit the height.
fontSize = roundWithTwoDigits(
Math.min(
height / LINE_FACTOR,
textWidth > width ? width / textWidth : Infinity
)
Math.min(height / LINE_FACTOR, width / textWidth)
);
numberOfLines = 1;
} else {