Java: Font doesn't load (from external file) -


in folder called data, have font file called font.ttf.

i want read in, that:

try {    font f = font.createfont(font.truetype_font,        new file("data/font.ttf")).derivefont(12.0); } catch (ioexception | fontformatexception e) {    system.err.println(e.tostring()); } 

that worked fine until point removed same font system (it's still in data folder!). now, it's showing generic , feel font.

is possible read in font file not in system fonts folder?

you don't seem doing font f once you've loaded in, might losing due block scoping.

font fallback = load system default; font myfont = null;  ...  try {   file ffile = new file("data/font.ttf");   myfont = font.createfont(font.truetype_font, ffile).derivefont(12); } catch (fontformatexception ffe) {   system.out.println("tried load bad font...");   ffe.printstacktrace(); } catch (ioexception ioe) {   system.out.println("i have no idea went wrong");   ioe.printstacktrace(); } {   loadmyapplication(myfont == null ? fallback : myfont); } 

or if absolutely need font correct ui building or content rendering, call loadmyapplication in try block, catches prevent application loading.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -