Character advance
64-bitThe advance width of one character in 1/1000 em.
Printable ASCII reads the table directly. Wider characters in bold use Math.round(w × 1.04). Unknown characters fall back to 556 or 1000.
export function charAdvance(ch, bold = false) {
ch = SUBST[ch] || ch;
const table = bold ? HELV_BOLD : HELV;
const code = ch.codePointAt(0);
if (code >= 32 && code < 127) return table[code - 32];
const w = CP1252[ch] !== undefined ? WIDE[CP1252[ch]] : WIDE[code];
if (w) return bold ? Math.round(w * 1.04) : w;
const b = ch.normalize('NFD')[0].codePointAt(0);
if (b >= 32 && b < 127) return table[b - 32];
return code >= 0x2e80 ? 1000 : 556;
}