libgdx/libgdx — pull request #263 by littlebtc (2013-02-25 09:08:40+00:00)
Title: Add margin per pixmap to PixmapPacker, fix the FreeType extensions issues on rendering

Hi, I am littlebtc (Hsiao-Ting Yu) from the Briareus Network Techonology, a game engine startup in Taiwan. We are developing our commercial game engine and using libgdx in our Android client implementation. Libgdx is very great and we love it <3

However, we encountered some problems about the freetype extensions. Due to the large size of asian scripts, we use the Motoya Japanese font from Android Open Source Project ( [Font on GitHub Mirrors](https://github.com/android/platform_frameworks_base/blob/master/data/fonts/MTLmr3m.ttf) ), and dynamically generate the BitmapFont using the freetype extension.

However, Motoya fonts includes some punctuation mark with halt width and height (e.g. 22px font has 7x9 full-sized comma), the PixmapPacker cannot efficiently deal with that type of various glyph sizes, and the generator did not give the enought size for drawing to the page. So the glyphs will be drawn on the second page, and since BitmapFontCache will only use one texture, the font rendering will be simply broken.

![Result](http://i.imgur.com/hccEgBq.png)
The texture page when rendering "―ア最大級" with MTLmr3m, sized 22, where "級" is absent.

To fix it, I investigate the rendering part and the pull request is my solution:

1. Improve the calulation of the PixmapPacker size; consider the packer padding and use ceil(sqrt(text.length)) to ensure there will always be enough spaces to fill the texts.
2. Allow setting "margins" for every pixmaps on the packer, this will make PixmapPacker places every texts in gird and there will be no strange position anymore.

------------------------------

And about the CLA, I discussed with my employer and we decided to sign a Corporate CLA (from Briareus Network Technology) instead of Personal CLA. Can we make a modification from Apache's Corporate CLA and sign on behalf of our company? :smile: