Reading custom Font *.ttf from Java classReading custom Font *.ttf from Java classhttps://liferay.dev/en/c/message_boards/find_thread?p_l_id=119785333&threadId=1180416682024-03-29T06:41:04Z2024-03-29T06:41:04ZRE: Reading custom Font *.ttf from Java classKevin Neibargerhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1180500012019-12-11T14:16:30Z2019-12-11T14:16:30ZI 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't need dependencies in my portlet with the exception of said jar.Kevin Neibarger2019-12-11T14:16:30ZRE: Reading custom Font *.ttf from Java classOlaf Kockhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1180461492019-12-11T08:57:35Z2019-12-11T08:57:35Z<div class="quote-title">Kevin Neibarger:</div><blockquote><br /> -- Does File: /compass-dashboard-roster-portlet/fonts/arial.ttf Exist? false-- <br /></blockquote>It depends a bit on which version you're on, however, you can'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'll always need to find out how to open a stream and read the data from it.<br />Even if you would find it on disk in your current case, you can't rely on it in the future. And if you'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'm guessing it doesn't.Olaf Kock2019-12-11T08:57:35ZReading custom Font *.ttf from Java classKevin Neibargerhttps://liferay.dev/en/c/message_boards/find_message?p_l_id=119785333&messageId=1180416672019-12-10T13:35:48Z2019-12-10T13:35:48ZSo, I'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'm trying to load it with the following code<br /><br />String path = httpRequest.getContextPath() + "/fonts/arial.ttf"; <br />String filePath = FileUtil.getAbsolutePath(new File(path));<br />System.out.println("\n -- Does File: " + filePath + " Exist? " + FileUtil.exists(filePath) + "-- \n");<br /><br />My output from the System.out.println with the "exists" method is false<br /><br /> -- Does File: /compass-dashboard-roster-portlet/fonts/arial.ttf Exist? false-- <br /><br />I'm trying to use th