@hexze/mctext 1.2.0 → 1.3.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/mctext_wasm.d.ts +15 -0
- package/mctext_wasm.js +90 -4
- package/mctext_wasm_bg.wasm +0 -0
- package/package.json +1 -1
package/mctext_wasm.d.ts
CHANGED
|
@@ -1,11 +1,20 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
|
+
export enum FontFamily {
|
|
5
|
+
Minecraft = 0,
|
|
6
|
+
Enchanting = 1,
|
|
7
|
+
Illager = 2,
|
|
8
|
+
}
|
|
9
|
+
|
|
4
10
|
export class FontSystem {
|
|
5
11
|
private constructor();
|
|
6
12
|
free(): void;
|
|
7
13
|
[Symbol.dispose](): void;
|
|
14
|
+
ascentRatio(): number;
|
|
15
|
+
static legacy(): FontSystem;
|
|
8
16
|
measure(text: string, size: number): number;
|
|
17
|
+
measureFamily(text: string, size: number, family: FontFamily): number;
|
|
9
18
|
static modern(): FontSystem;
|
|
10
19
|
}
|
|
11
20
|
|
|
@@ -13,6 +22,8 @@ export class LayoutOptions {
|
|
|
13
22
|
free(): void;
|
|
14
23
|
[Symbol.dispose](): void;
|
|
15
24
|
constructor(size: number);
|
|
25
|
+
withAlign(align: string): LayoutOptions;
|
|
26
|
+
withLineSpacing(spacing: number): LayoutOptions;
|
|
16
27
|
withMaxWidth(width: number): LayoutOptions;
|
|
17
28
|
withShadow(shadow: boolean): LayoutOptions;
|
|
18
29
|
}
|
|
@@ -20,6 +31,8 @@ export class LayoutOptions {
|
|
|
20
31
|
export class MCText {
|
|
21
32
|
free(): void;
|
|
22
33
|
[Symbol.dispose](): void;
|
|
34
|
+
concat(other: MCText): MCText;
|
|
35
|
+
isEmpty(): boolean;
|
|
23
36
|
constructor();
|
|
24
37
|
static parse(text: string): MCText;
|
|
25
38
|
static parseJson(json: string): MCText;
|
|
@@ -59,4 +72,6 @@ export function namedColors(): any;
|
|
|
59
72
|
|
|
60
73
|
export function render(font_system: FontSystem, text: MCText, width: number, height: number, options: LayoutOptions): RenderResult;
|
|
61
74
|
|
|
75
|
+
export function renderFamily(font_system: FontSystem, text: string, width: number, height: number, size: number, family: FontFamily): RenderResult;
|
|
76
|
+
|
|
62
77
|
export function stripCodes(text: string): string;
|
package/mctext_wasm.js
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
/* @ts-self-types="./mctext_wasm.d.ts" */
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* @enum {0 | 1 | 2}
|
|
5
|
+
*/
|
|
6
|
+
const FontFamily = Object.freeze({
|
|
7
|
+
Minecraft: 0, "0": "Minecraft",
|
|
8
|
+
Enchanting: 1, "1": "Enchanting",
|
|
9
|
+
Illager: 2, "2": "Illager",
|
|
10
|
+
});
|
|
11
|
+
exports.FontFamily = FontFamily;
|
|
12
|
+
|
|
3
13
|
class FontSystem {
|
|
4
14
|
static __wrap(ptr) {
|
|
5
15
|
ptr = ptr >>> 0;
|
|
@@ -18,6 +28,20 @@ class FontSystem {
|
|
|
18
28
|
const ptr = this.__destroy_into_raw();
|
|
19
29
|
wasm.__wbg_fontsystem_free(ptr, 0);
|
|
20
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* @returns {number}
|
|
33
|
+
*/
|
|
34
|
+
ascentRatio() {
|
|
35
|
+
const ret = wasm.fontsystem_ascentRatio(this.__wbg_ptr);
|
|
36
|
+
return ret;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* @returns {FontSystem}
|
|
40
|
+
*/
|
|
41
|
+
static legacy() {
|
|
42
|
+
const ret = wasm.fontsystem_legacy();
|
|
43
|
+
return FontSystem.__wrap(ret);
|
|
44
|
+
}
|
|
21
45
|
/**
|
|
22
46
|
* @param {string} text
|
|
23
47
|
* @param {number} size
|
|
@@ -29,6 +53,18 @@ class FontSystem {
|
|
|
29
53
|
const ret = wasm.fontsystem_measure(this.__wbg_ptr, ptr0, len0, size);
|
|
30
54
|
return ret;
|
|
31
55
|
}
|
|
56
|
+
/**
|
|
57
|
+
* @param {string} text
|
|
58
|
+
* @param {number} size
|
|
59
|
+
* @param {FontFamily} family
|
|
60
|
+
* @returns {number}
|
|
61
|
+
*/
|
|
62
|
+
measureFamily(text, size, family) {
|
|
63
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
64
|
+
const len0 = WASM_VECTOR_LEN;
|
|
65
|
+
const ret = wasm.fontsystem_measureFamily(this.__wbg_ptr, ptr0, len0, size, family);
|
|
66
|
+
return ret;
|
|
67
|
+
}
|
|
32
68
|
/**
|
|
33
69
|
* @returns {FontSystem}
|
|
34
70
|
*/
|
|
@@ -67,13 +103,30 @@ class LayoutOptions {
|
|
|
67
103
|
LayoutOptionsFinalization.register(this, this.__wbg_ptr, this);
|
|
68
104
|
return this;
|
|
69
105
|
}
|
|
106
|
+
/**
|
|
107
|
+
* @param {string} align
|
|
108
|
+
* @returns {LayoutOptions}
|
|
109
|
+
*/
|
|
110
|
+
withAlign(align) {
|
|
111
|
+
const ptr0 = passStringToWasm0(align, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
112
|
+
const len0 = WASM_VECTOR_LEN;
|
|
113
|
+
const ret = wasm.layoutoptions_withAlign(this.__wbg_ptr, ptr0, len0);
|
|
114
|
+
return LayoutOptions.__wrap(ret);
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* @param {number} spacing
|
|
118
|
+
* @returns {LayoutOptions}
|
|
119
|
+
*/
|
|
120
|
+
withLineSpacing(spacing) {
|
|
121
|
+
const ret = wasm.layoutoptions_withLineSpacing(this.__wbg_ptr, spacing);
|
|
122
|
+
return LayoutOptions.__wrap(ret);
|
|
123
|
+
}
|
|
70
124
|
/**
|
|
71
125
|
* @param {number} width
|
|
72
126
|
* @returns {LayoutOptions}
|
|
73
127
|
*/
|
|
74
128
|
withMaxWidth(width) {
|
|
75
|
-
const
|
|
76
|
-
const ret = wasm.layoutoptions_withMaxWidth(ptr, width);
|
|
129
|
+
const ret = wasm.layoutoptions_withMaxWidth(this.__wbg_ptr, width);
|
|
77
130
|
return LayoutOptions.__wrap(ret);
|
|
78
131
|
}
|
|
79
132
|
/**
|
|
@@ -81,8 +134,7 @@ class LayoutOptions {
|
|
|
81
134
|
* @returns {LayoutOptions}
|
|
82
135
|
*/
|
|
83
136
|
withShadow(shadow) {
|
|
84
|
-
const
|
|
85
|
-
const ret = wasm.layoutoptions_withShadow(ptr, shadow);
|
|
137
|
+
const ret = wasm.layoutoptions_withShadow(this.__wbg_ptr, shadow);
|
|
86
138
|
return LayoutOptions.__wrap(ret);
|
|
87
139
|
}
|
|
88
140
|
}
|
|
@@ -107,6 +159,22 @@ class MCText {
|
|
|
107
159
|
const ptr = this.__destroy_into_raw();
|
|
108
160
|
wasm.__wbg_mctext_free(ptr, 0);
|
|
109
161
|
}
|
|
162
|
+
/**
|
|
163
|
+
* @param {MCText} other
|
|
164
|
+
* @returns {MCText}
|
|
165
|
+
*/
|
|
166
|
+
concat(other) {
|
|
167
|
+
_assertClass(other, MCText);
|
|
168
|
+
const ret = wasm.mctext_concat(this.__wbg_ptr, other.__wbg_ptr);
|
|
169
|
+
return MCText.__wrap(ret);
|
|
170
|
+
}
|
|
171
|
+
/**
|
|
172
|
+
* @returns {boolean}
|
|
173
|
+
*/
|
|
174
|
+
isEmpty() {
|
|
175
|
+
const ret = wasm.mctext_isEmpty(this.__wbg_ptr);
|
|
176
|
+
return ret !== 0;
|
|
177
|
+
}
|
|
110
178
|
constructor() {
|
|
111
179
|
const ret = wasm.mctext_new();
|
|
112
180
|
this.__wbg_ptr = ret >>> 0;
|
|
@@ -378,6 +446,24 @@ function render(font_system, text, width, height, options) {
|
|
|
378
446
|
}
|
|
379
447
|
exports.render = render;
|
|
380
448
|
|
|
449
|
+
/**
|
|
450
|
+
* @param {FontSystem} font_system
|
|
451
|
+
* @param {string} text
|
|
452
|
+
* @param {number} width
|
|
453
|
+
* @param {number} height
|
|
454
|
+
* @param {number} size
|
|
455
|
+
* @param {FontFamily} family
|
|
456
|
+
* @returns {RenderResult}
|
|
457
|
+
*/
|
|
458
|
+
function renderFamily(font_system, text, width, height, size, family) {
|
|
459
|
+
_assertClass(font_system, FontSystem);
|
|
460
|
+
const ptr0 = passStringToWasm0(text, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc);
|
|
461
|
+
const len0 = WASM_VECTOR_LEN;
|
|
462
|
+
const ret = wasm.renderFamily(font_system.__wbg_ptr, ptr0, len0, width, height, size, family);
|
|
463
|
+
return RenderResult.__wrap(ret);
|
|
464
|
+
}
|
|
465
|
+
exports.renderFamily = renderFamily;
|
|
466
|
+
|
|
381
467
|
/**
|
|
382
468
|
* @param {string} text
|
|
383
469
|
* @returns {string}
|
package/mctext_wasm_bg.wasm
CHANGED
|
Binary file
|