I noticed that font characters had a large amount of padding in the texture atlas, leading to a lot of wasted space. This patch fixes that:
=== modified file treegui/eggatlas.py
--- treegui/eggatlas.py 2009-09-08 17:31:46 +0000
+++ treegui/eggatlas.py 2009-09-25 19:34:44 +0000
@@ -225,7 +225,7 @@
charName = name+str(i)
#print i,charName,"'%s'"%char
glyph = font.getGlyph(i)
- w,h = glyph.getWidth(),glyph.getBottom()
+ w,h = glyph.getWidth(),glyph.getBottom()-glyph.getTop()
image = PNMImage(w+PADDING*2,h+PADDING*2)
image.addAlpha()
image.alphaFill()
@@ -239,7 +239,7 @@
#image.write(tmp+"/%i.png"%i)
self.extents[charName] = (
glyph.getAdvance(),
- glyph.getBottom()-glyph.getTop())
+ glyph.getBottom()-2*glyph.getTop())
self.it.add(charName,image)
Note that there are some truly strange things going on in PNFTextGlyph’s placement of the baseline, so this is, at best, “bug-compatible” with what’s going on there.