libgdx/libgdx — pull request #566 by mattdesl (2013-09-07 19:12:14+00:00)
Title: Multi-Page Fonts & Tightly Packed FreeType Glyphs

#FRESH PULL REQUEST

--

This focuses on two features for bitmap fonts:

- FreeTypeFontGenerator allows the user to specify their own PixmapPacker. This allows for tightly packing many glyphs into a single page.
- BitmapFont, BitmapFontCache, and FreeTypeFontGenerator now support BMFont files with multiple glyphs pages.

As a result, `BitmapFontData.imagePath` and `BitmapFontData.getImagePath()` have been deprecated, and replaced by `imagePaths[]` and `getImagePath(int index)`. Likewise, the same has been done with the `getTextureRegion()` method of FreeTypeBitmapFontData. These could be removed if we're OK with breaking old code.

Users are encouraged to use `BitmapFont.getRegions()` and the TextureRegion[] constructor for greater compatibility with font files. I did not deprecate `BitmapFont.getRegion()` -- although maybe it should be, for consistency's sake.

See the CHANGES file, as well as FreeTypePackTest and BitmapFontTest.

## BitmapFontWriter

A utility in the gdx-tools package for writing bitmap font data to text or XML format -- can be used after generating with FreeType to cache the generated fonts and improve load time on mobile.

## Future Thoughts:

I am currently working on a tool which allows you to specify many BMFont files and TTF files, and it will **tightly** pack all their glyphs into the same texture(s). It then produces a JSON file with details for each FNT (size, name, etc), and ultimately a FontMapper class to facilitate the loading of them. I feel this does not quite belong in the LibGDX codebase; at least not until markup/multi-font text is added to scene2D and BitmapFontCache.