Class CachedFont
cached font
Defined in: gamejs-gui.js.
Constructor Attributes | Constructor Name and Description |
---|---|
CachedFont(font, color)
implements lazy caching for individual letters
|
Field Attributes | Field Name and Description |
---|---|
font object used to render characters.
|
|
space between lettersin pixels.
|
|
tab width in pixels.
|
Method Attributes | Method Name and Description |
---|---|
returns gamejs.Surface for a character.
|
|
getTextSize(text)
get size text would occupy if it was rendered
|
|
render(surface, text, position, space_width)
render text on a surface
|
Class Detail
CachedFont(font, color)
implements lazy caching for individual letters
- Parameters:
- {String|Array} font
- either font description as string, or assoc array character:gamejs.Surface
- {String} color
- a valid #RGB String, "#ffcc00"
Field Detail
{gamejs.font.Font}
font
font object used to render characters. Default 14px Verdana
{Number}
space_width
space between lettersin pixels. Default 'm' width divided by 3
{Number}
tab_width
tab width in pixels. Default 3*space_width
Method Detail
{gamejs.Surface}
getCharSurface(c)
returns gamejs.Surface for a character. Caches this surface if it is not cached
- Parameters:
- {String} c
- single character
- Returns:
- {gamejs.Surface} surface object with the character painted on. Not a copy, don't paint on it!
{Array}
getTextSize(text)
get size text would occupy if it was rendered
- Parameters:
- {String} text
- Returns:
- {Array} size, eg. [width, height]
render(surface, text, position, space_width)
render text on a surface
- Parameters:
- {gamejs.Surface} surface
- surface to render text on
- {String} text
- text to render
- {Array} position
- position to render the text at
- {Number} space_width
- OPTIONAL, override space width