Skip to content

Commit 7bd8bf2

Browse files
committed
The testString can now be set in the Text config.
1 parent b53f68c commit 7bd8bf2

1 file changed

Lines changed: 4 additions & 6 deletions

File tree

v3/src/gameobjects/text/MeasureText.js

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ var CanvasPool = require('../../display/canvas/CanvasPool');
33
/**
44
* Calculates the ascent, descent and fontSize of a given font style.
55
*/
6-
var MeasureText = function (textStyle, testString)
6+
var MeasureText = function (textStyle)
77
{
8-
if (testString === undefined) { testString = '|MÉqgy'; }
9-
108
// @property {HTMLCanvasElement} canvas - The canvas element that the text is rendered.
119
var canvas = CanvasPool.create(this);
1210

@@ -15,7 +13,7 @@ var MeasureText = function (textStyle, testString)
1513

1614
textStyle.syncFont(canvas, context);
1715

18-
var width = Math.ceil(context.measureText(testString).width * 1.2);
16+
var width = Math.ceil(context.measureText(textStyle.testString).width * 1.2);
1917
var baseline = width;
2018
var height = 2 * baseline;
2119

@@ -27,11 +25,11 @@ var MeasureText = function (textStyle, testString)
2725
context.fillStyle = '#f00';
2826
context.fillRect(0, 0, width, height);
2927

30-
context.font = textStyle.font;
28+
context.font = textStyle._font;
3129

3230
context.textBaseline = 'alphabetic';
3331
context.fillStyle = '#000';
34-
context.fillText(testString, 0, baseline);
32+
context.fillText(textStyle.testString, 0, baseline);
3533

3634
var output = {
3735
ascent: 0,

0 commit comments

Comments
 (0)