Moai SDK  2.0
MOAIDynamicGlyphCache Class Reference
+ Inheritance diagram for MOAIDynamicGlyphCache:

Function List

setColorFormat
 
setPadding
 

Detailed Description

This is the default implementation of a dynamic glyph cache. Right now it can only grow but support for reference counting glyphs and garbage collection will be added later.

The current implementation is set up in anticipation of garbage collection. If you use MOAIFont's getImage () to inspect the work of this cache you'll see that it is not as efficient in terms of texture use as it could be - glyphs are grouped by size, all glyphs for a given face size are given the same height and layout is orientated around rows. All of this will make it much easier to replace individual glyph slots as the set of glyphs that needs to be in memory changes. That said, we may offer an alternative dynamic cache implementation that attempts a more compact use of texture space, the tradeoff being that there won't be any garbage collection.

This implementation of the dynamic glyph cache does not implement setImage ().

Of course, you can also derive your own implementation from MOAIGlyphCache.

Function Documentation

setColorFormat

The color format may be used by dynamic cache implementations when allocating new textures.


function setColorFormat ( MOAIDynamicGlyphCache self, number colorFmt )

Parameters
MOAIDynamicGlyphCacheself
numbercolorFmt One of MOAIImage.COLOR_FMT_A_8, MOAIImage.COLOR_FMT_RGB_888, MOAIImage.COLOR_FMT_RGB_565, MOAIImage.COLOR_FMT_RGBA_5551, MOAIImage.COLOR_FMT_RGBA_4444, COLOR_FMT_RGBA_8888
Returns
nil
setPadding

Add padding to glyphs when ripping from font.


function setPadding ( MOAIDynamicGlyphCache self, number hPad, number vPad )

Parameters
MOAIDynamicGlyphCacheself
numberhPad glyph xMin -= hPad * 0.5, glyph xMax += hPad * 0.5
numbervPad glyph yMin -= vPad * 0.5, glyph yMax += vPad * 0.5
Returns
nil
Note

function setPadding ( MOAIDynamicGlyphCache self, xMinP glyph, yMinP glyph, xMaxP glyph, yMaxP glyph )

Parameters
MOAIDynamicGlyphCacheself
xMinPglyph xMin -= xMinP
yMinPglyph yMin -= yMinP
xMaxPglyph xMax += xMaxP
yMaxPglyph yMax += yMaxP
Returns
nil
Note