
Signature
free phpODP script: http://www.bie.no
> I'm currently loading TrueType fonts from the server and using them
> directly in my application with the Font.createFont(InputStream) method.
[quoted text clipped - 3 lines]
> libraries that support loading OpenType sfnt tables or OpenType fonts
> directly. Or if it is possible to do in Java.
OpenType is an extension of TrueType (with PostScript outlines). There
is a strange interface in the current J2SE:
java.awt.font.OpenType
Strange, because it is apparently not used anywhere in the API. Maybe
you are lucky, and createFont() can indeed deal with OpenType fonts,
while claiming to handle TrueType only. Or your OpenType fonts include
TrueType outlines, only? Did you try it? Did you check if the returned
Font implements java.awt.font.OpenType?
If all this doesn't work out, I think Apache FOP contains an OpenType
reader of some sort.
/Thomas
Bjørn Børresen - 22 Apr 2004 13:31 GMT
> Strange, because it is apparently not used anywhere in the API. Maybe you
> are lucky, and createFont() can indeed deal with OpenType fonts, while
> claiming to handle TrueType only. Or your OpenType fonts include TrueType
> outlines, only? Did you try it? Did you check if the returned Font
> implements java.awt.font.OpenType?
Font.createFont(int fontFormat, InputStream is) contains this code:
if ( fontFormat != Font.TRUETYPE_FONT ) {
throw new IllegalArgumentException ( "font format not recognized" );
}
Nonetheless I tried to just hand it an .otf file and specify that it was
truetype. I got this exception:
java.awt.FontFormatException: Unable to create font - bad font data
at java.awt.Font.createFont(Font.java:625)
at FontTest.getFont(FontTest.java:40)
at FontTest.<init>(FontTest.java:14)
at FontTest.main(FontTest.java:70)
Exception in thread "main" java.lang.NullPointerException
at FontTest.<init>(FontTest.java:18)
at FontTest.main(FontTest.java:70)
.. so no luck there :(
> If all this doesn't work out, I think Apache FOP contains an OpenType
> reader of some sort.
Hmm, I found a PFMReader and TTFReader there, but no OpenType reader ...
The closest thing I've found to what I need is
gnu.java.awt.Font.OpenTypeFactory; http://www.brawer.ch/software/fonts/
..but it didn't work on any of the fonts I've tested it on.
- Bjørn

Signature
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/