Skip to content

Commit fe6809b

Browse files
committed
address feedback
1 parent 260628b commit fe6809b

1 file changed

Lines changed: 4 additions & 3 deletions

File tree

scripts/generateOgImages.mjs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,11 @@ const boldFont = opentype.parse(
5353
// leaves an orphaned letter on its own line, so instead shrink them just
5454
// enough to fit on a single line.
5555
function titleFontSize(title) {
56-
if (/\s/.test(title.trim())) {
57-
return title.length > 24 ? 72 : 96;
56+
const trimmed = title.trim();
57+
if (/\s/.test(trimmed)) {
58+
return trimmed.length > 24 ? 72 : 96;
5859
}
59-
const widthPerPx = boldFont.getAdvanceWidth(title, 1);
60+
const widthPerPx = boldFont.getAdvanceWidth(trimmed, 1);
6061
const fit = Math.floor((TITLE_MAX_WIDTH - TITLE_SAFETY) / widthPerPx);
6162
return Math.max(TITLE_MIN_FONT, Math.min(TITLE_MAX_FONT, fit));
6263
}

0 commit comments

Comments
 (0)