toPNG() throws a TypeError when the multilingual setting i.e. the common Latin/English is chosen. This is reproducible on the Designer demo — open the browser console and click the PNG download button with the default content.
Reproduce
await Receipt.from('Hello World', '-c 48 -l en -p escpos').toPNG();
// TypeError: Cannot read properties of null (reading 'toLowerCase')
toSVG() is unaffected.
Root Cause
Inside Base64PNG.from(), the PNG renderer reads a lang attribute from the generated SVG's <g> element:
const lang = group.getAttribute('lang').toLowerCase() || 'en';
The SVG renderer only writes that attribute for CJK/Thai scripts. For Latin content the attribute is never set, so getAttribute('lang') returns null and .toLowerCase() throws.
Fix
- const lang = group.getAttribute('lang').toLowerCase() || 'en';
+ const lang = (group.getAttribute('lang') ?? 'en').toLowerCase() || 'en';
toPNG()throws aTypeErrorwhen the multilingual setting i.e. the common Latin/English is chosen. This is reproducible on the Designer demo — open the browser console and click the PNG download button with the default content.Reproduce
toSVG()is unaffected.Root Cause
Inside
Base64PNG.from(), the PNG renderer reads alangattribute from the generated SVG's<g>element:The SVG renderer only writes that attribute for CJK/Thai scripts. For Latin content the attribute is never set, so
getAttribute('lang')returnsnulland.toLowerCase()throws.Fix