I was wondering if there is a way for extending Font class in a manner that I could return my own Font class by createFont and deriveFont methods. I mean something like this...
public class MyFont extends Font {
// Constructor
public MyFont (...) {
super(...);
}
// createFont method
public static MyFont createFont (...) {
// body
}
// deriveFont method
public static MyFont deriveFont (...) {
// body
}
}
I've tryied but I could not retrieve any font, and when doing it the font I got was the default one (I mean "Dialog").
The reason for doing is is to minimize the impact produced by an eventual change in later Java distributions of its VM.
This is the code summoned above:
MyFont onePoint=MyFont.createFont(MyFont.TRUETYPE_FONT,fontStream, size);
Then in MyFont, I coded:
public static MyFont createFont (int i, InputStream io, int size) throws FontFormatException, IOException {
Font font = Font.createFont(i, io);
MyFont kfont = new
MyFont(font.getName(),font.getStyle(),font.getSize());
return kfont;
}