title: Apache FOP - Not Accepting Custom Font
body: <p>While trying to use <code>Apache FOP</code> to use custom fonts (Google Lato Font), I am getting below error. I have converted <code>ttf font</code> to <code>xml</code> as per documentation &amp; kept both ttf &amp; xml files in same directory <code>resource</code></p>
  
  <blockquote>
    <p>WARNING: <code>Font "Lato,normal,700" not found</code>. Substituting with "any,normal,700"<br/>
    WARNING: <code>Font "Lato,normal,400" not found</code>. Substituting with "any,normal,400".</p>
  </blockquote>
  
  <p>Configuration file:</p>
  
  <pre><code>&lt;?xml version="1.0"?&gt;
  &lt;fop version="1.0"&gt;
      &lt;base&gt;.&lt;/base&gt;
      &lt;source-resolution&gt;72&lt;/source-resolution&gt;
      &lt;target-resolution&gt;72&lt;/target-resolution&gt;
      &lt;default-page-settings height="11.00in" width="8.50in"/&gt;
      &lt;renderers&gt;
          &lt;renderer mime="application/pdf"&gt;
              &lt;filterList&gt;
                  &lt;!-- provides compression using zlib flate (default is on) --&gt;
                  &lt;value&gt;flate&lt;/value&gt;
              &lt;/filterList&gt;
              &lt;fonts&gt;
                  &lt;font metrics-url="Lato-Regular.xml" kerning="yes" embed-url="Lato-Regular.ttf"&gt;
                      &lt;font-triplet name="Lato" style="normal" weight="400"/&gt;
                  &lt;/font&gt;
                  &lt;font metrics-url="Lato-Bold.xml" kerning="yes" embed-url="Lato-Bold.ttf"&gt;
                      &lt;font-triplet name="Lato" style="normal" weight="700"/&gt;
                  &lt;/font&gt;
              &lt;/fonts&gt;
          &lt;/renderer&gt;
      &lt;/renderers&gt;
  &lt;/fop&gt;
  </code></pre>
  
  <p>Execution code:</p>
  
  <pre><code>public static void main(String[] args) throws SAXException, IOException, TransformerException, URISyntaxException {
          File fopConf = new File("\\fop.xconf");
          FopFactory fopFactory = FopFactory.newInstance(fopConf);
  
          OutputStream out = new BufferedOutputStream(new FileOutputStream(new File("D:/Hello.pdf")));
  
          try {
              // Step 3: Construct fop with desired output format
              Fop fop = fopFactory.newFop(MimeConstants.MIME_PDF, out);
  
              TransformerFactory factory = TransformerFactory.newInstance();
              Source xslt = new StreamSource(new File(ClassLoader.getSystemResource("resources/foo.xsl").toURI()));
              Transformer transformer = factory.newTransformer(xslt);
  
              // Resulting SAX events (the generated FO) must be piped through to FOP
              Result res = new SAXResult(fop.getDefaultHandler());
  
              Source src = new StreamSource(new File(ClassLoader.getSystemResource("resources/name.xml").toURI()));
              // Step 6: Start XSLT transformation and FOP processing
  
              transformer.transform(src, res);
  
          } finally {
              //Clean-up
              out.close();
          }
      }
  </code></pre>
  
  <p><em>Any suggestions? I have wasted entire day looking on Google, but unable to find a relevant solution. I have seen stackoverflow posts mentioning about using realtive/absolute path, sub-fonts, etc. but none of them seems to work</em></p>
  
  <ul>
  <li><code>FOP 2.2</code></li>
  <li><code>Would use this code on web for dynamic pdf generation</code></li>
  <li><code>JDK 1.8</code></li>
  </ul>