diff --git a/library/packet/card-render.js b/library/packet/card-render.js index 24d42a3ce..7b16377a2 100644 --- a/library/packet/card-render.js +++ b/library/packet/card-render.js @@ -141,9 +141,14 @@ export function createCardRenderer({ strings, lang = 'en', stock = 'poker', .nm{position:absolute;display:flex;align-items:center; ${SIDE ? `left:10px;width:${COL - 20}px;top:${12 + PH + 6}px;bottom:10px;align-items:flex-start;justify-content:center;text-align:center;` - : `left:${12 + PW + 12}px;right:12px;top:0;height:${BAND}px;`} - font:700 ${SIDE ? 14 : 17}px Georgia,serif;color:#1b1a17;line-height:1.1;overflow:hidden} + : `left:${12 + PW + 10}px;right:8px;top:0;height:${BAND}px;`} + font:700 ${SIDE ? 14 : 17}px Georgia,serif;color:#1b1a17;line-height:1.1;overflow:hidden; + overflow-wrap:anywhere} + /* Steps by the LONGEST WORD as well as the length: the name sits in a narrow box beside the photo, + and one unbreakable word (the dataset has 16-letter ones, e.g. Pagativeshagallu) would overflow it + sideways. overflow-wrap:anywhere is the last resort, so a name is never cut off without a sign. */ .nm.long{font-size:${SIDE ? 11.5 : 14}px} + .nm.xlong{font-size:${SIDE ? 10.5 : 11}px} .body{position:absolute;right:14px;overflow:hidden; left:${SIDE ? COL + 12 : 14}px; @@ -168,6 +173,14 @@ export function createCardRenderer({ strings, lang = 'en', stock = 'poker', font:400 7px Georgia,serif;color:#b9ae99;text-align:right}`; } + // The name's size step, from its length and its longest word (see .nm above). + function nameSize(name) { + const word = Math.max(0, ...String(name).split(/[\s,()/-]+/).map((w) => w.length)); + if (word >= 14 || name.length > 28) return ' xlong'; + if (word >= 11 || name.length > 16) return ' long'; + return ''; + } + // One card = one page. function card(g) { const name = String(g.name || g.slug || ''); @@ -193,7 +206,7 @@ export function createCardRenderer({ strings, lang = 'en', stock = 'poker', + `