<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <title>Reading custom Font *.ttf from Java class</title>
  <link rel="self" href="https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=118041668" />
  <subtitle>Reading custom Font *.ttf from Java class</subtitle>
  <id>https://liferay.dev/c/message_boards/find_thread?p_l_id=119785294&amp;threadId=118041668</id>
  <updated>2026-04-06T14:50:33Z</updated>
  <dc:date>2026-04-06T14:50:33Z</dc:date>
  <entry>
    <title>RE: Reading custom Font *.ttf from Java class</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118050001" />
    <author>
      <name>Kevin Neibarger</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118050001</id>
    <updated>2019-12-11T14:16:30Z</updated>
    <published>2019-12-11T14:16:30Z</published>
    <summary type="html">I figured out that I needed to move the custom fonts to the jar I was importing into my portlet and make it available to my jar executable. I am using the jar library to build my form so I don&amp;#39;t need dependencies in my portlet with the exception of said jar.</summary>
    <dc:creator>Kevin Neibarger</dc:creator>
    <dc:date>2019-12-11T14:16:30Z</dc:date>
  </entry>
  <entry>
    <title>RE: Reading custom Font *.ttf from Java class</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118046149" />
    <author>
      <name>Olaf Kock</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118046149</id>
    <updated>2019-12-11T08:57:35Z</updated>
    <published>2019-12-11T08:57:35Z</published>
    <summary type="html">&lt;div class="quote-title"&gt;Kevin Neibarger:&lt;/div&gt;&lt;blockquote&gt;&lt;br /&gt; -- Does File: /compass-dashboard-roster-portlet/fonts/arial.ttf Exist? false-- &lt;br /&gt;&lt;/blockquote&gt;It depends a bit on which version you&amp;#39;re on, however, you can&amp;#39;t rely on anything deployed with your web application to ever be addressable as File on disk: It might be packaged in a zip, jar or war, just in memory. Thus you&amp;#39;ll always need to find out how to open a stream and read the data from it.&lt;br /&gt;Even if you would find it on disk in your current case, you can&amp;#39;t rely on it in the future. And if you&amp;#39;d ignore this, your way to construct the filename is most likely wrong: If you read the message carefully: Does your filesystem have a top level directory /compass-dashboard-roster-portlet? I&amp;#39;m guessing it doesn&amp;#39;t.</summary>
    <dc:creator>Olaf Kock</dc:creator>
    <dc:date>2019-12-11T08:57:35Z</dc:date>
  </entry>
  <entry>
    <title>Reading custom Font *.ttf from Java class</title>
    <link rel="alternate" href="https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118041667" />
    <author>
      <name>Kevin Neibarger</name>
    </author>
    <id>https://liferay.dev/c/message_boards/find_message?p_l_id=119785294&amp;messageId=118041667</id>
    <updated>2019-12-10T13:35:48Z</updated>
    <published>2019-12-10T13:35:48Z</published>
    <summary type="html">So, I&amp;#39;m trying to load a custom *.ttf from my Java class within a Liferay MVC portlet. My file is located in /docroot/fonts/arial.ttf and I&amp;#39;m trying to load it with the following code&lt;br /&gt;&lt;br /&gt;String path = httpRequest.getContextPath() + &amp;#34;/fonts/arial.ttf&amp;#34;; &lt;br /&gt;String filePath = FileUtil.getAbsolutePath(new File(path));&lt;br /&gt;System.out.println(&amp;#34;\n -- Does File: &amp;#34; + filePath + &amp;#34; Exist? &amp;#34; + FileUtil.exists(filePath) + &amp;#34;-- \n&amp;#34;);&lt;br /&gt;&lt;br /&gt;My output from the System.out.println with the &amp;#34;exists&amp;#34; method is false&lt;br /&gt;&lt;br /&gt; -- Does File: /compass-dashboard-roster-portlet/fonts/arial.ttf Exist? false-- &lt;br /&gt;&lt;br /&gt;I&amp;#39;m trying to use the custom font *.ttf in a jar that builds a PDF using iText 7. How do I load this file from the portlet? See attached for directory structure</summary>
    <dc:creator>Kevin Neibarger</dc:creator>
    <dc:date>2019-12-10T13:35:48Z</dc:date>
  </entry>
</feed>
