MCPcopy Create free account
hub / github.com/phaserjs/phaser / measureTextWidth

Function measureTextWidth

src/gameobjects/bitmaptext/GetBitmapTextSize.js:110–126  ·  view source on GitHub ↗
(text, fontData)

Source from the content-addressed store, hash-verified

108
109 // Measure the width of the text
110 var measureTextWidth = function (text, fontData)
111 {
112 var width = 0;
113
114 for (var i = 0; i < text.length; i++)
115 {
116 var charCode = text.charCodeAt(i);
117 var glyph = fontData.chars[charCode];
118
119 if (glyph)
120 {
121 width += glyph.xAdvance;
122 }
123 }
124
125 return width * sx;
126 };
127
128 // Scan for breach of maxWidth and insert carriage-returns
129 if (maxWidth > 0)

Callers 1

GetBitmapTextSizeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…