Wall of People Groups: the last three long names fit their cards
A name is measured wider (0.72 em a bold character) and a wrapped name gets the lines it needs, up to three, on the poster and on the wall alike.
This commit is contained in:
parent
0c9772784d
commit
fab6cb695f
2 changed files with 13 additions and 7 deletions
|
|
@ -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 ? `<div class="vs" dir="auto">${esc(v.text)}</div><div class="rf" dir="auto">${esc(v.ref)}</div>` : ''
|
||||
const nf = cardText(plan, g.name || '').name
|
||||
return `<div class="card" style="left:${f(c.x)};top:${f(c.y)};width:${f(c.w)};height:${f(c.h)}">`
|
||||
+ `<div class="nm${nf.wrap ? ' w2' : ''}" dir="auto" style="font-size:${nf.pt}pt">${esc(g.name || '')}</div>${img}${verse}</div>`
|
||||
+ `<div class="nm${nf.wrap ? ' w2' : ''}" dir="auto" style="font-size:${nf.pt}pt${nf.wrap ? ';-webkit-line-clamp:' + nf.lines : ''}">${esc(g.name || '')}</div>${img}${verse}</div>`
|
||||
}
|
||||
const pages = plan.bands.map((bd) => {
|
||||
const s = bd.s, last = s === plan.bands.length - 1
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue