Incorporando fonte ao FOP do Apache

Estou tentando fazer com que o Apache FOP use o Arial como fonte. Até agora sem sorte.

No meu config.xml, diz:

<fonts>                           
 <font kerning="yes"  embed-url="file:///C:/Windows/Fonts/Arial.ttf" encoding-mode="auto">>
<font-triplet name="Arial" style="normal" weight="normal"/>
 </font>                     
</fonts>

Mas isso não parece funcionar. Quando eu começo o FOP na linha de comando, ele diz que a fonte Arial normal não foi encontrada.

Eu tentei gerar o arquivo Arial.xml do ttf com o TTFReader no FOP, mas isso também não funcionou (mesmo seguindo as instruções na página da Web do fop). Eu recebi a seguinte mensagem de erro:

C:\Users\xy\Desktop\FOP2>java -cp build\fop.jar;lib\avalon-framework-4.2.0.jar;lib\commons-logging-1.0.4.jar;lib\commons-io-1.3.1.jar org.apache.fop.TTFReader C:\Windows\Fonts\arial.ttf Arial.xml
TTF Reader for Apache FOP 1.1

Parsing font...
Reading C:\Windows\Fonts\arial.ttf...
Exception in thread "main" java.lang.NoClassDefFoundError: org/apache/xmlgraphics/fonts/Glyphs
        at org.apache.fop.fonts.truetype.TTFFile.initAnsiWidths(TTFFile.java:662)
        at org.apache.fop.fonts.truetype.TTFFile.readFont(TTFFile.java:711)
        at org.apache.fop.fonts.apps.TTFReader.loadTTF(TTFReader.java:224)
        at org.apache.fop.fonts.apps.TTFReader.main(TTFReader.java:177)
Caused by: java.lang.ClassNotFoundException: org.apache.xmlgraphics.fonts.Glyphs
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at sun.misc.Launcher$AppClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)

Talvez eu não esteja vendo o forrest para as árvores, mas eu estou em uma perda quanto ao que fazer.

Alguma sugestão?

UDPDATE:

Eu baixei um monte de arquivos xml deste site:http://www.java2s.com/Code/Jar/f/Downloadfopfontmetricsjar.htm (que para mim se parece muito com os arquivos xml que já estavam no fop. então eu suponho que eles estão no formato correto)

Eu coloquei eles na pasta fop / src / codegen

Eu também coloquei o arial.tff lá

no arquivo fop / conf / xconf diz

<fonts>

      <directory>C:\Windows\Fonts</directory>
        <!-- embedded fonts -->
        <!--
        This information must exactly match the font specified
        in the fo file. Otherwise it will use a default font.

        For example,
        <fo:inline font-family="Arial" font-weight="bold" font-style="normal">
            Arial-normal-normal font
        </fo:inline>
        for the font triplet specified by:
        <font-triplet name="Arial" style="normal" weight="bold"/>

        If you do not want to embed the font in the pdf document
        then do not include the "embed-url" attribute.
        The font will be needed where the document is viewed
        for it to be displayed properly.

        possible styles: normal | italic | oblique | backslant
        possible weights: normal | bold | 100 | 200 | 300 | 400
                          | 500 | 600 | 700 | 800 | 900
        (normal = 400, bold = 700)
        -->

        <font metrics-url="C:\Users\z003a5bp\Desktop\FOP2\src\codegen\fonts\arial.xml" kerning="yes" embed-url="C:\Users\z003a5bp\Desktop\FOP2\src\codegen\fonts\arial.ttf">
          <font-triplet name="Arial" style="normal" weight="normal"/>
          <!-- <font-triplet name="ArialMT" style="normal" weight="normal"/> -->
        </font>
       <!-- <font metrics-url="arialb.xml" kerning="yes" embed-url="arialb.ttf">
          <font-triplet name="Arial" style="normal" weight="bold"/>
          <font-triplet name="ArialMT" style="normal" weight="bold"/> -->

          <auto-detect/>
      </fonts>

Então eu tenho auto-detec e especificou um diretório para as fontes e embutido arial-stil eu recebo mensagens de erro como "glyph xyz não está incluído na Helvetica", embora em nenhum lugar na minha stylesheets ele diz font-family Helvetica. Os pdfs são exibidos em Times New Roman ...

++ ATUALIZAÇÃO ++

OK...

meu arquivo fop.xconf diz isso agora:

<fop version="1.0">

  <base>.</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:/Users/z003a5bp/Desktop/FOP2/src/codegen/fonts/arial.xml"
            kerning="yes"
            embed-url="file:///C:/Users/z003a5bp/Desktop/FOP2/arial.ttf">
        <font-triplet name="Arial" style="normal" weight="normal"/>
            </font> 

          <auto-detect/>
      </fonts>

    </renderer>

Eu adicionei font-family = "Arial" para praticamente todos os elementos agora: D

Eu vou para o meu diretório fop na linha de comando e digite

fop -xml blabla\file.xml -xsl blabla\stylesheet.xsl -pdf output.pdf

E eu recebo o seguinte:

Nov 07, 2013 1:34:29 PM org.apache.fop.events.LoggingEventListener processEvent
Schwerwiegend: Image not found. URI: 15300145419.PNG. (See position 44:-1)
Nov 07, 2013 1:34:29 PM org.apache.fop.events.LoggingEventListener processEvent
Warnung: The following feature isn't implemented by Apache FOP, yet: table-layout="auto" (on fo:table) (Siehe Position 29:-1)
Nov 07, 2013 1:34:29 PM org.apache.fop.events.LoggingEventListener processEvent
Schwerwiegend: Image not found. URI: 15627351051.PNG. (See position 44:-1)
Nov 07, 2013 1:34:29 PM org.apache.fop.events.LoggingEventListener processEvent
Schwerwiegend: Image not found. URI: 15629782795.PNG. (See position 44:-1)
Nov 07, 2013 1:34:29 PM org.apache.fop.events.LoggingEventListener processEvent
Warnung: Font "Arial,normal,400" not found. Substituting with "any,normal,400".
Nov 07, 2013 1:34:29 PM org.apache.fop.events.LoggingEventListener processEvent
Warnung: Glyph "?" (0x95) not available in font "Times-Roman".
Nov 07, 2013 1:34:29 PM org.apache.fop.events.LoggingEventListener processEvent
Warnung: Font "Arial,italic,400" not found. Substituting with "any,italic,400".
Nov 07, 2013 1:34:29 PM org.apache.fop.events.LoggingEventListener processEvent
Warnung: Content overflows the viewport of the fo:region-before on page 1 in block-progression direction by 2989 millipoints. (See position 50:-1)
Nov 07, 2013 1:34:29 PM org.apache.fop.events.LoggingEventListener processEvent
Information: Rendered page #1.
Nov 07, 2013 1:34:29 PM org.apache.fop.events.LoggingEventListener processEvent
Warnung: Content overflows the viewport of the fo:region-before on page 2 in block-progression direction by 2989 millipoints. (See position 59:-1)
Nov 07, 2013 1:34:29 PM org.apache.fop.events.LoggingEventListener processEvent
Information: Rendered page #2.

Não se importe com os URLs.

questionAnswers(5)

yourAnswerToTheQuestion