Page 1 of 1

DITA Fo plugin: adding fonts

Posted: Wed Jan 14, 2009 5:09 am
by Nicolas
Hi,

I am trying to figure out how to use user defined fonts with FOP. When compiling topic.fo to produce the pdf output, I get errors as the following:

Code: Select all

[fop] 600 WARN [ main ] org.apache.fop.fonts.FontInfo - Font 'TheSansOsF-Plain,normal,400' not found. Substituting with 'any,normal,400'.
This leads me to consider that fop cannot find my font.

According to what I read on fop website, I think I am supposed to use a config file to notify fop of where my fonts are. In the build file delivered with Oxygen, you call the fop lib as follows:

Code: Select all

<fop format="application/pdf" fofile="${inputFile}"
outfile="${outputFile}" messagelevel="info" force="true" userConfig="${dita.dir}/fop_relax_validation.xml" basedir="${outputDir}">
</fop>
Is it correct to say that fop_relax_validation.xml is the config file I am looking for?

I edited fop_relax_validation.xml as follows:

Code: Select all

<fop version="1.0">    
<!-- No strict FO validation for the Apache FOP-->
<strict-validation>false</strict-validation>
<fonts>
<directory>C:\Windows\Fonts</directory>
<auto-detect/>
</fonts>
</fop>
Unfortunately, that does not make any difference. Would you have any idea where I went wrong? I believe the font names are correct (Antenna Renderer outputs the pdf with the correct fonts.)

Thanks.

Nicolas

Re: DITA Fo plugin: adding fonts

Posted: Wed Jan 14, 2009 10:42 am
by Radu
Hi Nicolas,

You found the right configuration file Apache FOP uses when you call a DITA OT PDF transformation on a DITA Map opened in the DITA Maps Manager view in Oxygen.

We have an article showing how to add an additional Font to Apache FOP here:
https://www.oxygenxml.com/doc/versions/ ... n-FOP.html

The difference is that you will not have to set that configuration file to Oxygen but instead the fop_relax_validation.xml one.

Regards,
Radu

Re: DITA Fo plugin: adding fonts

Posted: Mon Feb 02, 2009 11:34 pm
by mshellenberger
Radu,

I am having a similar problem with DITA transforms using new fonts. This is my fop_relax_validation.xml code:

Code: Select all

<fop version="1.0">    
<base>file:///c:/Windows/Fonts/</base>
<source-resolution>72</source-resolution>
<target-resolution>72</target-resolution>
<default-page-settings height="11in" width="8.26in"/>
<renderers>
<renderer mime="application/pdf">
<filterList>
<value>flate</value>
</filterList>
<fonts>
<font metrics-url="file:///c:/Windows/Fonts/Arial.xml" kerning="yes"
embed-url="file://c:/Windows/Fonts/Arial.ttf">
<font-triplet name="Arial" style="normal"
weight="normal"/>
</font>
<font metrics-url="file:///c:/Windows/Fonts/Arialbi.xml" kerning="yes"
embed-url="file://c:/Windows/Fonts/Arialbi.ttf">
<font-triplet name="Arial" style="normal"
weight="normal"/>
</font>
<font metrics-url="file:///c:/Windows/Fonts/Arialbd.xml" kerning="yes"
embed-url="file://c:/Windows/Fonts/Arialbd.ttf">
<font-triplet name="Arial" style="normal"
weight="normal"/>
</font>
</fonts>
</renderer>
</renderers>
</fop>
I followed the directions at http://www.oxygenxml.com/doc/ug-oxygen/ ... uiltin-FOP. The ttfConvert.bat states that it completes successfully but then I cannot find the resulting XML files. Here is my ttfConvert.bat file:

Code: Select all

set LIB=lib
set CMD=java -cp "%LIB%\fop.jar;%LIB%\avalon-framework-4.2.0.jar
set CMD=%CMD%;%LIB%\xml-apis.jar;%LIB%\xercesImpl.jar;%LIB%\xalan.jar
set CMD=%CMD%;%LIB%\serializerOxygen.jar" org.apache.fop.fonts.apps.TTFReader
set FONT_DIR=C:\Windows\Fonts
%CMD% %FONT_DIR%\arial.ttf Arial.xml
%CMD% %FONT_DIR%\arialbi.ttf Arialbi.xml
%CMD% %FONT_DIR%\arialbd.ttf Arialbd.xml
I changed the FO Processor configuration file to point to the fop_relax_validation.xml file. I called the font within a block using @font-family="Arial". And I still get the warning "org.apache.fop.fonts.FontInfo - Font 'Arial,normal,400' not found. Substituting with 'any,normal,400'."

