yesterday I started working om making custom sized fonts to my game, in game, using FreeTypeFaceGenerator, and yesterday it worked fine, except an exception I was going to handle today. When I loaded it up today, and tried to run it, it keeps crashing in the part where I create the FTFGen object, I have no idea how to fix this. How do I fix this, where do I even begin? I changed to font file and it gives me the same error it did yesterday, but I don't want the other file (Vivaldi), I need the one I'm testing (Viner Hand ITC). How do I fix this? I'm using .TTF files, not making a bitmapfont file.

I don't want to provide my own source code, but I'll post the same way, just change a couple of things: (I followed a guide located here )
The method recieves three parameters, A FileHandle of the font file, a String of the font name, and a float array with all the sizes which will then turn to size of the font using
 (int)(size*Gdx.graphics.getDensity())
This is the code:

FreeTypeFontGenerator ftfGen = new FreeTypeFontGenerator(handle);
for (float x : size) {
PixmapPacker packer = new PixmapPacker(512, 512, Format.RGBA8888,
2, false);
FreeTypeBitmapFontData fontData = ftfGen.generateData(
(int) (x * Gdx.graphics.getDensity()),
FreeTypeFontGenerator.DEFAULT_CHARS, false, packer);
Array<Page> pages = packer.getPages();
TextureRegion[] textureRegions = new TextureRegion[pages.size];
for (int i = 0; i < pages.size; i++) {
Page p = pages.get(i);
Texture texture = new Texture(new PixmapTextureData(
p.getPixmap(), p.getPixmap().getFormat(), false, false,
true)) {
@Override
public void dispose() {
super.dispose();
getTextureData().consumePixmap().dispose();
}
};
texture.setFilter(Texture.TextureFilter.Nearest,
Texture.TextureFilter.Nearest);
textureRegions[i] = new TextureRegion(texture);
BitmapFont font = new BitmapFont(fontData, textureRegions,
false);
FileHandle file = Gdx.files.local("Data\\VINERITC.TTF");
FileHandle pixmapDir = Gdx.files.local("Data\\VINERITC");
BitmapFontWriter.setOutputFormat(OutputFormat.Text);
String[] pageRefs = BitmapFontWriter.writePixmaps(
packer.getPages(), pixmapDir, fontName);
for (int j = 0; j < pageRefs.length; j++) {
pageRefs[j] = fontName + "_" + pageRefs[j];
}
BitmapFontWriter.writeFont(
font.getData(),
pageRefs,
file,
new FontInfo(fontName, (int) (x * Gdx.graphics
.getDensity())), 1, 1);
packer.dispose();
}

}


The error I am receiving is in this line of code:
 FreeTypeFontGenerator ftfGen = new FreeTypeFontGenerator(handle);
Upon digging around in the code of LibGDX I found out that it is caused by this method, which uses a native method:

    public static Face newMemoryFace(Library library, byte[] data, int dataSize, int faceIndex) {
ByteBuffer buffer = BufferUtils.newUnsafeByteBuffer(data.length);
BufferUtils.copy(data, 0, buffer, data.length);
BufferUtils.disposeUnsafeByteBuffer(buffer);
}
else {
}
}

private static native long newMemoryFace(long library, ByteBuffer data, int dataSize, int faceIndex);


This part gives out the error:

long address = newMemoryFace(library.address, buffer, dataSize, faceIndex);
BufferUtils.disposeUnsafeByteBuffer(buffer);
}


The newMemoryFace is a native method.

I FOUND THE PROBLEM! This line is the problem:

FileHandle file = Gdx.files.local("Data\\VINERITC.TTF");


This line caused a creation of a new TTF file, and thus cause a problem with the loading system, make sure if you use this to write  .fnt  and not TTF.

• If you're using version control, why not just roll back your change? – ashes999 Jun 16 '14 at 20:01
• I'm not using version control, but it's the exact same code from last night the only thing I change was full screen so I could bugfix the problem which when using a different font creates the exception I was going to fix. I changed it back but it's still the same Couldn't load font exception... – Aon GoltzCrank Jun 16 '14 at 20:06
• Please begin by providing us current source code examples that we may look over as a starting point. – Matt Sams Jun 16 '14 at 20:59
• Added source code. – Aon GoltzCrank Jun 16 '14 at 21:07
• Please use version control. You'll save yourself hours of headaches. Git and Mercurial both work without a central server and allow local check-ins. – ashes999 Jun 16 '14 at 21:21

To anyone who had run into this problem, it originates from the creation (at least for me) of another TTF file in the local directory (I.e. "myGDXGame-desktop"), and this causes a problem with the loading of the font. Make sure that this line, that is the save directory for the .fnt file, is not saving as .TTF
FileHandle file = Gdx.files.local("Data\\VINERITC.TTF");

FileHandle file = Gdx.files.local("Data\\VINERITC.fnt");