Skip to content

Commit

Permalink
#168 always reduce font size if too wide
Browse files Browse the repository at this point in the history
  • Loading branch information
klues committed Jan 22, 2025
1 parent 2250d39 commit feadffc
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions src/js/util/fontUtil.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,8 @@ fontUtil.getFittingFontSize = function(text, container, options = {}) {
width = fontUtil.getTextWidth(text, container, tryPx);
maxWH = Math.max(width, tryPx);
}
if (count === FONT_ADAPT_MAX_ROUNDS) {
if (maxWH > containerWidth) {
tryPx -= 0.5;
}
if (maxWH > containerWidth) {
tryPx -= 0.5;
tryPx = Math.floor(tryPx);
}
return Math.min(options.maxSize, tryPx, (containerSize.height * options.containerPct / 100) / options.lineHeight);
Expand Down

0 comments on commit feadffc

Please sign in to comment.