@pixi/text
Advanced tools
Comparing version 5.0.0-rc.3 to 5.0.0
/*! | ||
* @pixi/text - v5.0.0-rc.3 | ||
* Compiled Fri, 22 Mar 2019 16:33:44 UTC | ||
* Compiled Tue, 30 Apr 2019 02:21:00 UTC | ||
* | ||
@@ -64,2 +64,10 @@ * @pixi/text is licensed under the MIT License. | ||
var genericFontFamilies = [ | ||
'serif', | ||
'sans-serif', | ||
'monospace', | ||
'cursive', | ||
'fantasy', | ||
'system-ui' ]; | ||
/** | ||
@@ -679,3 +687,3 @@ * A TextStyle Object contains information to decorate a Text objects. | ||
// Check if font already contains strings | ||
if (!(/([\"\'])[^\'\"]+\1/).test(fontFamily)) | ||
if (!(/([\"\'])[^\'\"]+\1/).test(fontFamily) && genericFontFamilies.indexOf(fontFamily) < 0) | ||
{ | ||
@@ -1436,2 +1444,3 @@ fontFamily = "\"" + fontFamily + "\""; | ||
* Cached canvas element for measuring text | ||
* | ||
* @memberof PIXI.TextMetrics | ||
@@ -1445,2 +1454,3 @@ * @type {HTMLCanvasElement} | ||
* Cache for context to use. | ||
* | ||
* @memberof PIXI.TextMetrics | ||
@@ -1454,2 +1464,3 @@ * @type {CanvasRenderingContext2D} | ||
* Cache of {@see PIXI.TextMetrics.FontMetrics} objects. | ||
* | ||
* @memberof PIXI.TextMetrics | ||
@@ -1463,2 +1474,4 @@ * @type {Object} | ||
* String used for calculate font metrics. | ||
* These characters are all tall to help calculate the height required for text. | ||
* | ||
* @static | ||
@@ -1468,8 +1481,9 @@ * @memberof PIXI.TextMetrics | ||
* @type {string} | ||
* @default |Éq | ||
* @default |ÉqÅ | ||
*/ | ||
TextMetrics.METRICS_STRING = '|Éq'; | ||
TextMetrics.METRICS_STRING = '|ÉqÅ'; | ||
/** | ||
* Baseline symbol for calculate font metrics. | ||
* | ||
* @static | ||
@@ -1485,2 +1499,3 @@ * @memberof PIXI.TextMetrics | ||
* Baseline multiplier for calculate font metrics. | ||
* | ||
* @static | ||
@@ -1496,2 +1511,3 @@ * @memberof PIXI.TextMetrics | ||
* Cache of new line chars. | ||
* | ||
* @memberof PIXI.TextMetrics | ||
@@ -1507,2 +1523,3 @@ * @type {number[]} | ||
* Cache of breaking spaces. | ||
* | ||
* @memberof PIXI.TextMetrics | ||
@@ -1530,2 +1547,3 @@ * @type {number[]} | ||
* A number, or a string containing a number. | ||
* | ||
* @memberof PIXI | ||
@@ -1793,19 +1811,25 @@ * @typedef IFontMetrics | ||
var characters = String.prototype.split.call(text, ''); | ||
var currentPosition = x; | ||
var index = 0; | ||
var current = ''; | ||
while (index < text.length) | ||
// Using Array.from correctly splits characters whilst keeping emoji together. | ||
// This is not supported on IE as it requires ES6, so regular text splitting occurs. | ||
// This also doesn't account for emoji that are multiple emoji put together to make something else. | ||
// Handling all of this would require a big library itself. | ||
// https://medium.com/@giltayar/iterating-over-emoji-characters-the-es6-way-f06e4589516 | ||
// https://github.com/orling/grapheme-splitter | ||
var stringArray = Array.from ? Array.from(text) : text.split(''); | ||
for (var i = 0; i < stringArray.length; ++i) | ||
{ | ||
current = characters[index++]; | ||
var currentChar = stringArray[i]; | ||
if (isStroke) | ||
{ | ||
this.context.strokeText(current, currentPosition, y); | ||
this.context.strokeText(currentChar, currentPosition, y); | ||
} | ||
else | ||
{ | ||
this.context.fillText(current, currentPosition, y); | ||
this.context.fillText(currentChar, currentPosition, y); | ||
} | ||
currentPosition += this.context.measureText(current).width + letterSpacing; | ||
currentPosition += this.context.measureText(currentChar).width + letterSpacing; | ||
} | ||
@@ -1812,0 +1836,0 @@ }; |
/*! | ||
* @pixi/text - v5.0.0-rc.3 | ||
* Compiled Fri, 22 Mar 2019 16:33:44 UTC | ||
* Compiled Tue, 30 Apr 2019 02:21:00 UTC | ||
* | ||
@@ -68,2 +68,10 @@ * @pixi/text is licensed under the MIT License. | ||
var genericFontFamilies = [ | ||
'serif', | ||
'sans-serif', | ||
'monospace', | ||
'cursive', | ||
'fantasy', | ||
'system-ui' ]; | ||
/** | ||
@@ -683,3 +691,3 @@ * A TextStyle Object contains information to decorate a Text objects. | ||
// Check if font already contains strings | ||
if (!(/([\"\'])[^\'\"]+\1/).test(fontFamily)) | ||
if (!(/([\"\'])[^\'\"]+\1/).test(fontFamily) && genericFontFamilies.indexOf(fontFamily) < 0) | ||
{ | ||
@@ -1440,2 +1448,3 @@ fontFamily = "\"" + fontFamily + "\""; | ||
* Cached canvas element for measuring text | ||
* | ||
* @memberof PIXI.TextMetrics | ||
@@ -1449,2 +1458,3 @@ * @type {HTMLCanvasElement} | ||
* Cache for context to use. | ||
* | ||
* @memberof PIXI.TextMetrics | ||
@@ -1458,2 +1468,3 @@ * @type {CanvasRenderingContext2D} | ||
* Cache of {@see PIXI.TextMetrics.FontMetrics} objects. | ||
* | ||
* @memberof PIXI.TextMetrics | ||
@@ -1467,2 +1478,4 @@ * @type {Object} | ||
* String used for calculate font metrics. | ||
* These characters are all tall to help calculate the height required for text. | ||
* | ||
* @static | ||
@@ -1472,8 +1485,9 @@ * @memberof PIXI.TextMetrics | ||
* @type {string} | ||
* @default |Éq | ||
* @default |ÉqÅ | ||
*/ | ||
TextMetrics.METRICS_STRING = '|Éq'; | ||
TextMetrics.METRICS_STRING = '|ÉqÅ'; | ||
/** | ||
* Baseline symbol for calculate font metrics. | ||
* | ||
* @static | ||
@@ -1489,2 +1503,3 @@ * @memberof PIXI.TextMetrics | ||
* Baseline multiplier for calculate font metrics. | ||
* | ||
* @static | ||
@@ -1500,2 +1515,3 @@ * @memberof PIXI.TextMetrics | ||
* Cache of new line chars. | ||
* | ||
* @memberof PIXI.TextMetrics | ||
@@ -1511,2 +1527,3 @@ * @type {number[]} | ||
* Cache of breaking spaces. | ||
* | ||
* @memberof PIXI.TextMetrics | ||
@@ -1534,2 +1551,3 @@ * @type {number[]} | ||
* A number, or a string containing a number. | ||
* | ||
* @memberof PIXI | ||
@@ -1797,19 +1815,25 @@ * @typedef IFontMetrics | ||
var characters = String.prototype.split.call(text, ''); | ||
var currentPosition = x; | ||
var index = 0; | ||
var current = ''; | ||
while (index < text.length) | ||
// Using Array.from correctly splits characters whilst keeping emoji together. | ||
// This is not supported on IE as it requires ES6, so regular text splitting occurs. | ||
// This also doesn't account for emoji that are multiple emoji put together to make something else. | ||
// Handling all of this would require a big library itself. | ||
// https://medium.com/@giltayar/iterating-over-emoji-characters-the-es6-way-f06e4589516 | ||
// https://github.com/orling/grapheme-splitter | ||
var stringArray = Array.from ? Array.from(text) : text.split(''); | ||
for (var i = 0; i < stringArray.length; ++i) | ||
{ | ||
current = characters[index++]; | ||
var currentChar = stringArray[i]; | ||
if (isStroke) | ||
{ | ||
this.context.strokeText(current, currentPosition, y); | ||
this.context.strokeText(currentChar, currentPosition, y); | ||
} | ||
else | ||
{ | ||
this.context.fillText(current, currentPosition, y); | ||
this.context.fillText(currentChar, currentPosition, y); | ||
} | ||
currentPosition += this.context.measureText(current).width + letterSpacing; | ||
currentPosition += this.context.measureText(currentChar).width + letterSpacing; | ||
} | ||
@@ -1816,0 +1840,0 @@ }; |
{ | ||
"name": "@pixi/text", | ||
"version": "5.0.0-rc.3", | ||
"version": "5.0.0", | ||
"main": "lib/text.js", | ||
@@ -30,15 +30,15 @@ "module": "lib/text.es.js", | ||
"dependencies": { | ||
"@pixi/core": "^5.0.0-rc.3", | ||
"@pixi/core": "^5.0.0", | ||
"@pixi/math": "^5.0.0-rc.3", | ||
"@pixi/settings": "^5.0.0-rc.3", | ||
"@pixi/sprite": "^5.0.0-rc.3", | ||
"@pixi/utils": "^5.0.0-rc.3" | ||
"@pixi/settings": "^5.0.0", | ||
"@pixi/sprite": "^5.0.0", | ||
"@pixi/utils": "^5.0.0" | ||
}, | ||
"devDependencies": { | ||
"@pixi/canvas-display": "^5.0.0-rc.3", | ||
"@pixi/canvas-renderer": "^5.0.0-rc.3", | ||
"@pixi/canvas-sprite": "^5.0.0-rc.3", | ||
"@pixi/canvas-display": "^5.0.0", | ||
"@pixi/canvas-renderer": "^5.0.0", | ||
"@pixi/canvas-sprite": "^5.0.0", | ||
"floss": "^2.2.0" | ||
}, | ||
"gitHead": "8bd27c8b903ae2c8f90d91d64e82d65b19ac1cdb" | ||
"gitHead": "607e68419902444cde15f2d69588fbd189481cd8" | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
494167
9
5784
Updated@pixi/core@^5.0.0
Updated@pixi/settings@^5.0.0
Updated@pixi/sprite@^5.0.0
Updated@pixi/utils@^5.0.0