modern-text 0.2.42 → 0.2.44
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 +6 -25
- package/dist/index.cjs +99 -77
- package/dist/index.d.cts +63 -91
- package/dist/index.d.mts +63 -91
- package/dist/index.d.ts +63 -91
- package/dist/index.js +4 -4
- package/dist/index.mjs +98 -78
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BoundingBox,
|
|
1
|
+
import { BoundingBox, Path2D, Vector2, VectorLike, Matrix3 } from 'modern-path2d';
|
|
2
2
|
export * from 'modern-path2d';
|
|
3
3
|
import { Sfnt, GlyphPathCommand } from 'modern-font';
|
|
4
4
|
export * from 'modern-font';
|
|
@@ -22,46 +22,49 @@ type HighlightImage = 'none' | string;
|
|
|
22
22
|
type HighlightSize = 'cover' | Sizeable;
|
|
23
23
|
type HighlightStrokeWidth = Sizeable;
|
|
24
24
|
type HighlightOverflow = 'none' | 'visible' | 'hidden';
|
|
25
|
-
interface
|
|
25
|
+
interface TextLineStyle {
|
|
26
26
|
writingMode: WritingMode;
|
|
27
|
-
|
|
27
|
+
textWrap: TextWrap;
|
|
28
|
+
textAlign: TextAlign;
|
|
29
|
+
textIndent: number;
|
|
28
30
|
lineHeight: number;
|
|
31
|
+
listStyleType: ListStyleType;
|
|
32
|
+
listStyleImage: ListStyleImage;
|
|
33
|
+
listStyleSize: ListStyleSize;
|
|
34
|
+
listStylePosition: ListStylePosition;
|
|
35
|
+
}
|
|
36
|
+
interface TextInlineStyle {
|
|
37
|
+
verticalAlign: VerticalAlign;
|
|
29
38
|
letterSpacing: number;
|
|
30
39
|
fontSize: number;
|
|
31
40
|
fontWeight: FontWeight;
|
|
32
41
|
fontFamily: string;
|
|
33
42
|
fontStyle: FontStyle;
|
|
34
43
|
fontKerning?: FontKerning;
|
|
35
|
-
textWrap: TextWrap;
|
|
36
|
-
textAlign: TextAlign;
|
|
37
44
|
textTransform: TextTransform;
|
|
38
45
|
textOrientation: TextOrientation;
|
|
46
|
+
textDecoration: TextDecoration;
|
|
47
|
+
highlightReferImage: HighlightImage;
|
|
48
|
+
highlightImage: HighlightImage;
|
|
49
|
+
highlightSize: HighlightSize;
|
|
50
|
+
highlightStrokeWidth: HighlightStrokeWidth;
|
|
51
|
+
highlightOverflow: HighlightOverflow;
|
|
39
52
|
}
|
|
40
53
|
interface TextDrawStyle {
|
|
41
54
|
color: string | CanvasGradient | CanvasPattern;
|
|
42
55
|
backgroundColor: string | CanvasGradient | CanvasPattern;
|
|
43
|
-
textDecoration: TextDecoration;
|
|
44
56
|
textStrokeWidth: number;
|
|
45
57
|
textStrokeColor: string | CanvasGradient | CanvasPattern;
|
|
46
58
|
shadowColor: string;
|
|
47
59
|
shadowOffsetX: number;
|
|
48
60
|
shadowOffsetY: number;
|
|
49
61
|
shadowBlur: number;
|
|
62
|
+
translateX: number;
|
|
63
|
+
translateY: number;
|
|
64
|
+
skewX: number;
|
|
65
|
+
skewY: number;
|
|
50
66
|
}
|
|
51
|
-
interface
|
|
52
|
-
listStyleType: ListStyleType;
|
|
53
|
-
listStyleImage: ListStyleImage;
|
|
54
|
-
listStyleSize: ListStyleSize;
|
|
55
|
-
listStylePosition: ListStylePosition;
|
|
56
|
-
}
|
|
57
|
-
interface TextHighlightStyle {
|
|
58
|
-
highlightReferImage: HighlightImage;
|
|
59
|
-
highlightImage: HighlightImage;
|
|
60
|
-
highlightSize: HighlightSize;
|
|
61
|
-
highlightStrokeWidth: HighlightStrokeWidth;
|
|
62
|
-
highlightOverflow: HighlightOverflow;
|
|
63
|
-
}
|
|
64
|
-
interface TextStyle extends TextLayoutStyle, TextDrawStyle, TextListStyle, TextHighlightStyle {
|
|
67
|
+
interface TextStyle extends TextLineStyle, TextInlineStyle, TextDrawStyle {
|
|
65
68
|
}
|
|
66
69
|
interface FragmentContent extends Partial<TextStyle> {
|
|
67
70
|
content: string;
|
|
@@ -72,7 +75,7 @@ interface ParagraphContent extends Partial<TextStyle> {
|
|
|
72
75
|
type TextContent = string | FragmentContent | ParagraphContent | (string | FragmentContent | ParagraphContent | (string | FragmentContent)[])[];
|
|
73
76
|
|
|
74
77
|
declare function parseColor(ctx: CanvasRenderingContext2D, source: string | CanvasGradient | CanvasPattern, box: BoundingBox): string | CanvasGradient | CanvasPattern;
|
|
75
|
-
declare function uploadColor(style: Partial<
|
|
78
|
+
declare function uploadColor(style: Partial<TextStyle>, box: BoundingBox, ctx: CanvasRenderingContext2D): void;
|
|
76
79
|
interface LinearGradient {
|
|
77
80
|
x0: number;
|
|
78
81
|
y0: number;
|
|
@@ -84,6 +87,16 @@ interface LinearGradient {
|
|
|
84
87
|
}[];
|
|
85
88
|
}
|
|
86
89
|
|
|
90
|
+
interface DrawShapePathsOptions extends Partial<TextStyle> {
|
|
91
|
+
ctx: CanvasRenderingContext2D;
|
|
92
|
+
path: Path2D;
|
|
93
|
+
fontSize: number;
|
|
94
|
+
clipRect?: BoundingBox;
|
|
95
|
+
}
|
|
96
|
+
declare function drawPath(options: DrawShapePathsOptions): void;
|
|
97
|
+
|
|
98
|
+
declare function setupView(ctx: CanvasRenderingContext2D, pixelRatio: number, boundingBox: BoundingBox): void;
|
|
99
|
+
|
|
87
100
|
declare class Fragment {
|
|
88
101
|
content: string;
|
|
89
102
|
style: Partial<TextStyle>;
|
|
@@ -128,7 +141,7 @@ declare class Character {
|
|
|
128
141
|
max: Vector2;
|
|
129
142
|
} | undefined;
|
|
130
143
|
getGlyphBoundingBox(withStyle?: boolean): BoundingBox | undefined;
|
|
131
|
-
drawTo(ctx: CanvasRenderingContext2D, config?: Partial<
|
|
144
|
+
drawTo(ctx: CanvasRenderingContext2D, config?: Partial<TextStyle>): void;
|
|
132
145
|
}
|
|
133
146
|
|
|
134
147
|
declare class Paragraph {
|
|
@@ -170,7 +183,7 @@ interface MeasuredCharacter {
|
|
|
170
183
|
textHeight: number;
|
|
171
184
|
textWidth: number;
|
|
172
185
|
}
|
|
173
|
-
interface
|
|
186
|
+
interface MeasureDomResult {
|
|
174
187
|
paragraphs: Paragraph[];
|
|
175
188
|
boundingBox: BoundingBox;
|
|
176
189
|
}
|
|
@@ -197,10 +210,22 @@ declare class Measurer {
|
|
|
197
210
|
fragments: MeasuredFragment[];
|
|
198
211
|
characters: MeasuredCharacter[];
|
|
199
212
|
};
|
|
200
|
-
measureDom(dom: HTMLElement):
|
|
201
|
-
measure(dom?: HTMLElement):
|
|
213
|
+
measureDom(dom: HTMLElement): MeasureDomResult;
|
|
214
|
+
measure(dom?: HTMLElement): MeasureDomResult;
|
|
202
215
|
}
|
|
203
216
|
|
|
217
|
+
type PromiseLike<T> = T | Promise<T>;
|
|
218
|
+
interface Plugin {
|
|
219
|
+
name: string;
|
|
220
|
+
paths?: Path2D[];
|
|
221
|
+
getBoundingBox?: (text: Text) => BoundingBox | undefined;
|
|
222
|
+
updateOrder?: number;
|
|
223
|
+
update?: (text: Text) => PromiseLike<void>;
|
|
224
|
+
renderOrder?: number;
|
|
225
|
+
render?: (ctx: CanvasRenderingContext2D, text: Text) => PromiseLike<void>;
|
|
226
|
+
}
|
|
227
|
+
declare function definePlugin(options: Plugin): Plugin;
|
|
228
|
+
|
|
204
229
|
declare class Parser {
|
|
205
230
|
protected _text: Text;
|
|
206
231
|
constructor(_text: Text);
|
|
@@ -215,48 +240,19 @@ interface TextOptions {
|
|
|
215
240
|
content?: TextContent;
|
|
216
241
|
style?: Partial<TextStyle>;
|
|
217
242
|
measureDom?: HTMLElement;
|
|
218
|
-
effects?:
|
|
243
|
+
effects?: Partial<TextStyle>[];
|
|
219
244
|
}
|
|
245
|
+
type MeasureResult = MeasureDomResult & {
|
|
246
|
+
renderBoundingBox: BoundingBox;
|
|
247
|
+
};
|
|
220
248
|
declare const defaultTextStyles: TextStyle;
|
|
221
249
|
declare class Text {
|
|
222
250
|
content: TextContent;
|
|
223
251
|
style: Partial<TextStyle>;
|
|
224
|
-
effects?:
|
|
252
|
+
effects?: Partial<TextStyle>[];
|
|
225
253
|
measureDom?: HTMLElement;
|
|
226
254
|
needsUpdate: boolean;
|
|
227
|
-
computedStyle:
|
|
228
|
-
writingMode: WritingMode;
|
|
229
|
-
verticalAlign: VerticalAlign;
|
|
230
|
-
lineHeight: number;
|
|
231
|
-
letterSpacing: number;
|
|
232
|
-
fontSize: number;
|
|
233
|
-
fontWeight: FontWeight;
|
|
234
|
-
fontFamily: string;
|
|
235
|
-
fontStyle: FontStyle;
|
|
236
|
-
fontKerning?: FontKerning;
|
|
237
|
-
textWrap: TextWrap;
|
|
238
|
-
textAlign: TextAlign;
|
|
239
|
-
textTransform: TextTransform;
|
|
240
|
-
textOrientation: TextOrientation;
|
|
241
|
-
color: string | CanvasGradient | CanvasPattern;
|
|
242
|
-
backgroundColor: string | CanvasGradient | CanvasPattern;
|
|
243
|
-
textDecoration: TextDecoration;
|
|
244
|
-
textStrokeWidth: number;
|
|
245
|
-
textStrokeColor: string | CanvasGradient | CanvasPattern;
|
|
246
|
-
shadowColor: string;
|
|
247
|
-
shadowOffsetX: number;
|
|
248
|
-
shadowOffsetY: number;
|
|
249
|
-
shadowBlur: number;
|
|
250
|
-
listStyleType: ListStyleType;
|
|
251
|
-
listStyleImage: ListStyleImage;
|
|
252
|
-
listStyleSize: ListStyleSize;
|
|
253
|
-
listStylePosition: ListStylePosition;
|
|
254
|
-
highlightReferImage: HighlightImage;
|
|
255
|
-
highlightImage: HighlightImage;
|
|
256
|
-
highlightSize: HighlightSize;
|
|
257
|
-
highlightStrokeWidth: HighlightStrokeWidth;
|
|
258
|
-
highlightOverflow: HighlightOverflow;
|
|
259
|
-
};
|
|
255
|
+
computedStyle: TextStyle;
|
|
260
256
|
paragraphs: Paragraph[];
|
|
261
257
|
boundingBox: BoundingBox;
|
|
262
258
|
renderBoundingBox: BoundingBox;
|
|
@@ -268,50 +264,26 @@ declare class Text {
|
|
|
268
264
|
get characters(): Character[];
|
|
269
265
|
constructor(options?: TextOptions);
|
|
270
266
|
use(plugin: Plugin): this;
|
|
271
|
-
measure(dom?: HTMLElement | undefined):
|
|
267
|
+
measure(dom?: HTMLElement | undefined): MeasureResult;
|
|
272
268
|
requestUpdate(): this;
|
|
273
269
|
update(): this;
|
|
274
270
|
render(options: TextRenderOptions): this;
|
|
275
271
|
}
|
|
276
272
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
paths?: Path2D[];
|
|
281
|
-
getBoundingBox?: (text: Text) => BoundingBox | undefined;
|
|
282
|
-
updateOrder?: number;
|
|
283
|
-
update?: (text: Text) => PromiseLike<void>;
|
|
284
|
-
renderOrder?: number;
|
|
285
|
-
render?: (ctx: CanvasRenderingContext2D, text: Text) => PromiseLike<void>;
|
|
286
|
-
}
|
|
287
|
-
declare function definePlugin(options: Plugin): Plugin;
|
|
273
|
+
declare function uploadColors(ctx: CanvasRenderingContext2D, text: Text): void;
|
|
274
|
+
|
|
275
|
+
declare function measureText(options: TextOptions): MeasureResult;
|
|
288
276
|
|
|
289
277
|
declare function highlight(): Plugin;
|
|
290
278
|
|
|
291
279
|
declare function listStyle(): Plugin;
|
|
292
280
|
|
|
293
|
-
type TextEffect = Partial<TextDrawStyle & {
|
|
294
|
-
offsetX: number;
|
|
295
|
-
offsetY: number;
|
|
296
|
-
skewX: number;
|
|
297
|
-
skewY: number;
|
|
298
|
-
}>;
|
|
299
281
|
declare function render(): Plugin;
|
|
300
|
-
declare function getTransform2D(text: Text, style:
|
|
282
|
+
declare function getTransform2D(text: Text, style: Partial<TextStyle>): Matrix3;
|
|
301
283
|
|
|
302
|
-
|
|
303
|
-
ctx: CanvasRenderingContext2D;
|
|
304
|
-
path: Path2D;
|
|
305
|
-
fontSize: number;
|
|
306
|
-
clipRect?: BoundingBox;
|
|
307
|
-
}
|
|
308
|
-
declare function drawPath(options: DrawShapePathsOptions): void;
|
|
309
|
-
|
|
310
|
-
declare function setupView(ctx: CanvasRenderingContext2D, pixelRatio: number, boundingBox: BoundingBox): void;
|
|
311
|
-
|
|
312
|
-
declare function uploadColors(ctx: CanvasRenderingContext2D, text: Text): void;
|
|
284
|
+
declare function renderText(options: TextOptions & TextRenderOptions): Text;
|
|
313
285
|
|
|
314
286
|
declare function isNone(val: string | undefined): boolean;
|
|
315
287
|
declare function filterEmpty(val: Record<string, any> | undefined): Record<string, any> | undefined;
|
|
316
288
|
|
|
317
|
-
export { Character, type DrawShapePathsOptions, type FontKerning, type FontStyle, type FontWeight, Fragment, type FragmentContent, type HighlightImage, type HighlightOverflow, type HighlightSize, type HighlightStrokeWidth, type LinearGradient, type ListStyleImage, type ListStylePosition, type ListStyleSize, type ListStyleType, type
|
|
289
|
+
export { Character, type DrawShapePathsOptions, type FontKerning, type FontStyle, type FontWeight, Fragment, type FragmentContent, type HighlightImage, type HighlightOverflow, type HighlightSize, type HighlightStrokeWidth, type LinearGradient, type ListStyleImage, type ListStylePosition, type ListStyleSize, type ListStyleType, type MeasureDomResult, type MeasureResult, type MeasuredCharacter, type MeasuredFragment, type MeasuredParagraph, Measurer, Paragraph, type ParagraphContent, Parser, type Plugin, type Sizeable, Text, type TextAlign, type TextContent, type TextDecoration, type TextDrawStyle, type TextInlineStyle, type TextLineStyle, type TextOptions, type TextOrientation, type TextRenderOptions, type TextStyle, type TextTransform, type TextWrap, type VerticalAlign, type WritingMode, defaultTextStyles, definePlugin, drawPath, filterEmpty, getTransform2D, highlight, isNone, listStyle, measureText, parseColor, render, renderText, setupView, uploadColor, uploadColors };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { BoundingBox,
|
|
1
|
+
import { BoundingBox, Path2D, Vector2, VectorLike, Matrix3 } from 'modern-path2d';
|
|
2
2
|
export * from 'modern-path2d';
|
|
3
3
|
import { Sfnt, GlyphPathCommand } from 'modern-font';
|
|
4
4
|
export * from 'modern-font';
|
|
@@ -22,46 +22,49 @@ type HighlightImage = 'none' | string;
|
|
|
22
22
|
type HighlightSize = 'cover' | Sizeable;
|
|
23
23
|
type HighlightStrokeWidth = Sizeable;
|
|
24
24
|
type HighlightOverflow = 'none' | 'visible' | 'hidden';
|
|
25
|
-
interface
|
|
25
|
+
interface TextLineStyle {
|
|
26
26
|
writingMode: WritingMode;
|
|
27
|
-
|
|
27
|
+
textWrap: TextWrap;
|
|
28
|
+
textAlign: TextAlign;
|
|
29
|
+
textIndent: number;
|
|
28
30
|
lineHeight: number;
|
|
31
|
+
listStyleType: ListStyleType;
|
|
32
|
+
listStyleImage: ListStyleImage;
|
|
33
|
+
listStyleSize: ListStyleSize;
|
|
34
|
+
listStylePosition: ListStylePosition;
|
|
35
|
+
}
|
|
36
|
+
interface TextInlineStyle {
|
|
37
|
+
verticalAlign: VerticalAlign;
|
|
29
38
|
letterSpacing: number;
|
|
30
39
|
fontSize: number;
|
|
31
40
|
fontWeight: FontWeight;
|
|
32
41
|
fontFamily: string;
|
|
33
42
|
fontStyle: FontStyle;
|
|
34
43
|
fontKerning?: FontKerning;
|
|
35
|
-
textWrap: TextWrap;
|
|
36
|
-
textAlign: TextAlign;
|
|
37
44
|
textTransform: TextTransform;
|
|
38
45
|
textOrientation: TextOrientation;
|
|
46
|
+
textDecoration: TextDecoration;
|
|
47
|
+
highlightReferImage: HighlightImage;
|
|
48
|
+
highlightImage: HighlightImage;
|
|
49
|
+
highlightSize: HighlightSize;
|
|
50
|
+
highlightStrokeWidth: HighlightStrokeWidth;
|
|
51
|
+
highlightOverflow: HighlightOverflow;
|
|
39
52
|
}
|
|
40
53
|
interface TextDrawStyle {
|
|
41
54
|
color: string | CanvasGradient | CanvasPattern;
|
|
42
55
|
backgroundColor: string | CanvasGradient | CanvasPattern;
|
|
43
|
-
textDecoration: TextDecoration;
|
|
44
56
|
textStrokeWidth: number;
|
|
45
57
|
textStrokeColor: string | CanvasGradient | CanvasPattern;
|
|
46
58
|
shadowColor: string;
|
|
47
59
|
shadowOffsetX: number;
|
|
48
60
|
shadowOffsetY: number;
|
|
49
61
|
shadowBlur: number;
|
|
62
|
+
translateX: number;
|
|
63
|
+
translateY: number;
|
|
64
|
+
skewX: number;
|
|
65
|
+
skewY: number;
|
|
50
66
|
}
|
|
51
|
-
interface
|
|
52
|
-
listStyleType: ListStyleType;
|
|
53
|
-
listStyleImage: ListStyleImage;
|
|
54
|
-
listStyleSize: ListStyleSize;
|
|
55
|
-
listStylePosition: ListStylePosition;
|
|
56
|
-
}
|
|
57
|
-
interface TextHighlightStyle {
|
|
58
|
-
highlightReferImage: HighlightImage;
|
|
59
|
-
highlightImage: HighlightImage;
|
|
60
|
-
highlightSize: HighlightSize;
|
|
61
|
-
highlightStrokeWidth: HighlightStrokeWidth;
|
|
62
|
-
highlightOverflow: HighlightOverflow;
|
|
63
|
-
}
|
|
64
|
-
interface TextStyle extends TextLayoutStyle, TextDrawStyle, TextListStyle, TextHighlightStyle {
|
|
67
|
+
interface TextStyle extends TextLineStyle, TextInlineStyle, TextDrawStyle {
|
|
65
68
|
}
|
|
66
69
|
interface FragmentContent extends Partial<TextStyle> {
|
|
67
70
|
content: string;
|
|
@@ -72,7 +75,7 @@ interface ParagraphContent extends Partial<TextStyle> {
|
|
|
72
75
|
type TextContent = string | FragmentContent | ParagraphContent | (string | FragmentContent | ParagraphContent | (string | FragmentContent)[])[];
|
|
73
76
|
|
|
74
77
|
declare function parseColor(ctx: CanvasRenderingContext2D, source: string | CanvasGradient | CanvasPattern, box: BoundingBox): string | CanvasGradient | CanvasPattern;
|
|
75
|
-
declare function uploadColor(style: Partial<
|
|
78
|
+
declare function uploadColor(style: Partial<TextStyle>, box: BoundingBox, ctx: CanvasRenderingContext2D): void;
|
|
76
79
|
interface LinearGradient {
|
|
77
80
|
x0: number;
|
|
78
81
|
y0: number;
|
|
@@ -84,6 +87,16 @@ interface LinearGradient {
|
|
|
84
87
|
}[];
|
|
85
88
|
}
|
|
86
89
|
|
|
90
|
+
interface DrawShapePathsOptions extends Partial<TextStyle> {
|
|
91
|
+
ctx: CanvasRenderingContext2D;
|
|
92
|
+
path: Path2D;
|
|
93
|
+
fontSize: number;
|
|
94
|
+
clipRect?: BoundingBox;
|
|
95
|
+
}
|
|
96
|
+
declare function drawPath(options: DrawShapePathsOptions): void;
|
|
97
|
+
|
|
98
|
+
declare function setupView(ctx: CanvasRenderingContext2D, pixelRatio: number, boundingBox: BoundingBox): void;
|
|
99
|
+
|
|
87
100
|
declare class Fragment {
|
|
88
101
|
content: string;
|
|
89
102
|
style: Partial<TextStyle>;
|
|
@@ -128,7 +141,7 @@ declare class Character {
|
|
|
128
141
|
max: Vector2;
|
|
129
142
|
} | undefined;
|
|
130
143
|
getGlyphBoundingBox(withStyle?: boolean): BoundingBox | undefined;
|
|
131
|
-
drawTo(ctx: CanvasRenderingContext2D, config?: Partial<
|
|
144
|
+
drawTo(ctx: CanvasRenderingContext2D, config?: Partial<TextStyle>): void;
|
|
132
145
|
}
|
|
133
146
|
|
|
134
147
|
declare class Paragraph {
|
|
@@ -170,7 +183,7 @@ interface MeasuredCharacter {
|
|
|
170
183
|
textHeight: number;
|
|
171
184
|
textWidth: number;
|
|
172
185
|
}
|
|
173
|
-
interface
|
|
186
|
+
interface MeasureDomResult {
|
|
174
187
|
paragraphs: Paragraph[];
|
|
175
188
|
boundingBox: BoundingBox;
|
|
176
189
|
}
|
|
@@ -197,10 +210,22 @@ declare class Measurer {
|
|
|
197
210
|
fragments: MeasuredFragment[];
|
|
198
211
|
characters: MeasuredCharacter[];
|
|
199
212
|
};
|
|
200
|
-
measureDom(dom: HTMLElement):
|
|
201
|
-
measure(dom?: HTMLElement):
|
|
213
|
+
measureDom(dom: HTMLElement): MeasureDomResult;
|
|
214
|
+
measure(dom?: HTMLElement): MeasureDomResult;
|
|
202
215
|
}
|
|
203
216
|
|
|
217
|
+
type PromiseLike<T> = T | Promise<T>;
|
|
218
|
+
interface Plugin {
|
|
219
|
+
name: string;
|
|
220
|
+
paths?: Path2D[];
|
|
221
|
+
getBoundingBox?: (text: Text) => BoundingBox | undefined;
|
|
222
|
+
updateOrder?: number;
|
|
223
|
+
update?: (text: Text) => PromiseLike<void>;
|
|
224
|
+
renderOrder?: number;
|
|
225
|
+
render?: (ctx: CanvasRenderingContext2D, text: Text) => PromiseLike<void>;
|
|
226
|
+
}
|
|
227
|
+
declare function definePlugin(options: Plugin): Plugin;
|
|
228
|
+
|
|
204
229
|
declare class Parser {
|
|
205
230
|
protected _text: Text;
|
|
206
231
|
constructor(_text: Text);
|
|
@@ -215,48 +240,19 @@ interface TextOptions {
|
|
|
215
240
|
content?: TextContent;
|
|
216
241
|
style?: Partial<TextStyle>;
|
|
217
242
|
measureDom?: HTMLElement;
|
|
218
|
-
effects?:
|
|
243
|
+
effects?: Partial<TextStyle>[];
|
|
219
244
|
}
|
|
245
|
+
type MeasureResult = MeasureDomResult & {
|
|
246
|
+
renderBoundingBox: BoundingBox;
|
|
247
|
+
};
|
|
220
248
|
declare const defaultTextStyles: TextStyle;
|
|
221
249
|
declare class Text {
|
|
222
250
|
content: TextContent;
|
|
223
251
|
style: Partial<TextStyle>;
|
|
224
|
-
effects?:
|
|
252
|
+
effects?: Partial<TextStyle>[];
|
|
225
253
|
measureDom?: HTMLElement;
|
|
226
254
|
needsUpdate: boolean;
|
|
227
|
-
computedStyle:
|
|
228
|
-
writingMode: WritingMode;
|
|
229
|
-
verticalAlign: VerticalAlign;
|
|
230
|
-
lineHeight: number;
|
|
231
|
-
letterSpacing: number;
|
|
232
|
-
fontSize: number;
|
|
233
|
-
fontWeight: FontWeight;
|
|
234
|
-
fontFamily: string;
|
|
235
|
-
fontStyle: FontStyle;
|
|
236
|
-
fontKerning?: FontKerning;
|
|
237
|
-
textWrap: TextWrap;
|
|
238
|
-
textAlign: TextAlign;
|
|
239
|
-
textTransform: TextTransform;
|
|
240
|
-
textOrientation: TextOrientation;
|
|
241
|
-
color: string | CanvasGradient | CanvasPattern;
|
|
242
|
-
backgroundColor: string | CanvasGradient | CanvasPattern;
|
|
243
|
-
textDecoration: TextDecoration;
|
|
244
|
-
textStrokeWidth: number;
|
|
245
|
-
textStrokeColor: string | CanvasGradient | CanvasPattern;
|
|
246
|
-
shadowColor: string;
|
|
247
|
-
shadowOffsetX: number;
|
|
248
|
-
shadowOffsetY: number;
|
|
249
|
-
shadowBlur: number;
|
|
250
|
-
listStyleType: ListStyleType;
|
|
251
|
-
listStyleImage: ListStyleImage;
|
|
252
|
-
listStyleSize: ListStyleSize;
|
|
253
|
-
listStylePosition: ListStylePosition;
|
|
254
|
-
highlightReferImage: HighlightImage;
|
|
255
|
-
highlightImage: HighlightImage;
|
|
256
|
-
highlightSize: HighlightSize;
|
|
257
|
-
highlightStrokeWidth: HighlightStrokeWidth;
|
|
258
|
-
highlightOverflow: HighlightOverflow;
|
|
259
|
-
};
|
|
255
|
+
computedStyle: TextStyle;
|
|
260
256
|
paragraphs: Paragraph[];
|
|
261
257
|
boundingBox: BoundingBox;
|
|
262
258
|
renderBoundingBox: BoundingBox;
|
|
@@ -268,50 +264,26 @@ declare class Text {
|
|
|
268
264
|
get characters(): Character[];
|
|
269
265
|
constructor(options?: TextOptions);
|
|
270
266
|
use(plugin: Plugin): this;
|
|
271
|
-
measure(dom?: HTMLElement | undefined):
|
|
267
|
+
measure(dom?: HTMLElement | undefined): MeasureResult;
|
|
272
268
|
requestUpdate(): this;
|
|
273
269
|
update(): this;
|
|
274
270
|
render(options: TextRenderOptions): this;
|
|
275
271
|
}
|
|
276
272
|
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
paths?: Path2D[];
|
|
281
|
-
getBoundingBox?: (text: Text) => BoundingBox | undefined;
|
|
282
|
-
updateOrder?: number;
|
|
283
|
-
update?: (text: Text) => PromiseLike<void>;
|
|
284
|
-
renderOrder?: number;
|
|
285
|
-
render?: (ctx: CanvasRenderingContext2D, text: Text) => PromiseLike<void>;
|
|
286
|
-
}
|
|
287
|
-
declare function definePlugin(options: Plugin): Plugin;
|
|
273
|
+
declare function uploadColors(ctx: CanvasRenderingContext2D, text: Text): void;
|
|
274
|
+
|
|
275
|
+
declare function measureText(options: TextOptions): MeasureResult;
|
|
288
276
|
|
|
289
277
|
declare function highlight(): Plugin;
|
|
290
278
|
|
|
291
279
|
declare function listStyle(): Plugin;
|
|
292
280
|
|
|
293
|
-
type TextEffect = Partial<TextDrawStyle & {
|
|
294
|
-
offsetX: number;
|
|
295
|
-
offsetY: number;
|
|
296
|
-
skewX: number;
|
|
297
|
-
skewY: number;
|
|
298
|
-
}>;
|
|
299
281
|
declare function render(): Plugin;
|
|
300
|
-
declare function getTransform2D(text: Text, style:
|
|
282
|
+
declare function getTransform2D(text: Text, style: Partial<TextStyle>): Matrix3;
|
|
301
283
|
|
|
302
|
-
|
|
303
|
-
ctx: CanvasRenderingContext2D;
|
|
304
|
-
path: Path2D;
|
|
305
|
-
fontSize: number;
|
|
306
|
-
clipRect?: BoundingBox;
|
|
307
|
-
}
|
|
308
|
-
declare function drawPath(options: DrawShapePathsOptions): void;
|
|
309
|
-
|
|
310
|
-
declare function setupView(ctx: CanvasRenderingContext2D, pixelRatio: number, boundingBox: BoundingBox): void;
|
|
311
|
-
|
|
312
|
-
declare function uploadColors(ctx: CanvasRenderingContext2D, text: Text): void;
|
|
284
|
+
declare function renderText(options: TextOptions & TextRenderOptions): Text;
|
|
313
285
|
|
|
314
286
|
declare function isNone(val: string | undefined): boolean;
|
|
315
287
|
declare function filterEmpty(val: Record<string, any> | undefined): Record<string, any> | undefined;
|
|
316
288
|
|
|
317
|
-
export { Character, type DrawShapePathsOptions, type FontKerning, type FontStyle, type FontWeight, Fragment, type FragmentContent, type HighlightImage, type HighlightOverflow, type HighlightSize, type HighlightStrokeWidth, type LinearGradient, type ListStyleImage, type ListStylePosition, type ListStyleSize, type ListStyleType, type
|
|
289
|
+
export { Character, type DrawShapePathsOptions, type FontKerning, type FontStyle, type FontWeight, Fragment, type FragmentContent, type HighlightImage, type HighlightOverflow, type HighlightSize, type HighlightStrokeWidth, type LinearGradient, type ListStyleImage, type ListStylePosition, type ListStyleSize, type ListStyleType, type MeasureDomResult, type MeasureResult, type MeasuredCharacter, type MeasuredFragment, type MeasuredParagraph, Measurer, Paragraph, type ParagraphContent, Parser, type Plugin, type Sizeable, Text, type TextAlign, type TextContent, type TextDecoration, type TextDrawStyle, type TextInlineStyle, type TextLineStyle, type TextOptions, type TextOrientation, type TextRenderOptions, type TextStyle, type TextTransform, type TextWrap, type VerticalAlign, type WritingMode, defaultTextStyles, definePlugin, drawPath, filterEmpty, getTransform2D, highlight, isNone, listStyle, measureText, parseColor, render, renderText, setupView, uploadColor, uploadColors };
|