modern-text 0.2.29 → 0.2.30
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 +51 -131
- package/dist/index.d.cts +3 -28
- package/dist/index.d.mts +3 -28
- package/dist/index.d.ts +3 -28
- package/dist/index.js +2 -2
- package/dist/index.mjs +52 -128
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -53,7 +53,7 @@ function parseCssLinearGradient(css, x, y, width, height) {
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
function drawPath(options) {
|
|
56
|
-
const { ctx, path, fontSize,
|
|
56
|
+
const { ctx, path, fontSize, clipRect } = options;
|
|
57
57
|
ctx.save();
|
|
58
58
|
ctx.beginPath();
|
|
59
59
|
const pathStyle = path.style;
|
|
@@ -72,83 +72,10 @@ function drawPath(options) {
|
|
|
72
72
|
ctx.clip();
|
|
73
73
|
ctx.beginPath();
|
|
74
74
|
}
|
|
75
|
-
|
|
76
|
-
for (let offsetX = -boldness; offsetX <= boldness; offsetX += boldness / 2) {
|
|
77
|
-
for (let offsetY = -boldness; offsetY <= boldness; offsetY += boldness / 2) {
|
|
78
|
-
ctx.save();
|
|
79
|
-
ctx.translate(Math.round(offsetX), Math.round(offsetY));
|
|
80
|
-
path.drawTo(ctx, style);
|
|
81
|
-
ctx.restore();
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
} else {
|
|
85
|
-
path.drawTo(ctx, style);
|
|
86
|
-
}
|
|
75
|
+
path.drawTo(ctx, style);
|
|
87
76
|
ctx.restore();
|
|
88
77
|
}
|
|
89
78
|
|
|
90
|
-
function filterEmpty(val) {
|
|
91
|
-
if (!val)
|
|
92
|
-
return val;
|
|
93
|
-
const res = {};
|
|
94
|
-
for (const key in val) {
|
|
95
|
-
if (val[key] !== "" && val[key] !== void 0) {
|
|
96
|
-
res[key] = val[key];
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
return res;
|
|
100
|
-
}
|
|
101
|
-
function getRotationPoint(point, rotation) {
|
|
102
|
-
const { x, y } = point;
|
|
103
|
-
const sin = Math.sin(rotation);
|
|
104
|
-
const cos = Math.cos(rotation);
|
|
105
|
-
return {
|
|
106
|
-
x: x * cos - y * sin,
|
|
107
|
-
y: x * sin + y * cos
|
|
108
|
-
};
|
|
109
|
-
}
|
|
110
|
-
function getSkewPoint(point, startPoint, skewX, skewY) {
|
|
111
|
-
const dx = point.x - startPoint.x;
|
|
112
|
-
const dy = point.y - startPoint.y;
|
|
113
|
-
return {
|
|
114
|
-
x: startPoint.x + (dx + Math.tan(skewX) * dy),
|
|
115
|
-
y: startPoint.y + (dy + Math.tan(skewY) * dx)
|
|
116
|
-
};
|
|
117
|
-
}
|
|
118
|
-
function getScalePoint(point, startPoint, scaleX, scaleY) {
|
|
119
|
-
const x = scaleX < 0 ? startPoint.x - point.x + startPoint.x : point.x;
|
|
120
|
-
const y = scaleY < 0 ? startPoint.y - point.y + startPoint.y : point.y;
|
|
121
|
-
return {
|
|
122
|
-
x: x * Math.abs(scaleX),
|
|
123
|
-
y: y * Math.abs(scaleY)
|
|
124
|
-
};
|
|
125
|
-
}
|
|
126
|
-
function getPointPosition(point, startPoint, rotation = 0, skewX = 0, skewY = 0, scaleX = 1, scaleY = 1) {
|
|
127
|
-
let points = Array.isArray(point) ? point : [point];
|
|
128
|
-
const _rotation = -rotation / 180 * Math.PI;
|
|
129
|
-
const { x, y } = startPoint;
|
|
130
|
-
if (scaleX !== 1 || scaleY !== 1) {
|
|
131
|
-
points = points.map((point2) => {
|
|
132
|
-
return getScalePoint(point2, startPoint, scaleX, scaleY);
|
|
133
|
-
});
|
|
134
|
-
}
|
|
135
|
-
if (skewX || skewY) {
|
|
136
|
-
points = points.map((point2) => {
|
|
137
|
-
return getSkewPoint(point2, startPoint, skewX, skewY);
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
|
-
points = points.map((d) => {
|
|
141
|
-
const h = d.x - x;
|
|
142
|
-
const f = -(d.y - y);
|
|
143
|
-
d = getRotationPoint({ x: h, y: f }, _rotation);
|
|
144
|
-
return {
|
|
145
|
-
x: x + d.x,
|
|
146
|
-
y: y - d.y
|
|
147
|
-
};
|
|
148
|
-
});
|
|
149
|
-
return points[0];
|
|
150
|
-
}
|
|
151
|
-
|
|
152
79
|
var __defProp$4 = Object.defineProperty;
|
|
153
80
|
var __defNormalProp$4 = (obj, key, value) => key in obj ? __defProp$4(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
154
81
|
var __publicField$4 = (obj, key, value) => {
|
|
@@ -168,6 +95,19 @@ const set2 = /* @__PURE__ */ new Set([
|
|
|
168
95
|
"\u2019",
|
|
169
96
|
"\u02DC"
|
|
170
97
|
]);
|
|
98
|
+
const fontWeightMap = {
|
|
99
|
+
100: -0.2,
|
|
100
|
+
200: -0.1,
|
|
101
|
+
300: 0,
|
|
102
|
+
400: 0,
|
|
103
|
+
normal: 0,
|
|
104
|
+
500: 0.1,
|
|
105
|
+
600: 0.2,
|
|
106
|
+
700: 0.3,
|
|
107
|
+
bold: 0.3,
|
|
108
|
+
800: 0.4,
|
|
109
|
+
900: 0.5
|
|
110
|
+
};
|
|
171
111
|
class Character {
|
|
172
112
|
constructor(content, index, parent) {
|
|
173
113
|
this.content = content;
|
|
@@ -257,7 +197,7 @@ class Character {
|
|
|
257
197
|
let x = left;
|
|
258
198
|
let y = top + baseline;
|
|
259
199
|
let glyphIndex;
|
|
260
|
-
|
|
200
|
+
const path = new modernPath2d.Path2D();
|
|
261
201
|
if (isVertical) {
|
|
262
202
|
x += (glyphHeight - glyphWidth) / 2;
|
|
263
203
|
if (Math.abs(textWidth - textHeight) > 0.1) {
|
|
@@ -266,27 +206,31 @@ class Character {
|
|
|
266
206
|
glyphIndex = void 0;
|
|
267
207
|
}
|
|
268
208
|
if (isVertical && !set1.has(content) && (content.codePointAt(0) <= 256 || set2.has(content))) {
|
|
269
|
-
|
|
209
|
+
path.addCommands(
|
|
210
|
+
font.getPathCommands(content, x, top + baseline - (glyphHeight - glyphWidth) / 2, fontSize) ?? []
|
|
211
|
+
);
|
|
270
212
|
const point = {
|
|
271
213
|
y: top - (glyphHeight - glyphWidth) / 2 + glyphHeight / 2,
|
|
272
214
|
x: x + glyphWidth / 2
|
|
273
215
|
};
|
|
274
216
|
if (fontStyle === "italic") {
|
|
275
|
-
|
|
276
|
-
|
|
217
|
+
this._italic(
|
|
218
|
+
path,
|
|
277
219
|
isVertical ? {
|
|
278
220
|
x: point.x,
|
|
279
221
|
y: top - (glyphHeight - glyphWidth) / 2 + baseline
|
|
280
222
|
} : void 0
|
|
281
223
|
);
|
|
282
224
|
}
|
|
283
|
-
|
|
225
|
+
path.rotate(90, point);
|
|
284
226
|
} else {
|
|
285
227
|
if (glyphIndex !== void 0) {
|
|
286
|
-
|
|
228
|
+
path.addCommands(
|
|
229
|
+
font.glyphs.get(glyphIndex).getPathCommands(x, y, fontSize)
|
|
230
|
+
);
|
|
287
231
|
if (fontStyle === "italic") {
|
|
288
|
-
|
|
289
|
-
|
|
232
|
+
this._italic(
|
|
233
|
+
path,
|
|
290
234
|
isVertical ? {
|
|
291
235
|
x: x + glyphWidth / 2,
|
|
292
236
|
y: top + typoAscender / (usWinAscent + Math.abs(usWinDescent)) * glyphHeight
|
|
@@ -294,17 +238,19 @@ class Character {
|
|
|
294
238
|
);
|
|
295
239
|
}
|
|
296
240
|
} else {
|
|
297
|
-
|
|
241
|
+
path.addCommands(
|
|
242
|
+
font.getPathCommands(content, x, y, fontSize) ?? []
|
|
243
|
+
);
|
|
298
244
|
if (fontStyle === "italic") {
|
|
299
|
-
|
|
300
|
-
|
|
245
|
+
this._italic(
|
|
246
|
+
path,
|
|
301
247
|
isVertical ? { x: x + glyphHeight / 2, y } : void 0
|
|
302
248
|
);
|
|
303
249
|
}
|
|
304
250
|
}
|
|
305
251
|
}
|
|
306
|
-
|
|
307
|
-
|
|
252
|
+
path.addCommands(this._decoration());
|
|
253
|
+
path.bold(fontWeightMap[computedStyle.fontWeight ?? 400] * fontSize * 0.05);
|
|
308
254
|
path.style = {
|
|
309
255
|
fill: computedStyle.color,
|
|
310
256
|
stroke: computedStyle.textStrokeWidth ? computedStyle.textStrokeColor : "none",
|
|
@@ -362,43 +308,10 @@ class Character {
|
|
|
362
308
|
];
|
|
363
309
|
}
|
|
364
310
|
}
|
|
365
|
-
_italic(
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
y: top + baseline,
|
|
370
|
-
x: left + glyphWidth / 2
|
|
371
|
-
};
|
|
372
|
-
return this._transform(commands, (x, y) => {
|
|
373
|
-
const p = getSkewPoint({ x, y }, _startPoint, -0.24, 0);
|
|
374
|
-
return [p.x, p.y];
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
_rotation90(commands, point) {
|
|
378
|
-
return this._transform(commands, (x, y) => {
|
|
379
|
-
const p = getPointPosition({ x, y }, point, 90);
|
|
380
|
-
return [p.x, p.y];
|
|
381
|
-
});
|
|
382
|
-
}
|
|
383
|
-
_transform(commands, cb) {
|
|
384
|
-
return commands.map((rawCmd) => {
|
|
385
|
-
const cmd = { ...rawCmd };
|
|
386
|
-
switch (cmd.type) {
|
|
387
|
-
case "L":
|
|
388
|
-
case "M":
|
|
389
|
-
[cmd.x, cmd.y] = cb(cmd.x, cmd.y);
|
|
390
|
-
break;
|
|
391
|
-
case "Q":
|
|
392
|
-
[cmd.x1, cmd.y1] = cb(cmd.x1, cmd.y1);
|
|
393
|
-
[cmd.x, cmd.y] = cb(cmd.x, cmd.y);
|
|
394
|
-
break;
|
|
395
|
-
case "C":
|
|
396
|
-
[cmd.x1, cmd.y1] = cb(cmd.x1, cmd.y1);
|
|
397
|
-
[cmd.x2, cmd.y2] = cb(cmd.x2, cmd.y2);
|
|
398
|
-
[cmd.x, cmd.y] = cb(cmd.x, cmd.y);
|
|
399
|
-
break;
|
|
400
|
-
}
|
|
401
|
-
return cmd;
|
|
311
|
+
_italic(path, startPoint) {
|
|
312
|
+
path.skew(-0.24, 0, startPoint || {
|
|
313
|
+
y: this.boundingBox.top + this.baseline,
|
|
314
|
+
x: this.boundingBox.left + this.glyphWidth / 2
|
|
402
315
|
});
|
|
403
316
|
}
|
|
404
317
|
getGlyphMinMax(min, max, withStyle) {
|
|
@@ -424,12 +337,23 @@ class Character {
|
|
|
424
337
|
path: this.path,
|
|
425
338
|
fontSize: this.computedStyle.fontSize,
|
|
426
339
|
color: this.computedStyle.color,
|
|
427
|
-
boldness: this.computedStyle.fontWeight === "bold" ? 2 : 0,
|
|
428
340
|
...config
|
|
429
341
|
});
|
|
430
342
|
}
|
|
431
343
|
}
|
|
432
344
|
|
|
345
|
+
function filterEmpty(val) {
|
|
346
|
+
if (!val)
|
|
347
|
+
return val;
|
|
348
|
+
const res = {};
|
|
349
|
+
for (const key in val) {
|
|
350
|
+
if (val[key] !== "" && val[key] !== void 0) {
|
|
351
|
+
res[key] = val[key];
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
return res;
|
|
355
|
+
}
|
|
356
|
+
|
|
433
357
|
var __defProp$3 = Object.defineProperty;
|
|
434
358
|
var __defNormalProp$3 = (obj, key, value) => key in obj ? __defProp$3(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
435
359
|
var __publicField$3 = (obj, key, value) => {
|
|
@@ -677,7 +601,7 @@ const _Highlighter = class _Highlighter extends Feature {
|
|
|
677
601
|
for (let i = 0; i < total; i++) {
|
|
678
602
|
const _transform = transform.clone().translate(i * unitWidth, 0);
|
|
679
603
|
paths.forEach((original) => {
|
|
680
|
-
const path = original.clone().
|
|
604
|
+
const path = original.clone().matrix(_transform);
|
|
681
605
|
if (path.style.strokeWidth) {
|
|
682
606
|
path.style.strokeWidth *= styleScale * strokeWidth;
|
|
683
607
|
}
|
|
@@ -1188,10 +1112,6 @@ exports.defaultHighlightRefer = defaultHighlightRefer;
|
|
|
1188
1112
|
exports.defaultTextStyles = defaultTextStyles;
|
|
1189
1113
|
exports.drawPath = drawPath;
|
|
1190
1114
|
exports.filterEmpty = filterEmpty;
|
|
1191
|
-
exports.getPointPosition = getPointPosition;
|
|
1192
|
-
exports.getRotationPoint = getRotationPoint;
|
|
1193
|
-
exports.getScalePoint = getScalePoint;
|
|
1194
|
-
exports.getSkewPoint = getSkewPoint;
|
|
1195
1115
|
exports.parseColor = parseColor;
|
|
1196
1116
|
exports.uploadColor = uploadColor;
|
|
1197
1117
|
Object.keys(modernFont).forEach(function (k) {
|
package/dist/index.d.cts
CHANGED
|
@@ -4,7 +4,7 @@ export * from 'modern-font';
|
|
|
4
4
|
|
|
5
5
|
type WritingMode = 'horizontal-tb' | 'vertical-lr' | 'vertical-rl';
|
|
6
6
|
type TextOrientation = 'mixed' | 'upright' | 'sideways-right' | 'sideways';
|
|
7
|
-
type FontWeight = 'normal' | 'bold' |
|
|
7
|
+
type FontWeight = 'normal' | 'bold' | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
|
|
8
8
|
type FontStyle = 'normal' | 'italic' | 'oblique' | `oblique ${string}`;
|
|
9
9
|
type FontKerning = 'auto' | 'none' | 'normal';
|
|
10
10
|
type TextWrap = 'wrap' | 'nowrap';
|
|
@@ -79,7 +79,6 @@ interface DrawShapePathsOptions extends Partial<TextEffect> {
|
|
|
79
79
|
ctx: CanvasRenderingContext2D;
|
|
80
80
|
path: Path2D;
|
|
81
81
|
fontSize: number;
|
|
82
|
-
boldness?: number;
|
|
83
82
|
clipRect?: BoundingBox;
|
|
84
83
|
}
|
|
85
84
|
declare function drawPath(options: DrawShapePathsOptions): void;
|
|
@@ -125,9 +124,7 @@ declare class Character {
|
|
|
125
124
|
updatePath(): this;
|
|
126
125
|
update(): this;
|
|
127
126
|
protected _decoration(): GlyphPathCommand[];
|
|
128
|
-
protected _italic(
|
|
129
|
-
protected _rotation90(commands: GlyphPathCommand[], point: VectorLike): GlyphPathCommand[];
|
|
130
|
-
protected _transform(commands: GlyphPathCommand[], cb: (x: number, y: number) => number[]): GlyphPathCommand[];
|
|
127
|
+
protected _italic(path: Path2D, startPoint?: VectorLike): void;
|
|
131
128
|
getGlyphMinMax(min?: Vector2, max?: Vector2, withStyle?: boolean): {
|
|
132
129
|
min: Vector2;
|
|
133
130
|
max: Vector2;
|
|
@@ -334,27 +331,5 @@ declare class Renderer2D extends Feature {
|
|
|
334
331
|
}
|
|
335
332
|
|
|
336
333
|
declare function filterEmpty(val: Record<string, any> | undefined): Record<string, any> | undefined;
|
|
337
|
-
declare function getRotationPoint(point: any, rotation: number): {
|
|
338
|
-
x: number;
|
|
339
|
-
y: number;
|
|
340
|
-
};
|
|
341
|
-
declare function getSkewPoint(point: any, startPoint: any, skewX: number, skewY: number): {
|
|
342
|
-
x: number;
|
|
343
|
-
y: number;
|
|
344
|
-
};
|
|
345
|
-
declare function getScalePoint(point: any, startPoint: any, scaleX: number, scaleY: number): {
|
|
346
|
-
x: number;
|
|
347
|
-
y: number;
|
|
348
|
-
};
|
|
349
|
-
declare function getPointPosition(point: {
|
|
350
|
-
x: number;
|
|
351
|
-
y: number;
|
|
352
|
-
}, startPoint: {
|
|
353
|
-
x: number;
|
|
354
|
-
y: number;
|
|
355
|
-
}, rotation?: number, skewX?: number, skewY?: number, scaleX?: number, scaleY?: number): {
|
|
356
|
-
x: number;
|
|
357
|
-
y: number;
|
|
358
|
-
};
|
|
359
334
|
|
|
360
|
-
export { Character, Deformer, type DrawShapePathsOptions, type EffectOptions, Effector, type FontKerning, type FontStyle, type FontWeight, Fragment, type FragmentContent, type FragmentHighlight, Highlighter, type LinearGradient, type MeasuredCharacter, type MeasuredFragment, type MeasuredParagraph, type MeasuredResult, Measurer, Paragraph, type ParagraphContent, Parser, Reflector, type Render2dOptions, Renderer2D, Text, type TextAlign, type TextContent, type TextDecoration, type TextDeformation, type TextDrawStyle, type TextEffect, type TextLayoutStyle, type TextOptions, type TextOrientation, type TextRenderOptions, type TextStyle, type TextTransform, type TextWrap, type VerticalAlign, type WritingMode, defaultHighlightRefer, defaultTextStyles, drawPath, filterEmpty,
|
|
335
|
+
export { Character, Deformer, type DrawShapePathsOptions, type EffectOptions, Effector, type FontKerning, type FontStyle, type FontWeight, Fragment, type FragmentContent, type FragmentHighlight, Highlighter, type LinearGradient, type MeasuredCharacter, type MeasuredFragment, type MeasuredParagraph, type MeasuredResult, Measurer, Paragraph, type ParagraphContent, Parser, Reflector, type Render2dOptions, Renderer2D, Text, type TextAlign, type TextContent, type TextDecoration, type TextDeformation, type TextDrawStyle, type TextEffect, type TextLayoutStyle, type TextOptions, type TextOrientation, type TextRenderOptions, type TextStyle, type TextTransform, type TextWrap, type VerticalAlign, type WritingMode, defaultHighlightRefer, defaultTextStyles, drawPath, filterEmpty, parseColor, uploadColor };
|
package/dist/index.d.mts
CHANGED
|
@@ -4,7 +4,7 @@ export * from 'modern-font';
|
|
|
4
4
|
|
|
5
5
|
type WritingMode = 'horizontal-tb' | 'vertical-lr' | 'vertical-rl';
|
|
6
6
|
type TextOrientation = 'mixed' | 'upright' | 'sideways-right' | 'sideways';
|
|
7
|
-
type FontWeight = 'normal' | 'bold' |
|
|
7
|
+
type FontWeight = 'normal' | 'bold' | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
|
|
8
8
|
type FontStyle = 'normal' | 'italic' | 'oblique' | `oblique ${string}`;
|
|
9
9
|
type FontKerning = 'auto' | 'none' | 'normal';
|
|
10
10
|
type TextWrap = 'wrap' | 'nowrap';
|
|
@@ -79,7 +79,6 @@ interface DrawShapePathsOptions extends Partial<TextEffect> {
|
|
|
79
79
|
ctx: CanvasRenderingContext2D;
|
|
80
80
|
path: Path2D;
|
|
81
81
|
fontSize: number;
|
|
82
|
-
boldness?: number;
|
|
83
82
|
clipRect?: BoundingBox;
|
|
84
83
|
}
|
|
85
84
|
declare function drawPath(options: DrawShapePathsOptions): void;
|
|
@@ -125,9 +124,7 @@ declare class Character {
|
|
|
125
124
|
updatePath(): this;
|
|
126
125
|
update(): this;
|
|
127
126
|
protected _decoration(): GlyphPathCommand[];
|
|
128
|
-
protected _italic(
|
|
129
|
-
protected _rotation90(commands: GlyphPathCommand[], point: VectorLike): GlyphPathCommand[];
|
|
130
|
-
protected _transform(commands: GlyphPathCommand[], cb: (x: number, y: number) => number[]): GlyphPathCommand[];
|
|
127
|
+
protected _italic(path: Path2D, startPoint?: VectorLike): void;
|
|
131
128
|
getGlyphMinMax(min?: Vector2, max?: Vector2, withStyle?: boolean): {
|
|
132
129
|
min: Vector2;
|
|
133
130
|
max: Vector2;
|
|
@@ -334,27 +331,5 @@ declare class Renderer2D extends Feature {
|
|
|
334
331
|
}
|
|
335
332
|
|
|
336
333
|
declare function filterEmpty(val: Record<string, any> | undefined): Record<string, any> | undefined;
|
|
337
|
-
declare function getRotationPoint(point: any, rotation: number): {
|
|
338
|
-
x: number;
|
|
339
|
-
y: number;
|
|
340
|
-
};
|
|
341
|
-
declare function getSkewPoint(point: any, startPoint: any, skewX: number, skewY: number): {
|
|
342
|
-
x: number;
|
|
343
|
-
y: number;
|
|
344
|
-
};
|
|
345
|
-
declare function getScalePoint(point: any, startPoint: any, scaleX: number, scaleY: number): {
|
|
346
|
-
x: number;
|
|
347
|
-
y: number;
|
|
348
|
-
};
|
|
349
|
-
declare function getPointPosition(point: {
|
|
350
|
-
x: number;
|
|
351
|
-
y: number;
|
|
352
|
-
}, startPoint: {
|
|
353
|
-
x: number;
|
|
354
|
-
y: number;
|
|
355
|
-
}, rotation?: number, skewX?: number, skewY?: number, scaleX?: number, scaleY?: number): {
|
|
356
|
-
x: number;
|
|
357
|
-
y: number;
|
|
358
|
-
};
|
|
359
334
|
|
|
360
|
-
export { Character, Deformer, type DrawShapePathsOptions, type EffectOptions, Effector, type FontKerning, type FontStyle, type FontWeight, Fragment, type FragmentContent, type FragmentHighlight, Highlighter, type LinearGradient, type MeasuredCharacter, type MeasuredFragment, type MeasuredParagraph, type MeasuredResult, Measurer, Paragraph, type ParagraphContent, Parser, Reflector, type Render2dOptions, Renderer2D, Text, type TextAlign, type TextContent, type TextDecoration, type TextDeformation, type TextDrawStyle, type TextEffect, type TextLayoutStyle, type TextOptions, type TextOrientation, type TextRenderOptions, type TextStyle, type TextTransform, type TextWrap, type VerticalAlign, type WritingMode, defaultHighlightRefer, defaultTextStyles, drawPath, filterEmpty,
|
|
335
|
+
export { Character, Deformer, type DrawShapePathsOptions, type EffectOptions, Effector, type FontKerning, type FontStyle, type FontWeight, Fragment, type FragmentContent, type FragmentHighlight, Highlighter, type LinearGradient, type MeasuredCharacter, type MeasuredFragment, type MeasuredParagraph, type MeasuredResult, Measurer, Paragraph, type ParagraphContent, Parser, Reflector, type Render2dOptions, Renderer2D, Text, type TextAlign, type TextContent, type TextDecoration, type TextDeformation, type TextDrawStyle, type TextEffect, type TextLayoutStyle, type TextOptions, type TextOrientation, type TextRenderOptions, type TextStyle, type TextTransform, type TextWrap, type VerticalAlign, type WritingMode, defaultHighlightRefer, defaultTextStyles, drawPath, filterEmpty, parseColor, uploadColor };
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ export * from 'modern-font';
|
|
|
4
4
|
|
|
5
5
|
type WritingMode = 'horizontal-tb' | 'vertical-lr' | 'vertical-rl';
|
|
6
6
|
type TextOrientation = 'mixed' | 'upright' | 'sideways-right' | 'sideways';
|
|
7
|
-
type FontWeight = 'normal' | 'bold' |
|
|
7
|
+
type FontWeight = 'normal' | 'bold' | 100 | 200 | 300 | 400 | 500 | 600 | 700 | 800 | 900;
|
|
8
8
|
type FontStyle = 'normal' | 'italic' | 'oblique' | `oblique ${string}`;
|
|
9
9
|
type FontKerning = 'auto' | 'none' | 'normal';
|
|
10
10
|
type TextWrap = 'wrap' | 'nowrap';
|
|
@@ -79,7 +79,6 @@ interface DrawShapePathsOptions extends Partial<TextEffect> {
|
|
|
79
79
|
ctx: CanvasRenderingContext2D;
|
|
80
80
|
path: Path2D;
|
|
81
81
|
fontSize: number;
|
|
82
|
-
boldness?: number;
|
|
83
82
|
clipRect?: BoundingBox;
|
|
84
83
|
}
|
|
85
84
|
declare function drawPath(options: DrawShapePathsOptions): void;
|
|
@@ -125,9 +124,7 @@ declare class Character {
|
|
|
125
124
|
updatePath(): this;
|
|
126
125
|
update(): this;
|
|
127
126
|
protected _decoration(): GlyphPathCommand[];
|
|
128
|
-
protected _italic(
|
|
129
|
-
protected _rotation90(commands: GlyphPathCommand[], point: VectorLike): GlyphPathCommand[];
|
|
130
|
-
protected _transform(commands: GlyphPathCommand[], cb: (x: number, y: number) => number[]): GlyphPathCommand[];
|
|
127
|
+
protected _italic(path: Path2D, startPoint?: VectorLike): void;
|
|
131
128
|
getGlyphMinMax(min?: Vector2, max?: Vector2, withStyle?: boolean): {
|
|
132
129
|
min: Vector2;
|
|
133
130
|
max: Vector2;
|
|
@@ -334,27 +331,5 @@ declare class Renderer2D extends Feature {
|
|
|
334
331
|
}
|
|
335
332
|
|
|
336
333
|
declare function filterEmpty(val: Record<string, any> | undefined): Record<string, any> | undefined;
|
|
337
|
-
declare function getRotationPoint(point: any, rotation: number): {
|
|
338
|
-
x: number;
|
|
339
|
-
y: number;
|
|
340
|
-
};
|
|
341
|
-
declare function getSkewPoint(point: any, startPoint: any, skewX: number, skewY: number): {
|
|
342
|
-
x: number;
|
|
343
|
-
y: number;
|
|
344
|
-
};
|
|
345
|
-
declare function getScalePoint(point: any, startPoint: any, scaleX: number, scaleY: number): {
|
|
346
|
-
x: number;
|
|
347
|
-
y: number;
|
|
348
|
-
};
|
|
349
|
-
declare function getPointPosition(point: {
|
|
350
|
-
x: number;
|
|
351
|
-
y: number;
|
|
352
|
-
}, startPoint: {
|
|
353
|
-
x: number;
|
|
354
|
-
y: number;
|
|
355
|
-
}, rotation?: number, skewX?: number, skewY?: number, scaleX?: number, scaleY?: number): {
|
|
356
|
-
x: number;
|
|
357
|
-
y: number;
|
|
358
|
-
};
|
|
359
334
|
|
|
360
|
-
export { Character, Deformer, type DrawShapePathsOptions, type EffectOptions, Effector, type FontKerning, type FontStyle, type FontWeight, Fragment, type FragmentContent, type FragmentHighlight, Highlighter, type LinearGradient, type MeasuredCharacter, type MeasuredFragment, type MeasuredParagraph, type MeasuredResult, Measurer, Paragraph, type ParagraphContent, Parser, Reflector, type Render2dOptions, Renderer2D, Text, type TextAlign, type TextContent, type TextDecoration, type TextDeformation, type TextDrawStyle, type TextEffect, type TextLayoutStyle, type TextOptions, type TextOrientation, type TextRenderOptions, type TextStyle, type TextTransform, type TextWrap, type VerticalAlign, type WritingMode, defaultHighlightRefer, defaultTextStyles, drawPath, filterEmpty,
|
|
335
|
+
export { Character, Deformer, type DrawShapePathsOptions, type EffectOptions, Effector, type FontKerning, type FontStyle, type FontWeight, Fragment, type FragmentContent, type FragmentHighlight, Highlighter, type LinearGradient, type MeasuredCharacter, type MeasuredFragment, type MeasuredParagraph, type MeasuredResult, Measurer, Paragraph, type ParagraphContent, Parser, Reflector, type Render2dOptions, Renderer2D, Text, type TextAlign, type TextContent, type TextDecoration, type TextDeformation, type TextDrawStyle, type TextEffect, type TextLayoutStyle, type TextOptions, type TextOrientation, type TextRenderOptions, type TextStyle, type TextTransform, type TextWrap, type VerticalAlign, type WritingMode, defaultHighlightRefer, defaultTextStyles, drawPath, filterEmpty, parseColor, uploadColor };
|