Class: Font

me. Font

new Font(font, size, fillStyle, textAlign)

a generic system font object.
Parameters:
Name Type Argument Default Description
font String a CSS font name
size Number | String size, or size + suffix (px, em, pt)
fillStyle me.Color | String a CSS color value
textAlign String <optional>
"left" horizontal alignment
Source:
font.js, line 30

Extends

Members

alpha :Number

Define the renderable opacity
Set to zero if you do not wish an object to be drawn
Type:
  • Number
Inherited From:
Default Value:
  • 1.0
Source:
renderable.js, line 151
See:
  • me.Renderable#setOpacity
  • me.Renderable#getOpacity

ancestor :me.Container

a reference to the Container object that contains this renderable, or undefined if it has not been added to one.
Type:
Inherited From:
Default Value:
  • undefined
Source:
renderable.js, line 163

fillStyle :me.Color

defines the color used to draw the font.
Type:
Default Value:
  • black
Source:
font.js, line 39

lineHeight :Number

Set the line spacing height (when displaying multi-line strings).
Current font height will be multiplied with this value to set the line height.
Type:
  • Number
Default Value:
  • 1.0
Source:
font.js, line 86

lineWidth :Number

sets the current line width, in pixels, when drawing stroke
Type:
  • Number
Default Value:
  • 1
Source:
font.js, line 57

strokeStyle :me.Color

defines the color used to draw the font stroke.
Type:
Default Value:
  • black
Source:
font.js, line 48

textAlign :String

Set the default text alignment (or justification),
possible values are "left", "right", and "center".
Type:
  • String
Default Value:
  • "left"
Source:
font.js, line 66

textBaseline :String

Set the text baseline (e.g. the Y-coordinate for the draw operation),
possible values are "top", "hanging, "middle, "alphabetic, "ideographic, "bottom"
Type:
  • String
Default Value:
  • "top"
Source:
font.js, line 76

Methods

<static> bold()

make the font bold
Source:
font.js, line 107

<static> draw(renderer, text, x, y)

draw a text at the specified coord
Parameters:
Name Type Description
renderer me.CanvasRenderer | me.WebGLRenderer Reference to the destination renderer instance
text String
x Number
y Number
Source:
font.js, line 205

<static> drawStroke(renderer, text, x, y)

draw a stroke text at the specified coord, as defined
by the `lineWidth` and `fillStroke` properties.
Note : using drawStroke is not recommended for performance reasons
Parameters:
Name Type Description
renderer me.CanvasRenderer | me.WebGLRenderer Reference to the destination renderer instance
text String
x Number
y Number
Source:
font.js, line 228

<static> italic()

make the font italic
Source:
font.js, line 117

<static> measureText(renderer, text) → {Object}

measure the given text size in pixels
Parameters:
Name Type Description
renderer me.CanvasRenderer | me.WebGLRenderer Reference to the destination renderer instance
text String
Source:
font.js, line 174
Returns:
returns an object, with two attributes: width (the width of the text) and height (the height of the text).
Type
Object

<static> setFont(font, size, fillStyle, textAlign)

Change the font settings
Parameters:
Name Type Argument Default Description
font String a CSS font name
size Number | String size, or size + suffix (px, em, pt)
fillStyle me.Color | String <optional>
a CSS color value
textAlign String <optional>
"left" horizontal alignment
Source:
font.js, line 127
Example
font.setFont("Arial", 20, "white");
font.setFont("Arial", "1.5em", "white");
Copyright © 2011 - 2017, Olivier Biot, Jason Oster, Aaron McLeod
Documentation generated by JSDoc 3.4.0 on 2017-02-28T11:37:40+08:00 using the DocStrap template modified by codename-.