jsPDF-CustomFonts-support
jsPDF-CustomFonts-support copied to clipboard
Buggy output when opened with muPDF
When an external font is embedded in the PDF, it cannot be opened in muPDF correctly:
Expected output:
muPDF also logs the following:
error: freetype: cannot load font: invalid stream operation
warning: ignored error when loading embedded font; attempting to load system font
The code to embed the fonts is as follows:
const pdf = new jsPDF();
pdf.addFileToVFS("Roboto-Regular.ttf", ROBOTO);
pdf.addFileToVFS("Roboto-Bold.ttf", ROBOTO_BOLD);
pdf.addFont("Roboto-Regular.ttf", "Roboto", "normal");
pdf.addFont("Roboto-Bold.ttf", "Roboto", "bold");
Here is the PDF in question: hyperschedule-color.pdf
Other PDF viewers can open the file correctly, so this may be a problem with muPDF. On the other hand, muPDF has also been fine with opening other PDFs with embedded fonts in the past, so I think the problem is not with only muPDF. I suspect that there is some protocol that this library is not following entirely and that other PDF viewers have managed to correct for these errors in a way that muPDF hasn't.
This may be the same issue as #44, but it's worth pointing out that in my cases the problem is specific to muPDF and does not happen using evince or inkscape, etc.
@kwshi Do you solved this problem?
Having same problem here with other font...
I haven't solved this problem--for now, I've only avoided it by not using custom fonts, but that's not a solution at all, only running away from the problem...