LibrePDF / OpenPDF

OpenPDF is a free Java library for creating and editing PDF files, with a LGPL and MPL open source license. OpenPDF is based on a fork of iText. We welcome contributions from other developers. Please feel free to submit pull-requests and bugreports to this GitHub repository.
Other
3.41k stars 572 forks source link

Issue with subsetting on OTF/CFF fonts #71

Open zimmyg opened 6 years ago

zimmyg commented 6 years ago

I use OpenPDF in flying saucer to generate PDFs from HTML and I've run into a problem that I cannot use fonts such as NotoSansCJKjp (an OTF/CFF font) because CFF font subsetting does not work correctly.

The subsequent PDF output is broken in Acrobat, stating that the embedded font cannot be extracted. It does work in other readers, but I believe that is because they are more lenient than Acrobat on this issue, but unfortunately using another reader is not an option.

I created a fork of OpenPDF and turned off font subsetting entirely and the output works fine, but obviously this is also not an real solution, because these fonts can be quite large and this particular font results in a minimum PDF size of 12MB, so the problem compounds when using multiple fonts.

I inspected the PDF output with PDFBox's preflight and it errors with "Font DICT invalid without "Private" entry", which does indeed seem to point again to the subsetting being broken, not including a private section in each font dict, which would explain why Acrobat is falling over as well.

I did my best to try and fix this myself, but I've not made much headway so I thought I would reach out to the community and see if anyone has the necessary experience with CFF font subsetting in order to fix this issue.

Thanks

szahariev commented 5 years ago

I have a similar issue. I've created a PDF with Inter UI otf fonts and it looks perfect, but if you print it, it prints very badly (nothing could be read). If you however set subset to false it prints OK, but it is 4 times the original size.

andreasrosdal commented 5 years ago

Pull-requests welcome

codecracker2014 commented 4 years ago

We have fixed substitution problems for TTF fonts by delegating font substitution to Apache FOP which very well supports advanced typography refer #297, #329. Same approach can be used for OTF, CFF and IVS fonts as well which is supported by FOP. Pull requests are welcome.

asturio commented 4 months ago

Can anybody verify it this issue is still unsolved. Maybe it's already fixed, and we forgot to close this issue.

Pull requests are still welcome ;-)

Some example code would be also nice, so we could check, if it already solved.