font problem, possibly related to spaces in font name

Here should go questions about transforming XML with XSLT and FOP.
rpraleigh
Posts: 6

font problem, possibly related to spaces in font name

Wed Aug 10, 2016 1:16 am

I'm working on an XSLt transformation from DITA using the FOP processor. I'm using the default DITA-OT 2.3 that comes with Oxygen, and the PDF2 plugin. Per instructions I read in a number of places, I created a customization directory and created pointers in catalog.xml to customization files for XSL processing, XSL attributes, and font mapping. I know I set this part up correctly, because most of my changes work fine.

The problem arises with the use of fonts. I want to use a particular font, called "Swis721 Lt BT", in my document. I checked to make sure that the FOP configuration file was set up to automatically process system fonts, so I then changed the physical font that is mapped to the "sans-serif" alias. At first I tried using the font I wanted, using the name that appeared as the font name under Windows (Swis721 Lt Bt). The parts of the document that are mapped as using "sans-serif" would appear in Helvetica (which was listed as one of the fallback fonts; if I remove the fallback fonts from the list, those portions of the document appear in Times). To make sure that the processor was able to get system fonts, I switched the alias "sans-serif" to use the font "Calibri." This time the document (or the portions specified as "sans-serif") appeared in Calibri. Just for fun, I also tried Algerian, and that worked. Swis721 Lt Bt won't work, however. I also tried a different font name that had a couple of spaces in the name, and it failed as well.

Suggestions as to how to fix this? Our company style guide calls for using the Swiss Light font.

Here is the relevant portion of the customized font-mappings.xml file:

Code: Select all

<aliases>
      <alias name="serif">Serif</alias>
    </aliases>
    <aliases>
      <alias name="sans-serif">Sans</alias>
    </aliases>
    <aliases>
      <alias name="monospace">Monospaced</alias>
    </aliases>
    <aliases>
      <alias name="Helvetica">Normal</alias>
    </aliases>
    <aliases>
      <alias name="Courier">Monospaced</alias>
    </aliases>
   
    <!-- OXYGEN PATCH START  Set fallback fonts for Asian and RTL languages. -->
    <logical-font name="Sans">
      <physical-font char-set="default">
        <font-face>Swis721 Lt BT, Helvetica, Arial</font-face>
      </physical-font>
      <physical-font char-set="Simplified Chinese">
        <font-face>AdobeSongStd-Light, Arial Unicode MS, Batang, SimSun</font-face>
      </physical-font>
      <physical-font char-set="Japanese">
        <font-face>KozMinProVI-Regular, Arial Unicode MS, Batang</font-face>
      </physical-font>
      <physical-font char-set="Korean">
        <font-face>AdobeMyungjoStd-Medium, Arial Unicode MS, Batang</font-face>
      </physical-font>     
      <physical-font char-set="Symbols">
        <font-face>ZapfDingbats</font-face>
      </physical-font>
      <physical-font char-set="SubmenuSymbol">
        <font-face>ZapfDingbats</font-face>
      </physical-font>
      <physical-font char-set="SymbolsSuperscript">
        <font-face>Helvetica, Arial Unicode MS</font-face>
        <baseline-shift>20%</baseline-shift>
        <override-size>smaller</override-size>
      </physical-font>
    </logical-font>
radu_pisoi
Posts: 310
Location: Craiova

Re: font problem, possibly related to spaces in font name

Wed Aug 10, 2016 12:22 pm

Hi,

It seems that the font is not visible or compatible with the Apache FOP processor. I think you have two options to debug this situation.

First, you can use the 'org.apache.fop.tools.fontlist.FontListMain' utility class that comes together with Apache FOP to list all the configured fonts, see https://xmlgraphics.apache.org/fop/trunk/fonts.html,

A sample script that runs this utility class is listed below, runFop.bat:

Code: Select all

@echo off

SET CP=lib\fop.jar;
SET CP=%CP%;lib\commons-io-1.3.1.jar;
SET CP=%CP%;lib\xmlgraphics-commons-2.1.jar
SET CP=%CP%;lib\commons-logging-1.2.jar;
SET CP=%CP%;lib\avalon-framework-api-4.3.1.jar;
SET CP=%CP%;lib\avalon-framework-impl-4.3.1.jar
SET CP=%CP%;lib\batik-all-1.8.jar;

