Font Creator for jMP

May be, a simple checker could be implemented: if a required glyph has no dots, after the end user selects a font, it will pop a message showing what is missing, so he/she can select another font.

Also, the final object being a texture, may be, a mix of user chosen font plus its missing glyphs from another font could do the trick… but, I know little about each glyph positioning (advance etc), but I believe we can trust on the “gaps filling” font information; just make sure to mix monospaced with monospaced and everything “should” go well (with the proper scaling of course, also to the glyph metrics).

You could use my jME-TrueTypeFontLite library for what you’re wanting to do.

assetManager.registerLoader(TrueTypeLoader.class, "ttf");

Then at some point have the user browse to and select a font file from their hard drive.

File fontFile = new File(userSelectedPath);
assetManager.registerLocator(fontFile.getParent(), FileLocator.class);

TrueTypeKey ttk = new TrueTypeKey(userSelectedPath,
    java.awt.Font.PLAIN, userSelectedPointSizeInt);
TrueTypeFont ttf = (TrueTypeFont)assetManager.loadAsset(ttk);

UI.getAssetManager().unregisterLocator(fontFile.getParent(), FileLocator.class);

the jME-TrueTypeFontLite library doesn’t include methods for determining if a glyph in a particular font file has contours or not, but the source is available so you could write that yourself easily enough:

public boolean hasContours(String character) {
    GlyphVector gv = font.createGlyphVector(frc, character);
    GeneralPath path = (GeneralPath)gv.getOutline();
    PathIterator pi = path.getPathIterator(null);
    if (pi.isDone())
        return false;
    
    return true;
}

Otherwise Google’s sfntly was a nice font reading library to work with, it also supports open type fonts. https://github.com/googlei18n/sfntly

P.S. The jME-TrueTypeFontLite library uses java.awt.Font’s canDisplay() method to determine if a glyph is available in a particular font file, if not a default glyph is used in place of the requested missing glyph. Although I have found some glyphs that java.awt.Font’s canDisplay() method returns true for actually have zero contours. The same was true with Google’s sfntly library, a glyph would be available in the font file, but would have no contours.

1 Like

oh ok! I re-read your post there, you made for your project a light version that doesnt depend on GPLv3 neither LGPL libraries, that will be very useful! jME-TrueTypeFont Rendering Library - #9 by Tryder
thx!