@vpmedia/phaser 1.76.0 → 1.77.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/lefthook.yml +0 -4
- package/package.json +13 -15
- package/src/phaser/display/text.js +34 -4
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @vpmedia/phaser
|
|
2
2
|
|
|
3
|
-
[](https://badge.fury.io/js/@vpmedia%2Fphaser)
|
|
4
4
|
[](https://github.com/vpmedia/phaser/actions/workflows/ci.yml)
|
|
5
5
|
|
|
6
6
|
@vpmedia/phaser is the modern ECMAScript port of the popular Phaser game engine v2.6.2.
|
package/lefthook.yml
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vpmedia/phaser",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.77.0",
|
|
4
4
|
"description": "@vpmedia/phaser is the modern ECMAScript port of the popular Phaser game engine v2.6.2",
|
|
5
5
|
"author": "Andras Csizmadia <andras@vpmedia.hu> (www.vpmedia.hu)",
|
|
6
6
|
"license": "MIT",
|
|
@@ -23,34 +23,32 @@
|
|
|
23
23
|
"types": "./types/index.d.ts",
|
|
24
24
|
"type": "module",
|
|
25
25
|
"dependencies": {
|
|
26
|
-
"@vpmedia/simplify": "^1.
|
|
27
|
-
"uuid": "^11.0
|
|
26
|
+
"@vpmedia/simplify": "^1.17.0",
|
|
27
|
+
"uuid": "^11.1.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
|
-
"@eslint/js": "^9.
|
|
30
|
+
"@eslint/js": "^9.21.0",
|
|
31
31
|
"@jest/globals": "^29.7.0",
|
|
32
32
|
"@types/jest": "^29.5.14",
|
|
33
|
-
"eslint": "^9.
|
|
34
|
-
"eslint-plugin-jsdoc": "^50.6.
|
|
35
|
-
"eslint-plugin-unicorn": "^
|
|
36
|
-
"globals": "^
|
|
33
|
+
"eslint": "^9.23.0",
|
|
34
|
+
"eslint-plugin-jsdoc": "^50.6.8",
|
|
35
|
+
"eslint-plugin-unicorn": "^57.0.0",
|
|
36
|
+
"globals": "^16.0.0",
|
|
37
37
|
"jest": "^29.7.0",
|
|
38
38
|
"jest-environment-jsdom": "^29.7.0",
|
|
39
|
-
"
|
|
40
|
-
"
|
|
41
|
-
"typescript": "^5.7.2"
|
|
39
|
+
"prettier": "^3.5.3",
|
|
40
|
+
"typescript": "^5.8.2"
|
|
42
41
|
},
|
|
43
42
|
"scripts": {
|
|
44
43
|
"test": "NODE_OPTIONS=--experimental-vm-modules jest --passWithNoTests",
|
|
45
44
|
"lint": "eslint \"**/*.{js,jsx}\"",
|
|
46
45
|
"typecheck": "tsc",
|
|
47
|
-
"format": "prettier --write \"./**/*.{js,jsx,mjs,cjs,ts,tsx,json,md,css}\""
|
|
48
|
-
"lefthook:install": "lefthook install",
|
|
49
|
-
"lefthook:uninstall": "lefthook uninstall"
|
|
46
|
+
"format": "prettier --write \"./**/*.{js,jsx,mjs,cjs,ts,tsx,json,md,css}\""
|
|
50
47
|
},
|
|
51
48
|
"browserslist": [
|
|
52
49
|
"> 0.5%",
|
|
53
50
|
"not dead",
|
|
54
|
-
"not op_mini all"
|
|
51
|
+
"not op_mini all",
|
|
52
|
+
"iOS >= 14"
|
|
55
53
|
]
|
|
56
54
|
}
|
|
@@ -153,7 +153,10 @@ export class Text extends Image {
|
|
|
153
153
|
const lineWidths = [];
|
|
154
154
|
let lineWidth = 0;
|
|
155
155
|
let maxLineWidth = 0;
|
|
156
|
-
|
|
156
|
+
let fontProperties = this.determineFontProperties(this.style.font);
|
|
157
|
+
if (!fontProperties.fontSize) {
|
|
158
|
+
fontProperties = this.determineFontPropertiesFallback(this.style.font);
|
|
159
|
+
}
|
|
157
160
|
let drawnLines = lines.length;
|
|
158
161
|
if (this.style.maxLines > 0 && this.style.maxLines < lines.length) {
|
|
159
162
|
drawnLines = this.style.maxLines;
|
|
@@ -894,12 +897,37 @@ export class Text extends Image {
|
|
|
894
897
|
return window.PhaserRegistry.fontPropertiesContext;
|
|
895
898
|
}
|
|
896
899
|
|
|
900
|
+
/**
|
|
901
|
+
* TBD.
|
|
902
|
+
* @param {string} font - TBD.
|
|
903
|
+
* @returns {object} TBD.
|
|
904
|
+
*/
|
|
905
|
+
determineFontProperties(font) {
|
|
906
|
+
const fontPropertiesCache = this.getFontPropertiesCache();
|
|
907
|
+
let properties = fontPropertiesCache[font];
|
|
908
|
+
if (properties) {
|
|
909
|
+
return properties;
|
|
910
|
+
}
|
|
911
|
+
const METRICS_STRING = '|ÉqÅ';
|
|
912
|
+
const BASELINE_SYMBOL = 'M';
|
|
913
|
+
/** @type {CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D} */
|
|
914
|
+
const context = this.getFontPropertiesContext();
|
|
915
|
+
context.font = font;
|
|
916
|
+
const metrics = context.measureText(METRICS_STRING + BASELINE_SYMBOL);
|
|
917
|
+
properties = {
|
|
918
|
+
ascent: Math.ceil(metrics.actualBoundingBoxAscent),
|
|
919
|
+
descent: Math.ceil(metrics.actualBoundingBoxDescent),
|
|
920
|
+
fontSize: Math.ceil(metrics.actualBoundingBoxAscent + metrics.actualBoundingBoxDescent),
|
|
921
|
+
};
|
|
922
|
+
return properties;
|
|
923
|
+
}
|
|
924
|
+
|
|
897
925
|
/**
|
|
898
926
|
* TBD.
|
|
899
927
|
* @param {string} fontStyle - TBD.
|
|
900
928
|
* @returns {object} TBD.
|
|
901
929
|
*/
|
|
902
|
-
|
|
930
|
+
determineFontPropertiesFallback(fontStyle) {
|
|
903
931
|
const fontPropertiesCache = this.getFontPropertiesCache();
|
|
904
932
|
let properties = fontPropertiesCache[fontStyle];
|
|
905
933
|
if (!properties) {
|
|
@@ -936,7 +964,8 @@ export class Text extends Image {
|
|
|
936
964
|
// ascent. scan from top to bottom until we find a non red pixel
|
|
937
965
|
for (i = 0; i < baseline; i += 1) {
|
|
938
966
|
for (j = 0; j < line; j += 4) {
|
|
939
|
-
|
|
967
|
+
// firefox returns 253 for red pixel
|
|
968
|
+
if (imagedata[idx + j] < 253) {
|
|
940
969
|
stop = true;
|
|
941
970
|
break;
|
|
942
971
|
}
|
|
@@ -953,7 +982,8 @@ export class Text extends Image {
|
|
|
953
982
|
// descent. scan from bottom to top until we find a non red pixel
|
|
954
983
|
for (i = height; i > baseline; i -= 1) {
|
|
955
984
|
for (j = 0; j < line; j += 4) {
|
|
956
|
-
|
|
985
|
+
// firefox returns 253 for red pixel
|
|
986
|
+
if (imagedata[idx + j] < 253) {
|
|
957
987
|
stop = true;
|
|
958
988
|
break;
|
|
959
989
|
}
|