jsPDF-CustomFonts-support icon indicating copy to clipboard operation
jsPDF-CustomFonts-support copied to clipboard

Buggy output when opened with muPDF

Open kwshi opened this issue 6 years ago • 3 comments

When an external font is embedded in the PDF, it cannot be opened in muPDF correctly: jspdf-mupdf-font Expected output: jspdf-evince-font

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.

kwshi avatar Aug 29 '18 07:08 kwshi

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 avatar Aug 29 '18 07:08 kwshi

@kwshi Do you solved this problem?

Having same problem here with other font...

abisewski avatar Feb 23 '19 19:02 abisewski

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...

kwshi avatar Feb 23 '19 19:02 kwshi