galkahana / HummusJS

Node.js module for high performance creation, modification and parsing of PDF files and streams
http://www.pdfhummus.com
Other
1.14k stars 169 forks source link

Throw exception when font is missing a glyph #325

Open phpdave11 opened 5 years ago

phpdave11 commented 5 years ago

I am trying to avoid generating a PDF when the font I'm using doesn't have the glyph(s) that I'm trying to write to the PDF.

For example:

cxt.writeText("Test漢", 0, 0, {
  font: myFont,
  size: 50,
  colorspace: 'cmyk',
  color: 0x8000FF00
});

If "漢" does not exist in myFont, is it possible to have an exception thrown, so that I can handle this error? Currently, the characters are inserted but do not show up properly in the final PDF.