Skip to content

Commit

Permalink
Fix crash when using too small text annotation font size
Browse files Browse the repository at this point in the history
  • Loading branch information
mrtcode committed Dec 17, 2024
1 parent aa8b6cb commit f9857be
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/annotations/write.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,10 +222,10 @@ async function annotationToRaw(annotation, fontEmbedder) {
let lines;
let n = 0;
// Reduce font size to fit the text within the annotation area
while (n++ < 20 && fontSize > 4) {
while (n++ < 20) {
maxLines = Math.floor(height / (fontSize * lineHeightMultiplier));
lines = calculateLines(chars, fontSize, width);
if (lines.length > maxLines) {
if (lines.length > maxLines && fontSize > 4) {
fontSize -= 0.5;
continue;
}
Expand Down

0 comments on commit f9857be

Please sign in to comment.