Also, I am using Vista with Office 2007, if that matters.

Any suggestions on where I am screwing this up?

Thanks.

Re: DITA Fo plugin: adding fonts

Posted: Tue Feb 03, 2009 3:02 pm
by Radu
Hi,

Can you be more specific about what you are trying to accomplish?

If you are opening a FO file in Oxygen and then apply to it the FO to PDF transformation then you should do exactly what is specified in the PDF article and you should not be interested in directly editing the fop_relax_validation.xm configuration file.

If you are running a DITA Open Toolkit ANT PDF transformation against a DITA Map opened in the Oxygen DITA Maps Manager then Apache FOP will look only in the OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT/fop_relax_validation.xm file and will not look at the configuration file you have set up in the Oxygen preferences.

Regards,
Radu

Re: DITA Fo plugin: adding fonts

Posted: Tue Feb 03, 2009 5:36 pm
by mshellenberger
Radu wrote:Hi,

Can you be more specific about what you are trying to accomplish?

If you are running a DITA Open Toolkit ANT PDF transformation against a DITA Map opened in the Oxygen DITA Maps Manager then Apache FOP will look only in the OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT/fop_relax_validation.xm file and will not look at the configuration file you have set up in the Oxygen preferences.

Regards,
Radu
The DITA Open toolkit transformation is what I am doing. And the fop_relax_validation.xml file I referenced previously is exactly where you describe it. I used the instructions for the "AddFontToFOP.pdf" because that is all that is available. Are the code files I posted previously incorrect?

All I want to do is add Arial fonts to the DITA Open ToolKit transformation in order to embed them in the resulting PDF. Please tell me how to accomplish that. I've spent too many hours on this already.

Thanks.

Re: DITA Fo plugin: adding fonts

Posted: Tue Feb 03, 2009 6:44 pm
by Radu
Hi,

First of all, after you run the arialConvert.bat file as specified in the PDF, the font configuration XML should appear in the same folder as the arialConvert.bat script (which should be the Oxygen installation directory).

If you are running Vista, it may be possible that there is no write access in the Oxygen installation directory and that is why the XML does not appear.
If this is the case, you should try to install Oxygen again in a folder which does have write restrictions and execute the script from there.

Then, considering that Arial.xml is located in the Oxygen installation directory, the fop_relax_validation.xml file should look like:

Code: Select all


<fop version="1.0">
<strict-validation>false</strict-validation>
<!-- No strict FO validation for the Apache FOP-->
<base>file:/c:/path/to/oxygen/installation/</base>
<source-resolution>72</source-resolution>
<target-resolution>72</target-resolution>
<default-page-settings height="11in" width="8.26in"/>
<renderers>
<renderer mime="application/pdf">
<filterList>
<value>flate</value>
</filterList>
<fonts>
<font metrics-url=Arial.xml" kerning="yes"
embed-url="file:/c:/Windows/Fonts/Arial.ttf">
<font-triplet name="Arial" style="normal" weight="normal"/>
</font>
</fonts>
</renderer>
</renderers>
</fop>
If you are running a "PDF DITA OT" transformation you should configure the transformation scenarion and set the args.fo.userconfig parameter to the path of fop_relax_validation.xml and the transformation should succeed using the new mapped font.

Otherwise, if you are running a PDF2 IDIOM FO Plugin transformation
the fop_relax_validation.xml file will be used by default by Apache FOP. In this case though you will probably have to edit the OXYGEN_INSTALL_DIR/frameworks/dita/DITA-OT/demo/fo/cfg/fo/font-mappings.xml and configure the mapping for your font.


Regards,
Radu

Re: DITA Fo plugin: adding fonts

Posted: Tue Feb 03, 2009 7:21 pm
by mshellenberger
Radu wrote:Hi,

If you are running Vista, it may be possible that there is no write access in the Oxygen installation directory and that is why the XML does not appear.
If this is the case, you should try to install Oxygen again in a folder which does have write restrictions and execute the script from there.

Regards,
Radu
That fixed it. Thank you for laying it out so clearly. This is both the first time I've used oXygen for DITA conversions and the first time I've had a problem with Vista's UAC. I had to reinstall oXygen outside the 'Program Files' directory.

I really appreciate how helpful and responsive oXygen support is. I don't have to dig all over the internet. I can come here and get the answer within a day.

Thanks,
Mark