title: How to add/embed custom font file to FontFactory.register in iText
body: <p>I need your assistant in adding a custom font to the Java Class for writing PDF. The selected font is arial.ttf and it is located in the below path:</p>
  <blockquote>
  <p>Web App -&gt; public html -&gt; resources -&gt; arial.ttf</p>
  </blockquote>
  <p>My previous code for testing was to read the font from the c: drive:</p>
  <pre><code>BaseFont bf = BaseFont.createFont(&quot;c://windows//fonts//arial.ttf&quot;, BaseFont.IDENTITY_H, BaseFont.EMBEDDED);
  </code></pre>
  <p>Now I want to make the Web app as WAR file and to deploy it and I need to change the path from the c: drive to the path:</p>
  <blockquote>
  <p>Web App -&gt; public html -&gt; resources -&gt; arial.ttf</p>
  </blockquote>
  <p>I tried also to embed the file from its location</p>
  <pre><code>FontFactory.register(&quot;/resources/fonts/arial.ttf&quot;);
  </code></pre>
  <p>However it always produces the below error:</p>
  <blockquote>
  <p>java.io.IOException: /resources/fonts/arial.ttf not found as file or
  resource.</p>
  </blockquote>
  <p>I tried different ways to refer to the file for example:</p>
  <blockquote>
  <p>/public_html/resources/fonts/arial.ttf</p>
  <p>../resources/fonts/arial.ttf</p>
  <p>/fonts/arial.ttf</p>
  <p>/arial.ttf</p>
  </blockquote>
  <p>But I wasn't successful</p>