How can i dynamically load fonts at runtime?
Davanum Srinivas Yes, This is possible in JDK1.3. The new method Font.createFont(int, InputStream) provides the ability to add fonts to the JVM at runtime. This font is not persistent upon termination of the JVM and is only available to the creator of the Font. At this time, only TrueTypeTM fonts can be created at runtime. The following code sample illustrates how to dynamically load the TrueType font Arial from a file:
File file = new File("Arial.ttf"); FileInputStream fis = new FileInputStream(file); Font font = Font.createFont(Font.TRUETYPE_FONT, fis);Similarly, to load the font from a URL:
URL url = new URL("Arial.ttf"); InputStream is = url.openStream(); Font font = Font.createFont(Font.TRUETYPE_FONT, is);