javafontstype-conversion

SFNTLY: How to convert any font that gets uploaded to "WOFF" format?


I can not find any documenration on this library (https://code.google.com/p/sfntly/). I've been taking stabs at it for 2 days now. I'm trying to convert any font that gets uploaded to "WOFF" format.

Could someone shed some light?


Solution

  • After reading the source code of SFNTLY I am no expert in sfntly, so use my answer at your risk :).

    I would convert the font with WoffWriter#convert() to writeable font data, then copy the wfd to outputstream.

        WoffWriter ww = new WoffWriter();
        WriteableFontData wfd = ww.convert(yourFont);
        try {
            FileOutPutStream fs = new FileOutputStream("out.fnt");
            wfd.copyTo(fs, wfd);
            fs.close();
        } catch (IOException e) {
        }