Module gamejs/font
Methods for creating Font objects which can render text
to a Surface.
Example
// create a font
var font = new Font('20px monospace');
// render text - this returns a surface with the text written on it.
var helloSurface = font.render('Hello World')
Instance Methods
Instance Properties
Font
(fontSettings, backgroundColor)
Create a Font to draw on the screen. The Font allows you to
render() text. Rendering text returns a Surface which
in turn can be put on screen.
Parameters
| String |
fontSettings |
a css font definition, e.g., "20px monospace" |
| STring |
backgroundColor |
valid #rgb string, "#ff00cc" |
Font.prototype.render
(text, color)
Returns a Surface with the given text on it.
Parameters
| String |
text |
the text to render |
| String |
color |
a valid #RGB String, "#ffcc00" |
Returns
| gamejs.Surface |
Surface with the rendered text on it. |
Font.prototype.size
(text)
Determine the width and height of the given text if rendered
with this Font.
Parameters
| String |
text |
the text to measure |
Returns
| Array |
the [width, height] of the text if rendered with this Font |