diff --git a/plugin-designs/wall-of-people-groups/src/blessPoster.js b/plugin-designs/wall-of-people-groups/src/blessPoster.js index c7484e575..2d9cec333 100644 --- a/plugin-designs/wall-of-people-groups/src/blessPoster.js +++ b/plugin-designs/wall-of-people-groups/src/blessPoster.js @@ -97,16 +97,22 @@ const ICONS = { * two cannot drift. Sizes in points, lengths in inches. * · the reference prints at the verse's size × 0.8, never below MIN_READABLE_PT (a reference that can't * be read is noise); verse and reference are only printed on sizes whose verses are readable; - * · a long name shrinks to fit its line (bold ≈ 0.68 em a character, measured wide on purpose), down to - * MIN_READABLE_PT (or the preset's own name size if that is smaller); still too long, it takes two lines. + * · a long name shrinks to fit its line (bold ≈ 0.72 em a character: measured wide on purpose, rega found + * 0.68 left "Kummara, Kumbara" 2 px over), down to MIN_READABLE_PT (or the preset's own name size if that + * is smaller); still too long, it wraps, at the size that fits two lines, or three at the floor. */ export function cardText(plan, name) { const vPt = plan.text.versePt, nPt = plan.text.namePt - const want = (plan.cw * 0.93 / PT) / (Math.max(1, String(name).length) * 0.68) - const pt = Math.max(Math.min(nPt, MIN_READABLE_PT), Math.min(nPt, want)) + const EM = 0.72, inner = plan.cw * 0.93 / PT, len = Math.max(1, String(name).length) + const floor = Math.min(nPt, MIN_READABLE_PT), want = inner / (len * EM) + const wrap = want < floor + // Wrapped: the size that fits two lines (not below the floor), and as many lines (≤ 3) as that size needs. + const pt = wrap ? Math.max(floor, Math.min(nPt, (2 * inner) / (len * EM))) : Math.min(nPt, want) + // (× 1.2: a line breaks at a word, so it is rarely full; rega measured a 3-line name the plain sum called 2) + const lines = wrap ? Math.min(3, Math.ceil((len * EM * pt * 1.2) / inner)) : 1 return { readable: plan.text.readable, versePt: vPt, refPt: +Math.max(MIN_READABLE_PT, vPt * 0.8).toFixed(1), - name: { pt: +pt.toFixed(1), wrap: want < pt }, + name: { pt: Math.floor(pt * 10) / 10, wrap, lines }, padIn: plan.cw * 0.035, imgMarginIn: plan.cw * 0.02, nameLine: 1.1, verseLine: 1.15, refGapPt: 1, } } @@ -176,7 +182,7 @@ function posterParts(groups, presetId, texts, withCards = true) { const verse = plan.text.readable ? `
${esc(v.text)}
${esc(v.ref)}
` : '' const nf = cardText(plan, g.name || '').name return `
` - + `
${esc(g.name || '')}
${img}${verse}
` + + `
${esc(g.name || '')}
${img}${verse}` } const pages = plan.bands.map((bd) => { const s = bd.s, last = s === plan.bands.length - 1 diff --git a/plugin-designs/wall-of-people-groups/src/wallCanvas.js b/plugin-designs/wall-of-people-groups/src/wallCanvas.js index 75cee6048..7c0d32825 100644 --- a/plugin-designs/wall-of-people-groups/src/wallCanvas.js +++ b/plugin-designs/wall-of-people-groups/src/wallCanvas.js @@ -212,7 +212,7 @@ export class WallCanvas { if (!T) { // Line breaks measured once per card (the fonts are the print's), then cached. ctx.font = `700 ${nameFs}px -apple-system, "Segoe UI", Arial, sans-serif` - const nameLines = ct.name.wrap ? this.breakLines(ctx, name, iw, 2) : [name] + const nameLines = ct.name.wrap ? this.breakLines(ctx, name, iw, ct.name.lines) : [name] let verse = null if (ct.readable) { const b = blessingFor(R.i)