Page 1 of 1

Support for Myriad Pro (CFF) font

PostPosted: Mon Aug 03, 2015 10:33 pm
by dileeph
Hi,
I am trying to convert a docx file to pdf using docx4j after binding values to it. If I save the output as a word document, Myriad Pro font is retained. However when pdf is generated it falls back to Helvetica and Calibri (looking at the pdf font properties). Intermediate fop file also shows font as Calibri.
Going through the code I see that if font is of type CFF it throws an UnsupportedOperationException ( "OpenType fonts with CFF data are not supported, yet"). I assume it is a throwback to the version 0.9x version of fop that was used to build docx4j (my assumption entirely based on some hints i saw in java src comments).

So is there a way to make docx4j generate PDF retaining the Myriad Pro font? Like leveraging fop 2?
Also if the free version is not capable of this, will the commercial version support it?
Any inputs appreciated.

( I had actually raised this initially in Github issues... moving here since this may be a better "forum")

Re: Support for Myriad Pro (CFF) font

PostPosted: Mon Aug 03, 2015 11:55 pm
by jason
Yes, org.docx4j.fonts.fop.fonts.truetype.TTFFontLoader is repackaged code from a now old version of FOP.

If newer FOP code can handle CFF, that's great; we'd be happy to accept a patch containing that support re-packaged.

Re: Support for Myriad Pro (CFF) font

PostPosted: Tue Aug 04, 2015 1:45 am
by dileeph
Thanks for your quick response Jason. I was hoping that this has been resolved in the Commercial version.
I tried to see if it can be quick-patched, but there are some considerable API changes in FOP (being major version upgrade). So if there are no ready-made solutions, let me see if I can get some time to do a patch.
I am somewhat curious to know why fop-1.1 is a dependency for your project (at least maven downloads that) and at the same time you have some code copied into your source. Are you doing something special there? So if I manage to change to v 2.0 are there some gotchas I need to watch out for?

Also any particular reason why the itext version was abandoned? IText 2 does support CFF fonts.

Again, inputs appreciated if you have the time.

Re: Support for Myriad Pro (CFF) font

PostPosted: Tue Aug 04, 2015 9:59 am
by jason
dileeph wrote:Thanks for your quick response Jason. I was hoping that this has been resolved in the Commercial version.
I tried to see if it can be quick-patched, but there are some considerable API changes in FOP (being major version upgrade). So if there are no ready-made solutions, let me see if I can get some time to do a patch.
I am somewhat curious to know why fop-1.1 is a dependency for your project (at least maven downloads that) and at the same time you have some code copied into your source.


Just the font package was copied/repackaged, a small part of the overall FOP code base, and if you want PDF output via XSL FO using FOP as the FO renderer, you need the rest of it.

FYI the plan for doc4j 3.4.0 is to move the FO based output into a separate sub-project, so FOP would become a dependency of that, not of docx4j 3.4.0 itself.

dileeph wrote:Are you doing something special there? So if I manage to change to v 2.0 are there some gotchas I need to watch out for?


When was CFF support added in FOP (ie by which commit)? You might look at adding just that.

dileeph wrote:Also any particular reason why the itext version was abandoned? IText 2 does support CFF fonts.


At the time, primarily because the XSL FO approach was going to yield a quicker time to "good enough" (for many) output, and we wanted to focus resources/effort on a single approach.

More recently of course, iText went commercial. They could fuel further uptake of their product if they wished, by resurrecting the docx4j-iText output and making it commercial quality.