Simplify font situation to make it possible to use vanilla JRE trees by gohai · Pull Request #4639 · processing/processing
// Can't use Base.getJavaHome(), because if we're not using our local JRE, // we likely have bigger problems with how things are running. File fontFile = new File(System.getProperty("java.home"), "lib/fonts/" + filename); if (!fontFile.exists()) { // any of the fallbacks below is a custom location, so try to register the font as well registerFont = true; // if we're debugging from Eclipse, grab it from the work folder (user.dir is /app) fontFile = new File(System.getProperty("user.dir"), "../build/shared/lib/fonts/" + filename); } if (!fontFile.exists()) { // if we're debugging the new Java Mode from Eclipse, paths are different fontFile = new File(System.getProperty("user.dir"), "../../shared/lib/fonts/" + filename); } if (!fontFile.exists()) { // this if for Linux, where we're shipping a second copy of the fonts outside of java fontFile = Platform.getContentFile("lib/fonts/" + filename); } if (!fontFile.exists()) { String msg = "Could not find required fonts. "; // This gets the JAVA_HOME for the *local* copy of the JRE installed with
// this makes Font() work for font files in custom locations if (registerFont) { GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment(); ge.registerFont(font); }
return font.deriveFont((float) size); }