Apart from the standard JavaFonts, How can I use and process system fonts ( .ttf) and make changes in the font.properties file for implementation?

Curtis Hatter

If you are using JDK1.3, they have added Dynamic Font Loading abilities. Currently it only supports TrueType fonts are supported. They can be loaded from a disk, or from a url. Also they have some restrictions. They are only available to the creator of the font, and they are not persistent (i.e., they are lost when the JVM terminates). Here's the sample code on how to do it:

From a file (exception handling will be necessary...):


File file = new File("Marlett.ttf");
FileInputStream fis = new FileInputStream(file);
Font font = Font.createFont(Font.TRUETYPE_FONT, fis);

From a URL (again, needs exception handling...):


URL url = new URL("Marlett.ttf");
InputStream is = url.openStream();
Font font = Font.createFont(Font.TRUETYPE_FONT, is);
0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact