Skip to content

Commit ea9678c

Browse files
committed
Removed TextStyle auto-quotes and added docs instead.
1 parent 4c24799 commit ea9678c

3 files changed

Lines changed: 45 additions & 3 deletions

File tree

CHANGELOG.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,6 @@ one set of bindings ever created, which makes things a lot cleaner.
302302
* `CanvasTexture.destroy` is a new method that specifically handles the destruction of the CanvasTexture and all of its associated typed arrays. This prevents a memory leak when creating and destroying lots of RenderTextures (which are CanvasTexture backed). Fix #4239 (thanks @sjb933)
303303
* The Alpha, Flip and Origin components have been removed from the Mesh Game Object (and by extension, Quad as well) as they are not used in the renderer and should be manipulated via the Mesh properties. Fix #4188 (thanks @enriqueto)
304304
* The `processDomCallbacks` method in the Input Manager wasn't correctly clearing the `once` arrays. Responsibility for this has now been passed to the queue methods `queueTouchStart`, `queueTouchMove`, `queueTouchEnd`, `queueMouseDown`, `queueMouseMove` and `queueMouseUp`. Fix #4257 (thanks @iArePJ)
305-
* The fontFamily in the Text object is now quoted when synced to the Canvas context, this fixes an issue where you couldn't use web fonts that had numbers in the name, such as "Press Start 2P" (thanks @BeFiveINFO)
306305
* Arcade Physics now manages when `postUpdate` should be applied better, stopping it from gaining a zero delta during a further check in the same frame. This fixes various issues, including the mass collision test demo. Fix #4154 (thanks @samme)
307306
* Arcade Physics could trigger a `collide` event on a Body even if it performing an overlap check, if the `onCollide` property was true (thanks @samme)
308307

src/gameobjects/text/TextStyle.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -397,7 +397,7 @@ var TextStyle = new Class({
397397
this.setFont(font, false);
398398
}
399399

400-
this._font = [ this.fontStyle, this.fontSize, '"' + this.fontFamily + '"' ].join(' ').trim();
400+
this._font = [ this.fontStyle, this.fontSize, this.fontFamily ].join(' ').trim();
401401

402402
// Allow for 'fill' to be used in place of 'color'
403403
var fill = GetValue(style, 'fill', null);
@@ -493,7 +493,7 @@ var TextStyle = new Class({
493493
{
494494
if (recalculateMetrics)
495495
{
496-
this._font = [ this.fontStyle, this.fontSize, '"' + this.fontFamily + '"' ].join(' ').trim();
496+
this._font = [ this.fontStyle, this.fontSize, this.fontFamily ].join(' ').trim();
497497

498498
this.metrics = MeasureText(this);
499499
}

src/gameobjects/text/static/Text.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,21 @@ var TextStyle = require('../TextStyle');
2727
* Because it uses the Canvas API you can take advantage of all the features this offers, such as
2828
* applying gradient fills to the text, or strokes, shadows and more. You can also use custom fonts
2929
* loaded externally, such as Google or TypeKit Web fonts.
30+
*
31+
* **Important:** If the font you wish to use has a space or digit in its name, such as
32+
* 'Press Start 2P' or 'Roboto Condensed', then you _must_ put the font name in quotes, either
33+
* when creating the Text object, or when setting the font via `setFont` or `setFontFamily`. I.e.:
34+
*
35+
* ```javascript
36+
* this.add.text(0, 0, 'Hello World', { fontFamily: '"Roboto Condensed"' });
37+
* ```
38+
*
39+
* Equally, if you wish to provide a list of fallback fonts, then you should ensure they are all
40+
* quoted properly, too:
41+
*
42+
* ```javascript
43+
* this.add.text(0, 0, 'Hello World', { fontFamily: 'Verdana, "Times New Roman", Tahoma, serif' });
44+
* ```
3045
*
3146
* You can only display fonts that are currently loaded and available to the browser: therefore fonts must
3247
* be pre-loaded. Phaser does not do ths for you, so you will require the use of a 3rd party font loader,
@@ -629,6 +644,20 @@ var Text = new Class({
629644
*
630645
* If an object is given, the `fontFamily`, `fontSize` and `fontStyle`
631646
* properties of that object are set.
647+
*
648+
* **Important:** If the font you wish to use has a space or digit in its name, such as
649+
* 'Press Start 2P' or 'Roboto Condensed', then you _must_ put the font name in quotes:
650+
*
651+
* ```javascript
652+
* Text.setFont('"Roboto Condensed"');
653+
* ```
654+
*
655+
* Equally, if you wish to provide a list of fallback fonts, then you should ensure they are all
656+
* quoted properly, too:
657+
*
658+
* ```javascript
659+
* Text.setFont('Verdana, "Times New Roman", Tahoma, serif');
660+
* ```
632661
*
633662
* @method Phaser.GameObjects.Text#setFont
634663
* @since 3.0.0
@@ -644,6 +673,20 @@ var Text = new Class({
644673

645674
/**
646675
* Set the font family.
676+
*
677+
* **Important:** If the font you wish to use has a space or digit in its name, such as
678+
* 'Press Start 2P' or 'Roboto Condensed', then you _must_ put the font name in quotes:
679+
*
680+
* ```javascript
681+
* Text.setFont('"Roboto Condensed"');
682+
* ```
683+
*
684+
* Equally, if you wish to provide a list of fallback fonts, then you should ensure they are all
685+
* quoted properly, too:
686+
*
687+
* ```javascript
688+
* Text.setFont('Verdana, "Times New Roman", Tahoma, serif');
689+
* ```
647690
*
648691
* @method Phaser.GameObjects.Text#setFontFamily
649692
* @since 3.0.0

0 commit comments

Comments
 (0)