font-family not working when running XSL-FO via XProc

Here should go questions about transforming XML with XSLT and FOP.
Martin de la Iglesia
Posts: 13
Joined: Tue Aug 22, 2017 5:43 pm

font-family not working when running XSL-FO via XProc

Post by Martin de la Iglesia » Thu Jun 06, 2019 5:46 pm

Hi,
I have written an FO stylesheet to transform XML to PDF, which works fine when I execute it as an XSLT Transformation Scenario. Now I'd like to integrate this stylesheet into my XProc pipeline. However, when I invoke the exact same FO stylesheet via an XProc Transformation Scenario, the resulting PDF contains the wrong font. Instead of a sans-serif font it's now a serif font, and some special characters are displayed as "#" (e.g. "Kou#im" instead of "Kouřim"). Everything else about the PDF is correct. It looks like the setting

<fo:root font-family="Arial Unicode MS">

in the XSL-FO gets ignored. No error messages or warnings are shown. Any idea why the same XSL-FO behaves differently in the XSLT Transformation Scenario and XProc? (And how to fix that?)

Radu
Posts: 6541
Joined: Fri Jul 09, 2004 5:18 pm

Re: font-family not working when running XSL-FO via XProc

Post by Radu » Thu Jun 13, 2019 9:16 pm

Hi Martin,

We are not very familiar with using XProc to generate PDF. Are you using Apache FOP for this or the XEP formatter? How did you set this up? Can you also give us a sample XProc script to test on our side. For Apache FOP there usually can be specified a "fop.xconf" configuration file which usually has an auto-detect statement for fonts installed in the system. But I'm not sure how this can be done with Calabash, maybe you can ask around on the Calabash users list.
Also for RenderX XEP there is an xep.xml which might need some tinkering:
https://www.oxygenxml.com/doc/versions/ ... h_xep.html

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Martin de la Iglesia
Posts: 13
Joined: Tue Aug 22, 2017 5:43 pm

Re: font-family not working when running XSL-FO via XProc

Post by Martin de la Iglesia » Mon Jun 17, 2019 3:24 pm

Hi Radu,

here's an XProc:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" xmlns:c="http://www.w3.org/ns/xproc-step" version="1.0" name="myPipeline">
    <p:input port="source">
        <p:empty/>
    </p:input>

    <p:xslt name="xsl-fo-test">
        <p:input port="source">
            <p:document href="fonttest.xpl"/>           
        </p:input>
        <p:input port="stylesheet">
            <p:document href="fonttest_tei2xsl-fo.xsl"/>
        </p:input>
        <p:input port="parameters">
            <p:empty/>
        </p:input>
    </p:xslt>
    <p:xsl-formatter name="test" href="fonttest.pdf" content-type="application/pdf">
        <p:with-param name="UserConfig" select="resolve-uri('fop.xconf', static-base-uri())"/>
        <p:input port="source">
            <p:pipe port="result" step="xsl-fo-test"/>
        </p:input>
        <p:input port="parameters">
            <p:empty/>
        </p:input>
    </p:xsl-formatter>

</p:declare-step>
This is the XSLT:

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fo="http://www.w3.org/1999/XSL/Format" exclude-result-prefixes="xs" version="2.0">

    <xsl:template match="/">
        <fo:root font-family="Arial Unicode MS">
            <fo:layout-master-set>
                <fo:simple-page-master master-name="test" page-height="297mm" page-width="210mm" margin-top="3cm" margin-bottom="5cm" margin-left="3cm" margin-right="3cm">
                    <fo:region-body/>
                </fo:simple-page-master>
            </fo:layout-master-set>

            <fo:page-sequence master-reference="test">
                <fo:flow flow-name="xsl-region-body">
                    <fo:block-container font-family="serif">
                        <fo:block>
                            <xsl:text>Gallia est omnis divisa in pařtes třes</xsl:text>
                        </fo:block>
                    </fo:block-container>
                    <fo:block-container>
                        <fo:block>
                            <xsl:text>Quařum unam incolunt Belgae, aliam Aquitani</xsl:text>
                        </fo:block>                       
                    </fo:block-container>
                </fo:flow>
            </fo:page-sequence>
        </fo:root>
    </xsl:template>

</xsl:stylesheet>
Here's the xconf file:

Code: Select all

<?xml version="1.0"?>
<fop version="1.0">
    <renderers>
        <renderer mime="application/pdf">
            <fonts>
                <directory recursive="true">fonts</directory> <!-- contains ARIALUNI.TTF -->
            </fonts>
        </renderer>
    </renderers>
</fop>
As I have described in my previous post, the XSLT works when executed as a Transformation Scenario, but not via XProc.

In the (non-XProc) Transformation Scenario, I have set Transformator to Saxon-PE 9.8.0.12, checked the FO Transformation checkbox, set Method to pdf and Processor to Apache FOP.

In the XProc Transformation Scenario, I have set the XProc processor to Add-on for Calabash XProc Engine. All other settings are default.

Radu
Posts: 6541
Joined: Fri Jul 09, 2004 5:18 pm

