title: Setting the font in XSL-FO with fop
body: <p>I have in the <code>.fonts/Dinarra/</code> folder the files <code>Dinarra LT Std-Roman.otf</code> and <code>Dinarra LT Std-Italic.otf</code>.</p>
  
  <p>The font configuration in <code>fop.xconf</code> is as follow:</p>
  
  <pre><code>&lt;renderer mime="application/pdf"&gt;
    ...
    &lt;fonts&gt;
      ...
      &lt;font kerning="yes" embed-url="'~/.fonts/Dinarra/DinarraLTStd-Roman.otf'" embedding-mode="subset"&gt;
        &lt;font-triplet name="'Dinarra LT Std'" style="normal" weight="normal"/&gt;
      &lt;/font&gt;
  
      &lt;font kerning="yes" embed-url="'~/.fonts/Dinarra/DinarraLTStd-Roman.otf'" embedding-mode="subset"&gt;
        &lt;font-triplet name="'Dinarra LT Std'" style="normal" weight="bold"/&gt;
      &lt;/font&gt;
  
      &lt;font kerning="yes" embed-url="'~/.fonts/Dinarra/DinarraLTStd-Italic.otf'" embedding-mode="subset"&gt;
        &lt;font-triplet name="'Dinarra LT Std'" style="italic" weight="normal"/&gt;
      &lt;/font&gt;
  
      &lt;font kerning="yes" embed-url="'~/.fonts/Dinarra/DinarraLTStd-Italic.otf'" embedding-mode="subset"&gt;
        &lt;font-triplet name="'Dinarra LT Std'" style="italic" weight="bold"/&gt;
      &lt;/font&gt;
  
      &lt;auto-detect/&gt;
    &lt;/fonts&gt;
  &lt;/renderer&gt;
  </code></pre>
  
  <p>I have registered the fonts in fop with <code>fop -c ~/.fop/fop.xconf</code>.</p>
  
  <p>Now I have the following XSL-FO code in the file <code>test.fob</code>:</p>
  
  <pre><code>&lt;fo:static-content flow-name="first-page-before"&gt;
    &lt;fo:block font-family="'Dinarra LT Std'" font-size="28pt"
        font-style="normal" font-variant="small-caps"&gt;
      &lt;fo:block&gt;S.E. Reverendo&lt;/fo:block&gt;
      &lt;fo:block&gt;Gabriele Asperso&lt;/fo:block&gt;
    &lt;/fo:block&gt;
  &lt;/fo:static-content&gt;
  </code></pre>
  
  <p>Compiled with <code>fop -c ~/.fop/fop.xconf -r test.fob test.pdf</code>, with the following output:</p>
  
  <pre><code>rev@asp-erso ~/repos/f5qg16 $ fop -c ~/.fop/fop.xconf -r test.fob test.pdf
  [warning] /usr/bin/fop: No java runtime was found
  [warning] /usr/bin/fop: No java runtime was found
  [warning] /usr/bin/fop: No JAVA_CMD set for run_java, falling back to JAVA_CMD = java
  [INFO] FopConfParser - Default page-height set to: 11.00in
  [INFO] FopConfParser - Default page-width set to: 8.50in
  [WARN] FOUserAgent - Border and padding for fo:region-before "first-page-before" should be '0' (See 6.4.14 in XSL 1.1); non-standard values are allowed if relaxed validation is enabled.  (See position 23:68)
  [WARN] FOUserAgent - Border and padding for fo:region-after "first-page-after" should be '0' (See 6.4.14 in XSL 1.1); non-standard values are allowed if relaxed validation is enabled.  (See position 25:62)
  [INFO] FOUserAgent - Rendered page #1.
  [INFO] FOUserAgent - Rendered page #2.
  </code></pre>
  
  <p>The problem is that the blocks are rendered with italic fonts, not normal, not small-caps.</p>
  
  <p>If I delete the file <code>Dinarra LT Std-Italic.otf</code> from the font folder then the blocks are rendered as expected (but not small-caps), but this way I can't have italic any more.</p>
  
  <p>My questions are:</p>
  
  <ol>
  <li><p>How can I set the fonts properly in the XSL-FO declaration, so that I can use normal style without deleting the italic file?</p></li>
  <li><p>How can I set the font so that I can obtain the small-caps variant?</p></li>
  </ol>
  
  <hr>
  
  <h2>Part 2: Some experiments</h2>
  
  <p>I have double checked that there is not the word "italic" anywhere in
  the test document before the declaration of the <code>static-content</code>;</p>
  
  <p>I have triple checked the exacteness of the font file paths in the
  file <code>~/.fop/fop.xconf</code>;</p>
  
  <p>I have deleted the file <code>~/.fop/fop-fonts.cache</code> and modified the file
  <code>~/.fop/fop.xconf</code> this way:</p>
  
  <pre><code>&lt;!-- ### deleted some 'font' element --&gt;
  &lt;font kerning="yes"
        embed-url="'~/.fonts/Dinarra/DinarraLTStd-Roman.otf'"
        embedding-mode="subset"&gt;
    &lt;font-triplet name="'Dinarra LT Std'"
                  style="normal"
                  weight="normal"/&gt;
  &lt;/font&gt;
  
  &lt;font kerning="yes"
        embed-url="'~/.fonts/Dinarra/DinarraLTStd-Italic.otf'"
        embedding-mode="subset"&gt;
    &lt;font-triplet name="'Dinarra LT Std'"
                  style="italic"
                  weight="normal"/&gt;
  &lt;/font&gt;
  
  &lt;!-- ### commented-out auto-detect--&gt;
  &lt;!-- &lt;auto-detect/&gt; --&gt;
  </code></pre>
  
  <p>I have compiled the test document re-registering the font with</p>
  
  <pre><code>fop -c ~/.fop/fop.xconf -r test.fob test.pdf
  </code></pre>
  
  <p>the output is:</p>
  
  <pre><code>[warning] /usr/bin/fop: No java runtime was found
  [warning] /usr/bin/fop: No java runtime was found
  [warning] /usr/bin/fop: No JAVA_CMD set for run_java, falling back to JAVA_CMD = java
  [INFO] FopConfParser - Default page-height set to: 11.00in
  [INFO] FopConfParser - Default page-width set to: 8.50in
  [WARN] FOUserAgent - Border and padding for fo:region-before "first-page-before" should be '0' (See 6.4.14 in XSL 1.1); non-standard values are allowed if relaxed validation is enabled.  (See position 23:68)
  [WARN] FOUserAgent - Border and padding for fo:region-after "first-page-after" should be '0' (See 6.4.14 in XSL 1.1); non-standard values are allowed if relaxed validation is enabled.  (See position 25:62)
  [WARN] FOUserAgent - Font "Dinarra LT Std,normal,400" not found. Substituting with "any,normal,400".
  [INFO] FOUserAgent - Rendered page #1.
  [INFO] FOUserAgent - Rendered page #2.
  </code></pre>
  
  <p>So (line 8) fop doesn't fint the font (!).</p>
  
  <p>Then I have newly deleted the file <code>~/.fop/fop-fonts.cache</code> and
  re-enabled the <code>auto-detect</code> directive, and finally re-compiled the
  test file. The output is 23,175 lines long, none of which contains the
  word 'Dinarra', nor the word 'otf'.</p>
  
  <p>But the content of the <code>fo:static-content</code> element is still composed
  with italic.</p>
  
  <hr>
  
  <p>I don't know what to think more.</p>