/** * Create a bitmap font on the fly from either a font name that's * installed on the system, or from a .ttf or .otf that's inside * the data folder of this sketch. * <p/> * Use 'null' for the charset if you want to dynamically create * character bitmaps only as they're needed. */ public PFont createFont(String name, float size, boolean smooth, char[] charset) { String lowerName = name.toLowerCase(); Typeface baseFont = null; if (lowerName.endsWith(".otf") || lowerName.endsWith(".ttf")) { AssetManager assets = activity.getAssets(); baseFont = Typeface.createFromAsset(assets, name); } else { baseFont = (Typeface) PFont.findNative(name); } return new PFont(baseFont, round(size), smooth, charset); }