libgdx/libgdx — pull request #494 by mattdesl (2013-07-02 20:07:36+00:00)
Title: Multi-Page Fonts & Tightly Packed FreeType Glyphs

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.

The result of this can be seen in FreeTypeFontGenerator -- 3,122 glyphs are packed into 2 texture pages. The result is 2 font styles (regular, italic) with 7 sizes each, or a total of 14 BitmapFont objects. We can adjust the maximum atlas size with `FreeTypeFontGenerator.setMaxTextureSize` to produce more or less texture 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.

## Future Thoughts:

I am currently working on a tool which allows you to specify many BMFont files and TTF files, and it will 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 becomes core in scene2D and BitmapFontCache.