modern-text 0.2.30 → 0.2.31
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/dist/index.cjs +421 -370
- package/dist/index.d.cts +140 -155
- package/dist/index.d.mts +140 -155
- package/dist/index.d.ts +140 -155
- package/dist/index.js +4 -2
- package/dist/index.mjs +412 -366
- package/package.json +2 -2
package/dist/index.d.cts
CHANGED
|
@@ -1,66 +1,74 @@
|
|
|
1
1
|
import { BoundingBox, Path2D, Vector2, VectorLike, Matrix3 } from 'modern-path2d';
|
|
2
|
+
export * from 'modern-path2d';
|
|
2
3
|
import { Sfnt, GlyphPathCommand } from 'modern-font';
|
|
3
4
|
export * from 'modern-font';
|
|
4
5
|
|
|
6
|
+
type Sizeable = `${number}%` | `${number}rem` | number;
|
|
5
7
|
type WritingMode = 'horizontal-tb' | 'vertical-lr' | 'vertical-rl';
|
|
6
8
|
type TextOrientation = 'mixed' | 'upright' | 'sideways-right' | 'sideways';
|
|
7
9
|
type FontWeight = 'normal' | 'bold' | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
|
|
8
10
|
type FontStyle = 'normal' | 'italic' | 'oblique' | `oblique ${string}`;
|
|
9
|
-
type FontKerning = '
|
|
11
|
+
type FontKerning = 'none' | 'auto' | 'normal';
|
|
10
12
|
type TextWrap = 'wrap' | 'nowrap';
|
|
11
13
|
type TextAlign = 'center' | 'end' | 'left' | 'right' | 'start';
|
|
12
14
|
type VerticalAlign = 'baseline' | 'top' | 'middle' | 'bottom' | 'sub' | 'super' | 'text-top' | 'text-bottom';
|
|
13
|
-
type TextTransform = '
|
|
15
|
+
type TextTransform = 'none' | 'uppercase' | 'lowercase';
|
|
14
16
|
type TextDecoration = 'none' | 'underline' | 'line-through';
|
|
17
|
+
type ListStyleType = 'none' | 'disc';
|
|
18
|
+
type ListStyleImage = 'none' | string;
|
|
19
|
+
type ListStyleSize = 'cover' | Sizeable;
|
|
20
|
+
type ListStylePosition = 'inside' | 'outside';
|
|
21
|
+
type HighlightImage = 'none' | string;
|
|
22
|
+
type HighlightSize = 'cover' | Sizeable;
|
|
23
|
+
type HighlightStrokeWidth = Sizeable;
|
|
24
|
+
type HighlightOverflow = 'none' | 'visible' | 'hidden';
|
|
15
25
|
interface TextLayoutStyle {
|
|
16
26
|
writingMode: WritingMode;
|
|
17
|
-
|
|
27
|
+
verticalAlign: VerticalAlign;
|
|
28
|
+
lineHeight: number;
|
|
29
|
+
letterSpacing: number;
|
|
18
30
|
fontSize: number;
|
|
19
31
|
fontWeight: FontWeight;
|
|
20
32
|
fontFamily: string;
|
|
21
33
|
fontStyle: FontStyle;
|
|
22
|
-
fontKerning
|
|
34
|
+
fontKerning?: FontKerning;
|
|
23
35
|
textWrap: TextWrap;
|
|
24
36
|
textAlign: TextAlign;
|
|
25
|
-
verticalAlign: VerticalAlign;
|
|
26
37
|
textTransform: TextTransform;
|
|
27
|
-
|
|
28
|
-
letterSpacing: number;
|
|
38
|
+
textOrientation: TextOrientation;
|
|
29
39
|
}
|
|
30
40
|
interface TextDrawStyle {
|
|
31
41
|
color: string | CanvasGradient | CanvasPattern;
|
|
32
42
|
backgroundColor: string | CanvasGradient | CanvasPattern;
|
|
43
|
+
textDecoration: TextDecoration;
|
|
33
44
|
textStrokeWidth: number;
|
|
34
45
|
textStrokeColor: string | CanvasGradient | CanvasPattern;
|
|
35
|
-
textDecoration: TextDecoration;
|
|
36
46
|
shadowColor: string;
|
|
37
47
|
shadowOffsetX: number;
|
|
38
48
|
shadowOffsetY: number;
|
|
39
49
|
shadowBlur: number;
|
|
40
50
|
}
|
|
41
|
-
interface
|
|
51
|
+
interface TextListStyle {
|
|
52
|
+
listStyleType: ListStyleType;
|
|
53
|
+
listStyleImage: ListStyleImage;
|
|
54
|
+
listStyleSize: ListStyleSize;
|
|
55
|
+
listStylePosition: ListStylePosition;
|
|
56
|
+
}
|
|
57
|
+
interface TextHighlightStyle {
|
|
58
|
+
highlightImage: HighlightImage;
|
|
59
|
+
highlightSize: HighlightSize;
|
|
60
|
+
highlightStrokeWidth: HighlightStrokeWidth;
|
|
61
|
+
highlightOverflow: HighlightOverflow;
|
|
62
|
+
}
|
|
63
|
+
interface TextStyle extends TextLayoutStyle, TextDrawStyle, TextListStyle, TextHighlightStyle {
|
|
42
64
|
}
|
|
43
65
|
interface FragmentContent extends Partial<TextStyle> {
|
|
44
66
|
content: string;
|
|
45
|
-
highlight?: FragmentHighlight;
|
|
46
67
|
}
|
|
47
68
|
interface ParagraphContent extends Partial<TextStyle> {
|
|
48
69
|
fragments: FragmentContent[];
|
|
49
70
|
}
|
|
50
71
|
type TextContent = string | FragmentContent | ParagraphContent | (string | FragmentContent | ParagraphContent | (string | FragmentContent)[])[];
|
|
51
|
-
type TextEffect = Partial<TextDrawStyle & {
|
|
52
|
-
offsetX: number;
|
|
53
|
-
offsetY: number;
|
|
54
|
-
skewX: number;
|
|
55
|
-
skewY: number;
|
|
56
|
-
}>;
|
|
57
|
-
type TextDeformation = () => void;
|
|
58
|
-
interface FragmentHighlight {
|
|
59
|
-
url: string;
|
|
60
|
-
strokeWidth?: number;
|
|
61
|
-
repeatXByFontsize?: number;
|
|
62
|
-
overflowXHidden?: boolean;
|
|
63
|
-
}
|
|
64
72
|
|
|
65
73
|
declare function parseColor(ctx: CanvasRenderingContext2D, source: string | CanvasGradient | CanvasPattern, box: BoundingBox): string | CanvasGradient | CanvasPattern;
|
|
66
74
|
declare function uploadColor(style: Partial<TextDrawStyle>, box: BoundingBox, ctx: CanvasRenderingContext2D): void;
|
|
@@ -75,14 +83,6 @@ interface LinearGradient {
|
|
|
75
83
|
}[];
|
|
76
84
|
}
|
|
77
85
|
|
|
78
|
-
interface DrawShapePathsOptions extends Partial<TextEffect> {
|
|
79
|
-
ctx: CanvasRenderingContext2D;
|
|
80
|
-
path: Path2D;
|
|
81
|
-
fontSize: number;
|
|
82
|
-
clipRect?: BoundingBox;
|
|
83
|
-
}
|
|
84
|
-
declare function drawPath(options: DrawShapePathsOptions): void;
|
|
85
|
-
|
|
86
86
|
declare class Fragment {
|
|
87
87
|
content: string;
|
|
88
88
|
style: Partial<TextStyle>;
|
|
@@ -90,7 +90,6 @@ declare class Fragment {
|
|
|
90
90
|
boundingBox: BoundingBox;
|
|
91
91
|
characters: Character[];
|
|
92
92
|
computedStyle: TextStyle;
|
|
93
|
-
highlight?: FragmentHighlight;
|
|
94
93
|
get computedContent(): string;
|
|
95
94
|
constructor(content: string, style: Partial<TextStyle> | undefined, parent: Paragraph);
|
|
96
95
|
updateComputedStyle(): this;
|
|
@@ -144,117 +143,6 @@ declare class Paragraph {
|
|
|
144
143
|
addFragment(content: string, style?: Partial<TextStyle>): Fragment;
|
|
145
144
|
}
|
|
146
145
|
|
|
147
|
-
interface TextRenderOptions {
|
|
148
|
-
view: HTMLCanvasElement;
|
|
149
|
-
pixelRatio?: number;
|
|
150
|
-
}
|
|
151
|
-
interface TextOptions {
|
|
152
|
-
content?: TextContent;
|
|
153
|
-
style?: Partial<TextStyle>;
|
|
154
|
-
effects?: TextEffect[];
|
|
155
|
-
deformation?: TextDeformation;
|
|
156
|
-
measureDom?: HTMLElement;
|
|
157
|
-
}
|
|
158
|
-
declare const defaultTextStyles: TextStyle;
|
|
159
|
-
declare class Text {
|
|
160
|
-
content: TextContent;
|
|
161
|
-
style: Partial<TextStyle>;
|
|
162
|
-
effects?: TextEffect[];
|
|
163
|
-
deformation?: TextDeformation;
|
|
164
|
-
measureDom?: HTMLElement;
|
|
165
|
-
needsUpdate: boolean;
|
|
166
|
-
computedStyle: {
|
|
167
|
-
writingMode: WritingMode;
|
|
168
|
-
textOrientation: TextOrientation;
|
|
169
|
-
fontSize: number;
|
|
170
|
-
fontWeight: FontWeight;
|
|
171
|
-
fontFamily: string;
|
|
172
|
-
fontStyle: FontStyle;
|
|
173
|
-
fontKerning: FontKerning;
|
|
174
|
-
textWrap: TextWrap;
|
|
175
|
-
textAlign: TextAlign;
|
|
176
|
-
verticalAlign: VerticalAlign;
|
|
177
|
-
textTransform: TextTransform;
|
|
178
|
-
lineHeight: number;
|
|
179
|
-
letterSpacing: number;
|
|
180
|
-
color: string | CanvasGradient | CanvasPattern;
|
|
181
|
-
backgroundColor: string | CanvasGradient | CanvasPattern;
|
|
182
|
-
textStrokeWidth: number;
|
|
183
|
-
textStrokeColor: string | CanvasGradient | CanvasPattern;
|
|
184
|
-
textDecoration: TextDecoration;
|
|
185
|
-
shadowColor: string;
|
|
186
|
-
shadowOffsetX: number;
|
|
187
|
-
shadowOffsetY: number;
|
|
188
|
-
shadowBlur: number;
|
|
189
|
-
};
|
|
190
|
-
paragraphs: Paragraph[];
|
|
191
|
-
boundingBox: BoundingBox;
|
|
192
|
-
renderBoundingBox: BoundingBox;
|
|
193
|
-
parser: Parser;
|
|
194
|
-
measurer: Measurer;
|
|
195
|
-
deformer: Deformer;
|
|
196
|
-
effector: Effector;
|
|
197
|
-
highlighter: Highlighter;
|
|
198
|
-
renderer2D: Renderer2D;
|
|
199
|
-
get fontSize(): number;
|
|
200
|
-
get characters(): Character[];
|
|
201
|
-
constructor(options?: TextOptions);
|
|
202
|
-
measure(dom?: HTMLElement | undefined): MeasuredResult;
|
|
203
|
-
requestUpdate(): this;
|
|
204
|
-
update(): this;
|
|
205
|
-
render(options: TextRenderOptions): this;
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
declare class Feature {
|
|
209
|
-
_text: Text;
|
|
210
|
-
constructor(_text: Text);
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
declare class Deformer extends Feature {
|
|
214
|
-
deform(): void;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
interface EffectOptions {
|
|
218
|
-
ctx: CanvasRenderingContext2D;
|
|
219
|
-
}
|
|
220
|
-
declare class Effector extends Feature {
|
|
221
|
-
getTransform2D(style: TextEffect): Matrix3;
|
|
222
|
-
getBoundingBox(): BoundingBox;
|
|
223
|
-
draw(options: EffectOptions): this;
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
interface HighlightGroup {
|
|
227
|
-
highlight: FragmentHighlight;
|
|
228
|
-
box: BoundingBox;
|
|
229
|
-
baseline: number;
|
|
230
|
-
fontSize: number;
|
|
231
|
-
}
|
|
232
|
-
declare const defaultHighlightRefer = "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI3MiIgaGVpZ2h0PSI3MiIgdmlld0JveD0iMCAwIDcyIDcyIiBmaWxsPSJub25lIj48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTMyLjQwMjkgMjhIMzUuMTU5NFYzMy4xNzcxQzM1Ljk4MjEgMzIuMzExNSAzNi45NzEgMzEuODczNyAzOC4wOTQ4IDMxLjg3MzdDMzkuNjY3NiAzMS44NzM3IDQwLjkxNjYgMzIuNDI5NSA0MS44MzkgMzMuNTQzN0w0MS44NDAzIDMzLjU0NTNDNDIuNjcxNyAzNC41NzA1IDQzLjA5MTUgMzUuODU1OSA0My4wOTE1IDM3LjM4NzdDNDMuMDkxNSAzOC45NzYxIDQyLjY3MjkgNDAuMzAyOCA0MS44MTgzIDQxLjMzMDRMNDEuODE3MSA0MS4zMzE4QzQwLjg3MzEgNDIuNDQ2MSAzOS41ODMyIDQzIDM3Ljk3MjEgNDNDMzYuNzQ3NyA0MyAzNS43NDg4IDQyLjY1OTkgMzQuOTk1OCA0MS45NjkzVjQyLjcyNDdIMzIuNDAyOVYyOFpNMzcuNTQyOCAzNC4wOTI0QzM2Ljg1NDkgMzQuMDkyNCAzNi4zMDE0IDM0LjM1NjEgMzUuODQ4NyAzNC45MDA0TDM1Ljg0NTIgMzQuOTA0NkMzNS4zMzU4IDM1LjQ4NTMgMzUuMDc3NiAzNi4yOTc2IDM1LjA3NzYgMzcuMzQ4NFYzNy41MDU3QzM1LjA3NzYgMzguNDY0IDM1LjI3NzIgMzkuMjQ0MyAzNS42OTQzIDM5LjgyNzlDMzYuMTQ0MSA0MC40NTg3IDM2Ljc3MjYgNDAuNzgxMyAzNy42MjQ1IDQwLjc4MTNDMzguNTg3NCA0MC43ODEzIDM5LjI3MDcgNDAuNDUyNyAzOS43MTUyIDM5LjgxMjdDNDAuMDcyOCAzOS4yNjg0IDQwLjI3MzcgMzguNDY3MyA0MC4yNzM3IDM3LjM4NzdDNDAuMjczNyAzNi4zMTA1IDQwLjA1MzMgMzUuNTMxMyAzOS42NzgzIDM1LjAwNzdDMzkuMjM3MSAzNC40MDcxIDM4LjUzNDIgMzQuMDkyNCAzNy41NDI4IDM0LjA5MjRaIiBmaWxsPSIjMjIyNTI5Ii8+PHBhdGggZD0iTTQ5Ljg2MTQgMzEuODczN0M0OC4xNTM1IDMxLjg3MzcgNDYuODAxNiAzMi40MjM5IDQ1LjgzNDggMzMuNTM5MkM0NC45MzcgMzQuNTQ3MiA0NC40OTY2IDM1Ljg1NiA0NC40OTY2IDM3LjQyN0M0NC40OTY2IDM5LjAzNjggNDQuOTM2NyA0MC4zNjU5IDQ1Ljg1NTkgNDEuMzk0M0M0Ni44MDMxIDQyLjQ3MDYgNDguMTM0OCA0MyA0OS44MjA1IDQzQzUxLjIyNiA0MyA1Mi4zODI2IDQyLjY1NjMgNTMuMjQ3OSA0MS45Njk3QzU0LjEzNTkgNDEuMjYxNCA1NC43MDYxIDQwLjE4ODcgNTQuOTU3MyAzOC43NzkxTDU1IDM4LjUzOTdINTIuMjQ4NEw1Mi4yMjU5IDM4LjcyMDFDNTIuMTM3OSAzOS40MjUxIDUxLjg5MjUgMzkuOTI3OCA1MS41MTA5IDQwLjI1NThDNTEuMTI5NSA0MC41ODM1IDUwLjU4MzEgNDAuNzYxNiA0OS44NDA5IDQwLjc2MTZDNDkuMDAwMSA0MC43NjE2IDQ4LjM5NDkgNDAuNDcxNSA0Ny45OTA3IDM5LjkyMzdMNDcuOTg3NCAzOS45MTk0QzQ3LjUzNTYgMzkuMzQwMSA0Ny4zMTQ0IDM4LjUwNjIgNDcuMzE0NCAzNy40MDc0QzQ3LjMxNDQgMzYuMzMyMiA0Ny41NTQ0IDM1LjUxNzcgNDguMDA1OCAzNC45NTY4TDQ4LjAwNzggMzQuOTU0M0M0OC40NTM3IDM0LjM4MjUgNDkuMDYxOCAzNC4xMTIxIDQ5Ljg2MTQgMzQuMTEyMUM1MC41MjMgMzQuMTEyMSA1MS4wNDUxIDM0LjI2MTUgNTEuNDI3MiAzNC41NDA3QzUxLjc4ODQgMzQuODE5NCA1Mi4wNTMgMzUuMjQ0NyA1Mi4xODgxIDM1Ljg1NzFMNTIuMjIzOSAzNi4wMTk0SDU0Ljk1NDhMNTQuOTE3IDM1Ljc4MzVDNTQuNzA2MyAzNC40NjYgNTQuMTUzNiAzMy40NzAxIDUzLjI2MzQgMzIuODAxOUw1My4yNjAyIDMyLjc5OTVDNTIuMzk1MSAzMi4xNzU1IDUxLjI2MjEgMzEuODczNyA0OS44NjE0IDMxLjg3MzdaIiBmaWxsPSIjMjIyNTI5Ii8+PHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0yNS43NTYxIDI4LjI3NTNIMjIuNzQ0TDE3IDQyLjcyNDdIMjAuMDE0MUwyMS4zNDI5IDM5LjIwNDlIMjcuMTU3MkwyOC40ODYgNDIuNzI0N0gzMS41MDAxTDI1Ljc1NjEgMjguMjc1M1pNMjIuMjEyNSAzNi45MDc2TDI0LjI1OTYgMzEuNDUzOUwyNi4yODg1IDM2LjkwNzZIMjIuMjEyNVoiIGZpbGw9IiMyMjI1MjkiLz48L3N2Zz4=";
|
|
233
|
-
declare class Highlighter extends Feature {
|
|
234
|
-
protected static _refer: string;
|
|
235
|
-
static parsedRefer: Path2D[];
|
|
236
|
-
static get refer(): string;
|
|
237
|
-
static set refer(refer: string);
|
|
238
|
-
paths: {
|
|
239
|
-
clipRect?: BoundingBox;
|
|
240
|
-
path: Path2D;
|
|
241
|
-
}[];
|
|
242
|
-
getReferBoundingBox(): BoundingBox;
|
|
243
|
-
getBoundingBox(): BoundingBox | undefined;
|
|
244
|
-
highlight(perChar?: boolean): void;
|
|
245
|
-
protected _parseSvg(url: string): {
|
|
246
|
-
paths: Path2D[];
|
|
247
|
-
box: BoundingBox;
|
|
248
|
-
};
|
|
249
|
-
protected _parseGroup(group: HighlightGroup): {
|
|
250
|
-
clipRect?: BoundingBox;
|
|
251
|
-
path: Path2D;
|
|
252
|
-
}[];
|
|
253
|
-
draw({ ctx }: {
|
|
254
|
-
ctx: CanvasRenderingContext2D;
|
|
255
|
-
}): this;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
146
|
interface MeasuredParagraph {
|
|
259
147
|
paragraphIndex: number;
|
|
260
148
|
left: number;
|
|
@@ -287,7 +175,9 @@ interface MeasuredResult {
|
|
|
287
175
|
paragraphs: Paragraph[];
|
|
288
176
|
boundingBox: BoundingBox;
|
|
289
177
|
}
|
|
290
|
-
declare class Measurer
|
|
178
|
+
declare class Measurer {
|
|
179
|
+
protected _text: Text;
|
|
180
|
+
constructor(_text: Text);
|
|
291
181
|
protected _styleToDomStyle(style: Partial<TextStyle>): Record<string, any>;
|
|
292
182
|
/**
|
|
293
183
|
* <section style="...">
|
|
@@ -312,24 +202,119 @@ declare class Measurer extends Feature {
|
|
|
312
202
|
measure(dom?: HTMLElement): MeasuredResult;
|
|
313
203
|
}
|
|
314
204
|
|
|
315
|
-
declare class Parser
|
|
205
|
+
declare class Parser {
|
|
206
|
+
protected _text: Text;
|
|
207
|
+
constructor(_text: Text);
|
|
316
208
|
parse(): Paragraph[];
|
|
317
209
|
}
|
|
318
210
|
|
|
319
|
-
|
|
211
|
+
interface TextRenderOptions {
|
|
212
|
+
view: HTMLCanvasElement;
|
|
213
|
+
pixelRatio?: number;
|
|
214
|
+
}
|
|
215
|
+
interface TextOptions {
|
|
216
|
+
content?: TextContent;
|
|
217
|
+
style?: Partial<TextStyle>;
|
|
218
|
+
measureDom?: HTMLElement;
|
|
219
|
+
effects?: TextEffect[];
|
|
220
|
+
highlight?: HighlightOptions;
|
|
221
|
+
}
|
|
222
|
+
declare const defaultTextStyles: TextStyle;
|
|
223
|
+
declare class Text {
|
|
224
|
+
content: TextContent;
|
|
225
|
+
style: Partial<TextStyle>;
|
|
226
|
+
measureDom?: HTMLElement;
|
|
227
|
+
needsUpdate: boolean;
|
|
228
|
+
computedStyle: {
|
|
229
|
+
writingMode: WritingMode;
|
|
230
|
+
verticalAlign: VerticalAlign;
|
|
231
|
+
lineHeight: number;
|
|
232
|
+
letterSpacing: number;
|
|
233
|
+
fontSize: number;
|
|
234
|
+
fontWeight: FontWeight;
|
|
235
|
+
fontFamily: string;
|
|
236
|
+
fontStyle: FontStyle;
|
|
237
|
+
fontKerning?: FontKerning;
|
|
238
|
+
textWrap: TextWrap;
|
|
239
|
+
textAlign: TextAlign;
|
|
240
|
+
textTransform: TextTransform;
|
|
241
|
+
textOrientation: TextOrientation;
|
|
242
|
+
color: string | CanvasGradient | CanvasPattern;
|
|
243
|
+
backgroundColor: string | CanvasGradient | CanvasPattern;
|
|
244
|
+
textDecoration: TextDecoration;
|
|
245
|
+
textStrokeWidth: number;
|
|
246
|
+
textStrokeColor: string | CanvasGradient | CanvasPattern;
|
|
247
|
+
shadowColor: string;
|
|
248
|
+
shadowOffsetX: number;
|
|
249
|
+
shadowOffsetY: number;
|
|
250
|
+
shadowBlur: number;
|
|
251
|
+
listStyleType: ListStyleType;
|
|
252
|
+
listStyleImage: ListStyleImage;
|
|
253
|
+
listStyleSize: ListStyleSize;
|
|
254
|
+
listStylePosition: ListStylePosition;
|
|
255
|
+
highlightImage: HighlightImage;
|
|
256
|
+
highlightSize: HighlightSize;
|
|
257
|
+
highlightStrokeWidth: HighlightStrokeWidth;
|
|
258
|
+
highlightOverflow: HighlightOverflow;
|
|
259
|
+
};
|
|
260
|
+
paragraphs: Paragraph[];
|
|
261
|
+
boundingBox: BoundingBox;
|
|
262
|
+
renderBoundingBox: BoundingBox;
|
|
263
|
+
parser: Parser;
|
|
264
|
+
measurer: Measurer;
|
|
265
|
+
plugins: Map<string, Plugin>;
|
|
266
|
+
get fontSize(): number;
|
|
267
|
+
get characters(): Character[];
|
|
268
|
+
constructor(options?: TextOptions);
|
|
269
|
+
use(plugin: Plugin): this;
|
|
270
|
+
measure(dom?: HTMLElement | undefined): MeasuredResult;
|
|
271
|
+
requestUpdate(): this;
|
|
272
|
+
update(): this;
|
|
273
|
+
render(options: TextRenderOptions): this;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
interface Plugin {
|
|
277
|
+
name: string;
|
|
278
|
+
paths?: Path2D[];
|
|
279
|
+
getBoundingBox?: (text: Text) => BoundingBox | undefined;
|
|
280
|
+
updateOrder?: number;
|
|
281
|
+
update?: (text: Text) => void;
|
|
282
|
+
renderOrder?: number;
|
|
283
|
+
render?: (ctx: CanvasRenderingContext2D, text: Text) => void;
|
|
320
284
|
}
|
|
285
|
+
declare function plugin(options: Plugin): Plugin;
|
|
321
286
|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
287
|
+
type TextEffect = Partial<TextDrawStyle & {
|
|
288
|
+
offsetX: number;
|
|
289
|
+
offsetY: number;
|
|
290
|
+
skewX: number;
|
|
291
|
+
skewY: number;
|
|
292
|
+
}>;
|
|
293
|
+
declare function effect(effects?: TextEffect[]): Plugin;
|
|
294
|
+
declare function getTransform2D(text: Text, style: TextEffect): Matrix3;
|
|
295
|
+
|
|
296
|
+
interface HighlightOptions {
|
|
297
|
+
referImage?: string;
|
|
325
298
|
}
|
|
326
|
-
declare
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
299
|
+
declare function highlight(options?: HighlightOptions): Plugin;
|
|
300
|
+
|
|
301
|
+
declare function listStyle(): Plugin;
|
|
302
|
+
|
|
303
|
+
interface DrawShapePathsOptions extends Partial<TextEffect> {
|
|
304
|
+
ctx: CanvasRenderingContext2D;
|
|
305
|
+
path: Path2D;
|
|
306
|
+
fontSize: number;
|
|
307
|
+
clipRect?: BoundingBox;
|
|
331
308
|
}
|
|
309
|
+
declare function drawPath(options: DrawShapePathsOptions): void;
|
|
310
|
+
|
|
311
|
+
declare function fillBackground(ctx: CanvasRenderingContext2D, text: Text): void;
|
|
312
|
+
|
|
313
|
+
declare function setupView(ctx: CanvasRenderingContext2D, pixelRatio: number, boundingBox: BoundingBox): void;
|
|
314
|
+
|
|
315
|
+
declare function uploadColors(ctx: CanvasRenderingContext2D, text: Text): void;
|
|
332
316
|
|
|
317
|
+
declare function isNone(val: string | undefined): boolean;
|
|
333
318
|
declare function filterEmpty(val: Record<string, any> | undefined): Record<string, any> | undefined;
|
|
334
319
|
|
|
335
|
-
export { Character,
|
|
320
|
+
export { Character, type DrawShapePathsOptions, type FontKerning, type FontStyle, type FontWeight, Fragment, type FragmentContent, type HighlightImage, type HighlightOptions, type HighlightOverflow, type HighlightSize, type HighlightStrokeWidth, type LinearGradient, type ListStyleImage, type ListStylePosition, type ListStyleSize, type ListStyleType, type MeasuredCharacter, type MeasuredFragment, type MeasuredParagraph, type MeasuredResult, Measurer, Paragraph, type ParagraphContent, Parser, type Plugin, type Sizeable, Text, type TextAlign, type TextContent, type TextDecoration, type TextDrawStyle, type TextEffect, type TextHighlightStyle, type TextLayoutStyle, type TextListStyle, type TextOptions, type TextOrientation, type TextRenderOptions, type TextStyle, type TextTransform, type TextWrap, type VerticalAlign, type WritingMode, defaultTextStyles, drawPath, effect, fillBackground, filterEmpty, getTransform2D, highlight, isNone, listStyle, parseColor, plugin, setupView, uploadColor, uploadColors };
|