java -Xmx1060m -cp %CP% org.apache.fop.tools.fontlist.FontListMain %*


You can put this script in the oXygen installation folder and then run from console:

Code: Select all

runfop -c lib/fop.xconf fonts.xml


All the available fonts will be listed in fonts.xml. You can open this file and check if your custom font is available.

Another option to debug this situation is to enable the output of the Apache FOP processor from the 'FO Processor' preferences page, see
https://www.oxygenxml.com/doc/versions/ ... ssors.html

Normally, the Apache FOP processor will display error messages if the font is not supported.
Radu Pisoi
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
rpraleigh
Posts: 6

Re: font problem, possibly related to spaces in font name

Wed Aug 10, 2016 9:09 pm

That doesn't seem to help me. I created that batch file and ran it, and here is the output:

Code: Select all

C:\Program Files\Oxygen XML Editor 18>runfop
use --help or -? for usage information.
Courier:
  F9 [Courier]
    Computer-Modern-Typewriter,normal,400
    Courier,normal,400
    Monospaced,normal,400
    monospace,normal,400
  F11 [Courier]
    Courier,normal,700
    Monospaced,normal,700
    monospace,normal,700
  F12 [Courier]
    Courier,italic,700
    Courier,oblique,700
    Monospaced,italic,700
    Monospaced,oblique,700
    monospace,italic,700
    monospace,oblique,700
  F10 [Courier]
    Courier,italic,400
    Courier,oblique,400
    Monospaced,italic,400
    Monospaced,oblique,400
    monospace,italic,400
    monospace,oblique,400
Helvetica:
  F1 [Helvetica]
    Helvetica,normal,400
    SansSerif,normal,400
    sans-serif,normal,400
  F3 [Helvetica]
    Helvetica,normal,700
    SansSerif,normal,700
    sans-serif,normal,700
  F4 [Helvetica]
    Helvetica,italic,700
    Helvetica,oblique,700
    SansSerif,italic,700
    SansSerif,oblique,700
    sans-serif,italic,700
    sans-serif,oblique,700
  F2 [Helvetica]
    Helvetica,italic,400
    Helvetica,oblique,400
    SansSerif,italic,400
    SansSerif,oblique,400
    sans-serif,italic,400
    sans-serif,oblique,400
Symbol:
  F13 [Symbol]
    Symbol,normal,400
Times:
  F7 [Times]
    Times Roman,normal,700
    Times,normal,700
    Times-Roman,normal,700
    any,normal,700
    serif,normal,700
  F8 [Times]
    Times Roman,italic,700
    Times Roman,oblique,700
    Times,italic,700
    Times,oblique,700
    Times-Roman,italic,700
    Times-Roman,oblique,700
    any,italic,700
    any,oblique,700
    serif,italic,700
    serif,oblique,700
  F6 [Times]
    Times Roman,italic,400
    Times Roman,oblique,400
    Times,italic,400
    Times,oblique,400
    Times-Roman,italic,400
    Times-Roman,oblique,400
    any,italic,400
    any,oblique,400
    serif,italic,400
    serif,oblique,400
  F5 [Times]
    Times Roman,normal,400
    Times,normal,400
    Times-Roman,normal,400
    any,normal,400
    serif,normal,400
ZapfDingbats:
  F14 [ZapfDingbats]
    ZapfDingbats,normal,400


Notice that some fonts that I know work, such as Calibri and Algerian, do not appear in that list. So apparently that list, while it shows something, doesn't show all the fonts that the FOP processor is capable of using to produce output.
rpraleigh
Posts: 6

Re: font problem, possibly related to spaces in font name

Wed Aug 10, 2016 9:25 pm

Please disregard my earlier post. I was running the script without the additional parameters. Once I ran it correctly, I discovered the problem:

Even though Windows shows the name of the font to be "Swis721 Lt BT" when I open the font using the Windows font viewer, when I look at the list of fonts as processed by FOP, the name of that particular font gets processed as "Swis721 Light BT". Once I knew the name that FOP expects to see, and put it into the font-mappings.xml file, then the font was used correctly. Not sure of the reason for the discrepancy, but that resolved my problem.

Thanks!

Return to “XSLT and FOP”

Who is online

Users browsing this forum: No registered users and 2 guests