Re: font-family not working when running XSL-FO via XProc

Post by Radu » Fri Jun 21, 2019 10:39 am

Hello Martin,

Sorry for the delay. In my opinion the user config file is not passed at all to the Apache FOP.
What is my opinion based on:

1) I can change the name of the fop.xconf file to something else in the Xproc file and is still works.
2) Looking at the Java code Norman Walsh has for running FOP 2.x:

https://github.com/ndw/xmlcalabash1-pri ... FoFOP.java

the code which was supposed to send the parameter to the FOP engine is commented out:

Code: Select all

            /* FIXME:
            s = getStringProp("UserConfig");
            if (s != null) {
                fopFactory.setUserConfig(s);
            }
            */
So I'm not sure if there is a workaround for this.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

ndw
Posts: 2
Joined: Wed Aug 08, 2018 11:52 pm

Re: font-family not working when running XSL-FO via XProc

Post by ndw » Thu Sep 19, 2019 6:56 pm

I've just published a 1.2.0 version of the xmlcalabash1-print library that should fix this issue. (It may not turn up in Maven for a few minutes.)

I have dropped support for FOP 1.x.

It's possible that additional FOP 2.x properties would be nice to have; feel free to make feature requests :-)

Radu
Posts: 6541
Joined: Fri Jul 09, 2004 5:18 pm

Re: font-family not working when running XSL-FO via XProc

Post by Radu » Fri Sep 20, 2019 7:59 am

Hi Norman,

Thanks for the update. We'll update the Calabash version shipped with Oxygen probably next year in January when we plan to release Oxygen 22.
In the meantime Martin can probably try to download the new library and then merge it in the "OXYGEN_INSTALL_DIR\lib\xproc\calabash" folder, changing both the "engine.xml" to refer to the new library name and also add it to the "calabash/lib" folder and remove the old library.
Instead of having Calabash directly integrated in Oxygen we should have probably packed it as an optional add-on. This would have allowed us to update the add-on more frequently and maybe also offer a separate experimental add-on for Calabash 2.x.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Martin de la Iglesia
Posts: 13
Joined: Tue Aug 22, 2017 5:43 pm

Re: font-family not working when running XSL-FO via XProc

Post by Martin de la Iglesia » Mon Oct 21, 2019 12:55 pm

Thank you, Norman and Radu.
I'm not sure if this is what you meant, Radu, but I just downloaded the new xmlcalabash1-print-1.2.0.jar from https://github.com/ndw/xmlcalabash1-print/releases to replace the old xmlcalabash1-print-1.1.5.jar in the C:\Program Files\Oxygen XML Editor 20\lib\xproc\calabash\lib directory; and I changed the engine.xml accordingly. This leads to a strange error message when executing my XProc:
Add-on for Calabash XProc Engine requires a Java Virtual Machine (JVM) version that is greater than or equal to 1.7.
Currently, oXygen is using JVM: 1.8.0_172.

Radu
Posts: 6541
Joined: Fri Jul 09, 2004 5:18 pm

Re: font-family not working when running XSL-FO via XProc

Post by Radu » Mon Oct 21, 2019 2:08 pm

Hi,

The error message is silly (and we'll rectify it) but it seems that Norm compiled the xmlcalabash1-print-1.2.0.jar library using Java 11 so you actually need an Oxygen installation with Java 11 or newer to use it (or Norm maybe could provide a Java 1.8 compiled equivalent).
For Oxygen 21.1 we have a kit which comes bundled with Java 12 Open JDK and which should work:

https://www.oxygenxml.com/xml_editor/do ... ditor.html

I also added this issue on the Calabash issues list:

https://github.com/ndw/xmlcalabash1-print/issues/4

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Martin de la Iglesia
Posts: 13
Joined: Tue Aug 22, 2017 5:43 pm

Re: font-family not working when running XSL-FO via XProc

Post by Martin de la Iglesia » Mon Oct 21, 2019 2:53 pm

I just installed Oxygen 21.1, but I get essentially the same error message there:
Add-on for Calabash XProc Engine requires a Java Virtual Machine (JVM) version that is greater than or equal to 1.7.
Currently, oXygen is using JVM: 1.8.0_202.

Radu
Posts: 6541
Joined: Fri Jul 09, 2004 5:18 pm

Re: font-family not working when running XSL-FO via XProc

Post by Radu » Mon Oct 21, 2019 2:56 pm

Hi,

You installed the Oxygen 21.1 bundled with Java 1.8, there was an extra link on the download page for the Java 12 bundled kit.
I'm pasting the direct link below:

https://www.oxygenxml.com/InstData/Edit ... penjdk.exe

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Martin de la Iglesia
Posts: 13
Joined: Tue Aug 22, 2017 5:43 pm

Re: font-family not working when running XSL-FO via XProc

Post by Martin de la Iglesia » Mon Oct 21, 2019 4:08 pm

Thank you, Radu, I had indeed downloaded the wrong version at first.
Now that I have the correct version installed, I can confirm that Calabash now finds the .xconf file, and my PDFs are finally rendered in the font that I wanted! :-)

Post Reply