title: Creating fonts from *.ttf files using iText
body: <p>This is a method inside my Resources.class:</p>
  
  <pre><code>public static Font loadFont(String fontFileName)
      {
          BaseFont base = null;
  
          try
          {
              base = BaseFont.createFont(Resource.class.getResource(fontFileName + "_font.ttf").toString(), BaseFont.WINANSI, true);
          }
          catch (DocumentException | IOException e)
          {
              e.printStackTrace();
          }
  
          Font font = new Font(base, Font.BOLD, 15);
          return font;
      }
  </code></pre>
  
  <p>Structure of my program is:</p>
  
  <pre><code>src (folder)
      core (package)
          //all (but one) classes used for program
      resources (package)
          class Resources (used to load resources into the "core" classes)
          wingding_font.ttf
  </code></pre>
  
  <p>This is the snippet of the code which isn't working:</p>
  
  <pre><code>p = new Phrase("some random text");
  p.setFont(Resource.loadFont("wingding"));
  pa = new Paragraph(p);
  pa.setFont(Resource.loadFont("wingding"));
  document.add(pa);
  </code></pre>
  
  <p>When I open the PDF, text is there, but some font, which I guess is the default font, is used.</p>
  
  <p>Note1: I tried to setting font to only Phrase(p), and to only Paragraph(pa), but that didn't change output in any way.</p>
  
  <p>Note2: The Resource.loadFont("wingding"); methods try/catch didn't "catch" any errors.</p>