pa_font 0.1.2 → 0.2.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/README.md +175 -0
- package/dist/paFont.cjs +2756 -11
- package/dist/paFont.cjs.map +1 -1
- package/dist/paFont.js +2754 -10
- package/dist/paFont.js.map +1 -1
- package/paFont.d.ts +70 -3
- package/package.json +2 -1
package/paFont.d.ts
CHANGED
|
@@ -34,6 +34,21 @@ export interface PointOptions extends ShapeOptions {
|
|
|
34
34
|
includeHoles?: boolean;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
+
export interface ParagraphOptions extends TextOptions {
|
|
38
|
+
width: number;
|
|
39
|
+
lineHeight?: number;
|
|
40
|
+
align?: "left" | "center" | "right" | "justify";
|
|
41
|
+
whiteSpace?: "normal" | "pre-wrap" | "nowrap";
|
|
42
|
+
overflowWrap?: "normal" | "break-word" | "anywhere";
|
|
43
|
+
maxLines?: number;
|
|
44
|
+
ellipsis?: string | false;
|
|
45
|
+
fontFamily?: string;
|
|
46
|
+
fontWeight?: string | number;
|
|
47
|
+
fontStyle?: "normal" | "italic" | "oblique";
|
|
48
|
+
font?: string;
|
|
49
|
+
engine?: "pretext" | "native";
|
|
50
|
+
}
|
|
51
|
+
|
|
37
52
|
export interface Metrics {
|
|
38
53
|
width: number;
|
|
39
54
|
bbox: Rect;
|
|
@@ -63,6 +78,43 @@ export interface ShapeMetrics {
|
|
|
63
78
|
bbox: Rect;
|
|
64
79
|
}
|
|
65
80
|
|
|
81
|
+
export interface ParagraphLine {
|
|
82
|
+
index: number;
|
|
83
|
+
text: string;
|
|
84
|
+
start: number;
|
|
85
|
+
end: number;
|
|
86
|
+
x: number;
|
|
87
|
+
y: number;
|
|
88
|
+
width: number;
|
|
89
|
+
baseline: number;
|
|
90
|
+
height: number;
|
|
91
|
+
bbox: Rect;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export interface ParagraphMetrics {
|
|
95
|
+
x: number;
|
|
96
|
+
y: number;
|
|
97
|
+
width: number;
|
|
98
|
+
height: number;
|
|
99
|
+
lineCount: number;
|
|
100
|
+
bbox: Rect;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export interface ParagraphShapeOptions extends ShapeOptions {
|
|
104
|
+
layout?: "current" | "pretext" | "native";
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export interface ParagraphPointOptions extends PointOptions {
|
|
108
|
+
layout?: "current" | "pretext" | "native";
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface DrawTextOptions {
|
|
112
|
+
fillStyle?: string | CanvasGradient | CanvasPattern;
|
|
113
|
+
strokeStyle?: string | CanvasGradient | CanvasPattern;
|
|
114
|
+
fill?: boolean;
|
|
115
|
+
stroke?: boolean;
|
|
116
|
+
}
|
|
117
|
+
|
|
66
118
|
export class PAShape implements Iterable<Region> {
|
|
67
119
|
text: string;
|
|
68
120
|
bbox: Rect;
|
|
@@ -81,7 +133,21 @@ export class PAShape implements Iterable<Region> {
|
|
|
81
133
|
toPoints(options?: PointOptions): PointSample[];
|
|
82
134
|
}
|
|
83
135
|
|
|
84
|
-
export class
|
|
136
|
+
export class paParagraph {
|
|
137
|
+
text: string;
|
|
138
|
+
lines: ParagraphLine[];
|
|
139
|
+
metrics: ParagraphMetrics;
|
|
140
|
+
options: ParagraphOptions;
|
|
141
|
+
|
|
142
|
+
relayout(next?: Partial<ParagraphOptions>): paParagraph;
|
|
143
|
+
line(index: number): ParagraphLine | undefined;
|
|
144
|
+
drawText(ctx: CanvasRenderingContext2D, options?: DrawTextOptions): void;
|
|
145
|
+
toShape(options?: ParagraphShapeOptions): PAShape;
|
|
146
|
+
toRegions(options?: ParagraphShapeOptions): Region[];
|
|
147
|
+
toPoints(options?: ParagraphPointOptions): PointSample[];
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export class paFont {
|
|
85
151
|
constructor(font: unknown);
|
|
86
152
|
|
|
87
153
|
font: unknown;
|
|
@@ -90,11 +156,12 @@ export class PAFont {
|
|
|
90
156
|
static load(
|
|
91
157
|
source: string | URL | ArrayBuffer | ArrayBufferView,
|
|
92
158
|
options?: LoadOptions,
|
|
93
|
-
): Promise<
|
|
159
|
+
): Promise<paFont>;
|
|
94
160
|
|
|
95
161
|
text(value: string, options?: TextOptions): PAShape;
|
|
96
162
|
glyph(value: string, options?: TextOptions): PAShape;
|
|
97
163
|
metrics(value: string, options?: TextOptions): Metrics;
|
|
164
|
+
paragraph(value: string, options: ParagraphOptions): paParagraph;
|
|
98
165
|
}
|
|
99
166
|
|
|
100
|
-
export default
|
|
167
|
+
export default paFont;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pa_font",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.2.0",
|
|
4
4
|
"description": "Generate polygon and point geometry from OpenType fonts.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"font",
|
|
@@ -40,6 +40,7 @@
|
|
|
40
40
|
"vite": "^8.0.1"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
+
"@chenglou/pretext": "^0.0.4",
|
|
43
44
|
"opentype.js": "^1.3.4"
|
|
44
45
|
}
|
|
45
46
|
}
|