diff --git a/src/gameobjects/text/TextStyle.js b/src/gameobjects/text/TextStyle.js index 1eb1d48f3..6c481491a 100644 --- a/src/gameobjects/text/TextStyle.js +++ b/src/gameobjects/text/TextStyle.js @@ -399,6 +399,8 @@ var TextStyle = new Class({ else { this._font = font; + + this.setFont(font, false); } // Allow for 'fill' to be used in place of 'color' @@ -515,11 +517,14 @@ var TextStyle = new Class({ * @since 3.0.0 * * @param {(string|object)} font - The font family or font settings to set. + * @param {boolean} [updateText=true] - Whether to update the text immediately. * * @return {Phaser.GameObjects.Text} The parent Text object. */ - setFont: function (font) + setFont: function (font, updateText) { + if (updateText === undefined) { updateText = true; } + var fontFamily = font; var fontSize = ''; var fontStyle = ''; @@ -530,14 +535,28 @@ var TextStyle = new Class({ fontSize = GetValue(font, 'fontSize', '16px'); fontStyle = GetValue(font, 'fontStyle', ''); } + else + { + var fontSplit = font.split(' '); + var i = 0; + if (fontSplit.length > 2) + { + this.fontStyle = fontSplit[i++]; + } + this.fontSize = fontSplit[i++] || this.fontSize; + this.fontFamily = fontSplit[i++] || this.fontFamily; + } if (fontFamily !== this.fontFamily || fontSize !== this.fontSize || fontStyle !== this.fontStyle) { this.fontFamily = fontFamily; this.fontSize = fontSize; this.fontStyle = fontStyle; - - this.update(true); + + if (updateText) + { + this.update(true); + } } return this.parent;