modern-text 0.2.35 → 0.2.36
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 +35 -20
- package/dist/index.d.cts +7 -8
- package/dist/index.d.mts +7 -8
- package/dist/index.d.ts +7 -8
- package/dist/index.js +3 -3
- package/dist/index.mjs +36 -21
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -298,7 +298,10 @@ class Character {
|
|
|
298
298
|
}
|
|
299
299
|
}
|
|
300
300
|
path.addCommands(this._decoration());
|
|
301
|
-
|
|
301
|
+
const fontWeight = computedStyle.fontWeight ?? 400;
|
|
302
|
+
if (fontWeight in fontWeightMap) {
|
|
303
|
+
path.bold(fontWeightMap[fontWeight] * fontSize * 0.05);
|
|
304
|
+
}
|
|
302
305
|
path.style = {
|
|
303
306
|
fill: computedStyle.color,
|
|
304
307
|
stroke: computedStyle.textStrokeWidth ? computedStyle.textStrokeColor : "none",
|
|
@@ -819,9 +822,7 @@ function getTransform2D(text, style) {
|
|
|
819
822
|
return tempM1.clone();
|
|
820
823
|
}
|
|
821
824
|
|
|
822
|
-
const
|
|
823
|
-
referImage: "data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSI3MiIgaGVpZ2h0PSI3MiIgdmlld0JveD0iMCAwIDcyIDcyIiBmaWxsPSJub25lIj48cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTMyLjQwMjkgMjhIMzUuMTU5NFYzMy4xNzcxQzM1Ljk4MjEgMzIuMzExNSAzNi45NzEgMzEuODczNyAzOC4wOTQ4IDMxLjg3MzdDMzkuNjY3NiAzMS44NzM3IDQwLjkxNjYgMzIuNDI5NSA0MS44MzkgMzMuNTQzN0w0MS44NDAzIDMzLjU0NTNDNDIuNjcxNyAzNC41NzA1IDQzLjA5MTUgMzUuOD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L3N2Zz4=";
|
|
825
826
|
function parseCharsPerRepeat(size, fontSize, total) {
|
|
826
827
|
if (size === "cover") {
|
|
827
828
|
return 0;
|
|
@@ -852,11 +853,30 @@ function parseStrokeWidthScale(strokeWidth, fontSize, total) {
|
|
|
852
853
|
return strokeWidth / total;
|
|
853
854
|
}
|
|
854
855
|
}
|
|
855
|
-
function
|
|
856
|
-
const
|
|
857
|
-
const
|
|
856
|
+
function getTransformMatrix(a, b, c) {
|
|
857
|
+
const scaleX = c.width / b.width;
|
|
858
|
+
const scaleY = c.height / b.height;
|
|
859
|
+
const aCenterInB = new modernPath2d.Vector2(a.x + a.width / 2, a.y + a.height / 2);
|
|
860
|
+
const cCenter = new modernPath2d.Vector2(c.x + c.width / 2, c.y + c.height / 2);
|
|
861
|
+
const translatedCenterInC = cCenter.add(
|
|
862
|
+
aCenterInB.clone().sub(new modernPath2d.Vector2(b.x + b.width / 2, b.y + b.height / 2)).scale(scaleX, scaleY)
|
|
863
|
+
);
|
|
864
|
+
const newX = translatedCenterInC.x - a.width * scaleX / 2;
|
|
865
|
+
const newY = translatedCenterInC.y - a.height * scaleY / 2;
|
|
866
|
+
return new modernPath2d.Matrix3().translate(-a.left, -a.top).scale(scaleX, scaleY).translate(newX, newY);
|
|
867
|
+
}
|
|
868
|
+
function highlight() {
|
|
858
869
|
const paths = [];
|
|
859
870
|
const clipRects = [];
|
|
871
|
+
const svgStringToSvgPaths = /* @__PURE__ */ new Map();
|
|
872
|
+
function getPaths(svg) {
|
|
873
|
+
let paths2 = svgStringToSvgPaths.get(svg);
|
|
874
|
+
if (!paths2) {
|
|
875
|
+
paths2 = modernPath2d.parseSvg(svg);
|
|
876
|
+
svgStringToSvgPaths.set(svg, paths2);
|
|
877
|
+
}
|
|
878
|
+
return paths2;
|
|
879
|
+
}
|
|
860
880
|
return definePlugin({
|
|
861
881
|
name: "highlight",
|
|
862
882
|
paths,
|
|
@@ -890,20 +910,14 @@ function highlight(options = {}) {
|
|
|
890
910
|
const strokeWidthScale = parseStrokeWidthScale(style.highlightStrokeWidth, fontSize, groupBox.width);
|
|
891
911
|
const charsPerRepeat = parseCharsPerRepeat(style.highlightSize, fontSize, groupBox.width);
|
|
892
912
|
const highlightOverflow = isNone(style.highlightOverflow) ? charsPerRepeat ? "hidden" : "visible" : style.highlightOverflow;
|
|
893
|
-
const
|
|
894
|
-
const svgPaths =
|
|
895
|
-
const box = modernPath2d.getPathsBoundingBox(svgPaths,
|
|
896
|
-
const refBox = modernPath2d.getPathsBoundingBox(
|
|
897
|
-
const
|
|
898
|
-
const
|
|
899
|
-
const scaleY = groupBox.height / refBox.height;
|
|
913
|
+
const refPaths = getPaths(isNone(style.highlightReferImage) ? defaultReferImage : style.highlightReferImage);
|
|
914
|
+
const svgPaths = getPaths(style.highlightImage);
|
|
915
|
+
const box = modernPath2d.getPathsBoundingBox(svgPaths, true);
|
|
916
|
+
const refBox = modernPath2d.getPathsBoundingBox(refPaths, false);
|
|
917
|
+
const transform = getTransformMatrix(box, refBox, groupBox);
|
|
918
|
+
const unitWidth = charsPerRepeat ? fontSize * charsPerRepeat : groupBox.width;
|
|
900
919
|
const styleScale = fontSize / box.width * 2;
|
|
901
|
-
const unitWidth = box.width * scaleX;
|
|
902
920
|
const total = Math.ceil(groupBox.width / unitWidth);
|
|
903
|
-
const transform = new modernPath2d.Matrix3().translate(-box.left, -box.top).scale(scaleX, scaleY).translate(groupBox.left, groupBox.top).translate(
|
|
904
|
-
(box.left - refBox.left) * scaleX,
|
|
905
|
-
(box.top - refBox.top) * scaleY
|
|
906
|
-
);
|
|
907
921
|
for (let i = 0; i < total; i++) {
|
|
908
922
|
const _transform = transform.clone().translate(i * unitWidth, 0);
|
|
909
923
|
svgPaths.forEach((original) => {
|
|
@@ -1059,6 +1073,7 @@ const defaultTextStyles = {
|
|
|
1059
1073
|
listStyleSize: "cover",
|
|
1060
1074
|
listStylePosition: "outside",
|
|
1061
1075
|
// highlight
|
|
1076
|
+
highlightReferImage: "none",
|
|
1062
1077
|
highlightImage: "none",
|
|
1063
1078
|
highlightSize: "cover",
|
|
1064
1079
|
highlightStrokeWidth: "100%",
|
|
@@ -1083,7 +1098,7 @@ class Text {
|
|
|
1083
1098
|
this.style = style;
|
|
1084
1099
|
this.measureDom = measureDom;
|
|
1085
1100
|
this.effects = effects;
|
|
1086
|
-
this.use(effect()).use(highlight(
|
|
1101
|
+
this.use(effect()).use(highlight()).use(listStyle());
|
|
1087
1102
|
}
|
|
1088
1103
|
get fontSize() {
|
|
1089
1104
|
return this.computedStyle.fontSize;
|
package/dist/index.d.cts
CHANGED
|
@@ -55,6 +55,7 @@ interface TextListStyle {
|
|
|
55
55
|
listStylePosition: ListStylePosition;
|
|
56
56
|
}
|
|
57
57
|
interface TextHighlightStyle {
|
|
58
|
+
highlightReferImage: HighlightImage;
|
|
58
59
|
highlightImage: HighlightImage;
|
|
59
60
|
highlightSize: HighlightSize;
|
|
60
61
|
highlightStrokeWidth: HighlightStrokeWidth;
|
|
@@ -217,7 +218,6 @@ interface TextOptions {
|
|
|
217
218
|
style?: Partial<TextStyle>;
|
|
218
219
|
measureDom?: HTMLElement;
|
|
219
220
|
effects?: TextEffect[];
|
|
220
|
-
highlight?: HighlightOptions;
|
|
221
221
|
}
|
|
222
222
|
declare const defaultTextStyles: TextStyle;
|
|
223
223
|
declare class Text {
|
|
@@ -253,6 +253,7 @@ declare class Text {
|
|
|
253
253
|
listStyleImage: ListStyleImage;
|
|
254
254
|
listStyleSize: ListStyleSize;
|
|
255
255
|
listStylePosition: ListStylePosition;
|
|
256
|
+
highlightReferImage: HighlightImage;
|
|
256
257
|
highlightImage: HighlightImage;
|
|
257
258
|
highlightSize: HighlightSize;
|
|
258
259
|
highlightStrokeWidth: HighlightStrokeWidth;
|
|
@@ -275,14 +276,15 @@ declare class Text {
|
|
|
275
276
|
render(options: TextRenderOptions): this;
|
|
276
277
|
}
|
|
277
278
|
|
|
279
|
+
type PromiseLike<T> = T | Promise<T>;
|
|
278
280
|
interface Plugin {
|
|
279
281
|
name: string;
|
|
280
282
|
paths?: Path2D[];
|
|
281
283
|
getBoundingBox?: (text: Text) => BoundingBox | undefined;
|
|
282
284
|
updateOrder?: number;
|
|
283
|
-
update?: (text: Text) => void
|
|
285
|
+
update?: (text: Text) => PromiseLike<void>;
|
|
284
286
|
renderOrder?: number;
|
|
285
|
-
render?: (ctx: CanvasRenderingContext2D, text: Text) => void
|
|
287
|
+
render?: (ctx: CanvasRenderingContext2D, text: Text) => PromiseLike<void>;
|
|
286
288
|
}
|
|
287
289
|
declare function definePlugin(options: Plugin): Plugin;
|
|
288
290
|
|
|
@@ -295,10 +297,7 @@ type TextEffect = Partial<TextDrawStyle & {
|
|
|
295
297
|
declare function effect(): Plugin;
|
|
296
298
|
declare function getTransform2D(text: Text, style: TextEffect): Matrix3;
|
|
297
299
|
|
|
298
|
-
|
|
299
|
-
referImage?: string;
|
|
300
|
-
}
|
|
301
|
-
declare function highlight(options?: HighlightOptions): Plugin;
|
|
300
|
+
declare function highlight(): Plugin;
|
|
302
301
|
|
|
303
302
|
declare function listStyle(): Plugin;
|
|
304
303
|
|
|
@@ -319,4 +318,4 @@ declare function uploadColors(ctx: CanvasRenderingContext2D, text: Text): void;
|
|
|
319
318
|
declare function isNone(val: string | undefined): boolean;
|
|
320
319
|
declare function filterEmpty(val: Record<string, any> | undefined): Record<string, any> | undefined;
|
|
321
320
|
|
|
322
|
-
export { Character, type DrawShapePathsOptions, type FontKerning, type FontStyle, type FontWeight, Fragment, type FragmentContent, type HighlightImage, type
|
|
321
|
+
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 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, definePlugin, drawPath, effect, fillBackground, filterEmpty, getTransform2D, highlight, isNone, listStyle, parseColor, setupView, uploadColor, uploadColors };
|
package/dist/index.d.mts
CHANGED
|
@@ -55,6 +55,7 @@ interface TextListStyle {
|
|
|
55
55
|
listStylePosition: ListStylePosition;
|
|
56
56
|
}
|
|
57
57
|
interface TextHighlightStyle {
|
|
58
|
+
highlightReferImage: HighlightImage;
|
|
58
59
|
highlightImage: HighlightImage;
|
|
59
60
|
highlightSize: HighlightSize;
|
|
60
61
|
highlightStrokeWidth: HighlightStrokeWidth;
|
|
@@ -217,7 +218,6 @@ interface TextOptions {
|
|
|
217
218
|
style?: Partial<TextStyle>;
|
|
218
219
|
measureDom?: HTMLElement;
|
|
219
220
|
effects?: TextEffect[];
|
|
220
|
-
highlight?: HighlightOptions;
|
|
221
221
|
}
|
|
222
222
|
declare const defaultTextStyles: TextStyle;
|
|
223
223
|
declare class Text {
|
|
@@ -253,6 +253,7 @@ declare class Text {
|
|
|
253
253
|
listStyleImage: ListStyleImage;
|
|
254
254
|
listStyleSize: ListStyleSize;
|
|
255
255
|
listStylePosition: ListStylePosition;
|
|
256
|
+
highlightReferImage: HighlightImage;
|
|
256
257
|
highlightImage: HighlightImage;
|
|
257
258
|
highlightSize: HighlightSize;
|
|
258
259
|
highlightStrokeWidth: HighlightStrokeWidth;
|
|
@@ -275,14 +276,15 @@ declare class Text {
|
|
|
275
276
|
render(options: TextRenderOptions): this;
|
|
276
277
|
}
|
|
277
278
|
|
|
279
|
+
type PromiseLike<T> = T | Promise<T>;
|
|
278
280
|
interface Plugin {
|
|
279
281
|
name: string;
|
|
280
282
|
paths?: Path2D[];
|
|
281
283
|
getBoundingBox?: (text: Text) => BoundingBox | undefined;
|
|
282
284
|
updateOrder?: number;
|
|
283
|
-
update?: (text: Text) => void
|
|
285
|
+
update?: (text: Text) => PromiseLike<void>;
|
|
284
286
|
renderOrder?: number;
|
|
285
|
-
render?: (ctx: CanvasRenderingContext2D, text: Text) => void
|
|
287
|
+
render?: (ctx: CanvasRenderingContext2D, text: Text) => PromiseLike<void>;
|
|
286
288
|
}
|
|
287
289
|
declare function definePlugin(options: Plugin): Plugin;
|
|
288
290
|
|
|
@@ -295,10 +297,7 @@ type TextEffect = Partial<TextDrawStyle & {
|
|
|
295
297
|
declare function effect(): Plugin;
|
|
296
298
|
declare function getTransform2D(text: Text, style: TextEffect): Matrix3;
|
|
297
299
|
|
|
298
|
-
|
|
299
|
-
referImage?: string;
|
|
300
|
-
}
|
|
301
|
-
declare function highlight(options?: HighlightOptions): Plugin;
|
|
300
|
+
declare function highlight(): Plugin;
|
|
302
301
|
|
|
303
302
|
declare function listStyle(): Plugin;
|
|
304
303
|
|
|
@@ -319,4 +318,4 @@ declare function uploadColors(ctx: CanvasRenderingContext2D, text: Text): void;
|
|
|
319
318
|
declare function isNone(val: string | undefined): boolean;
|
|
320
319
|
declare function filterEmpty(val: Record<string, any> | undefined): Record<string, any> | undefined;
|
|
321
320
|
|
|
322
|
-
export { Character, type DrawShapePathsOptions, type FontKerning, type FontStyle, type FontWeight, Fragment, type FragmentContent, type HighlightImage, type
|
|
321
|
+
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 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, definePlugin, drawPath, effect, fillBackground, filterEmpty, getTransform2D, highlight, isNone, listStyle, parseColor, setupView, uploadColor, uploadColors };
|
package/dist/index.d.ts
CHANGED
|
@@ -55,6 +55,7 @@ interface TextListStyle {
|
|
|
55
55
|
listStylePosition: ListStylePosition;
|
|
56
56
|
}
|
|
57
57
|
interface TextHighlightStyle {
|
|
58
|
+
highlightReferImage: HighlightImage;
|
|
58
59
|
highlightImage: HighlightImage;
|
|
59
60
|
highlightSize: HighlightSize;
|
|
60
61
|
highlightStrokeWidth: HighlightStrokeWidth;
|
|
@@ -217,7 +218,6 @@ interface TextOptions {
|
|
|
217
218
|
style?: Partial<TextStyle>;
|
|
218
219
|
measureDom?: HTMLElement;
|
|
219
220
|
effects?: TextEffect[];
|
|
220
|
-
highlight?: HighlightOptions;
|
|
221
221
|
}
|
|
222
222
|
declare const defaultTextStyles: TextStyle;
|
|
223
223
|
declare class Text {
|
|
@@ -253,6 +253,7 @@ declare class Text {
|
|
|
253
253
|
listStyleImage: ListStyleImage;
|
|
254
254
|
listStyleSize: ListStyleSize;
|
|
255
255
|
listStylePosition: ListStylePosition;
|
|
256
|
+
highlightReferImage: HighlightImage;
|
|
256
257
|
highlightImage: HighlightImage;
|
|
257
258
|
highlightSize: HighlightSize;
|
|
258
259
|
highlightStrokeWidth: HighlightStrokeWidth;
|
|
@@ -275,14 +276,15 @@ declare class Text {
|
|
|
275
276
|
render(options: TextRenderOptions): this;
|
|
276
277
|
}
|
|
277
278
|
|
|
279
|
+
type PromiseLike<T> = T | Promise<T>;
|
|
278
280
|
interface Plugin {
|
|
279
281
|
name: string;
|
|
280
282
|
paths?: Path2D[];
|
|
281
283
|
getBoundingBox?: (text: Text) => BoundingBox | undefined;
|
|
282
284
|
updateOrder?: number;
|
|
283
|
-
update?: (text: Text) => void
|
|
285
|
+
update?: (text: Text) => PromiseLike<void>;
|
|
284
286
|
renderOrder?: number;
|
|
285
|
-
render?: (ctx: CanvasRenderingContext2D, text: Text) => void
|
|
287
|
+
render?: (ctx: CanvasRenderingContext2D, text: Text) => PromiseLike<void>;
|
|
286
288
|
}
|
|
287
289
|
declare function definePlugin(options: Plugin): Plugin;
|
|
288
290
|
|
|
@@ -295,10 +297,7 @@ type TextEffect = Partial<TextDrawStyle & {
|
|
|
295
297
|
declare function effect(): Plugin;
|
|
296
298
|
declare function getTransform2D(text: Text, style: TextEffect): Matrix3;
|
|
297
299
|
|
|
298
|
-
|
|
299
|
-
referImage?: string;
|
|
300
|
-
}
|
|
301
|
-
declare function highlight(options?: HighlightOptions): Plugin;
|
|
300
|
+
declare function highlight(): Plugin;
|
|
302
301
|
|
|
303
302
|
declare function listStyle(): Plugin;
|
|
304
303
|
|
|
@@ -319,4 +318,4 @@ declare function uploadColors(ctx: CanvasRenderingContext2D, text: Text): void;
|
|
|
319
318
|
declare function isNone(val: string | undefined): boolean;
|
|
320
319
|
declare function filterEmpty(val: Record<string, any> | undefined): Record<string, any> | undefined;
|
|
321
320
|
|
|
322
|
-
export { Character, type DrawShapePathsOptions, type FontKerning, type FontStyle, type FontWeight, Fragment, type FragmentContent, type HighlightImage, type
|
|
321
|
+
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 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, definePlugin, drawPath, effect, fillBackground, filterEmpty, getTransform2D, highlight, isNone, listStyle, parseColor, setupView, uploadColor, uploadColors };
|