Merge pull request #15592 from calixteman/1794403
[Annotation] Take the border into account when computing the font size (bug 1794403)
This commit is contained in:
commit
cc450b405d
@ -974,17 +974,26 @@ class WidgetAnnotationElement extends AnnotationElement {
|
|||||||
// If the height is "big" then it could lead to a too big font size
|
// If the height is "big" then it could lead to a too big font size
|
||||||
// so in this case use the one we've in the pdf (hence the min).
|
// so in this case use the one we've in the pdf (hence the min).
|
||||||
let computedFontSize;
|
let computedFontSize;
|
||||||
|
const BORDER_SIZE = 2;
|
||||||
|
const roundToOneDecimal = x => Math.round(10 * x) / 10;
|
||||||
if (this.data.multiLine) {
|
if (this.data.multiLine) {
|
||||||
const height = Math.abs(this.data.rect[3] - this.data.rect[1]);
|
const height = Math.abs(
|
||||||
|
this.data.rect[3] - this.data.rect[1] - BORDER_SIZE
|
||||||
|
);
|
||||||
const numberOfLines = Math.round(height / (LINE_FACTOR * fontSize)) || 1;
|
const numberOfLines = Math.round(height / (LINE_FACTOR * fontSize)) || 1;
|
||||||
const lineHeight = height / numberOfLines;
|
const lineHeight = height / numberOfLines;
|
||||||
computedFontSize = Math.min(
|
computedFontSize = Math.min(
|
||||||
fontSize,
|
fontSize,
|
||||||
Math.round(lineHeight / LINE_FACTOR)
|
roundToOneDecimal(lineHeight / LINE_FACTOR)
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
const height = Math.abs(this.data.rect[3] - this.data.rect[1]);
|
const height = Math.abs(
|
||||||
computedFontSize = Math.min(fontSize, Math.round(height / LINE_FACTOR));
|
this.data.rect[3] - this.data.rect[1] - BORDER_SIZE
|
||||||
|
);
|
||||||
|
computedFontSize = Math.min(
|
||||||
|
fontSize,
|
||||||
|
roundToOneDecimal(height / LINE_FACTOR)
|
||||||
|
);
|
||||||
}
|
}
|
||||||
style.fontSize = `calc(${computedFontSize}px * var(--scale-factor))`;
|
style.fontSize = `calc(${computedFontSize}px * var(--scale-factor))`;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user