textmode.js 0.1.8-beta.2 → 0.1.8
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/textmode.esm.js +1144 -953
- package/dist/textmode.esm.min.js +1108 -917
- package/dist/textmode.umd.js +19 -19
- package/dist/textmode.umd.min.js +17 -17
- package/dist/types/Textmode.d.ts +21 -31
- package/dist/types/export/image/types.d.ts +1 -1
- package/dist/types/export/svg/SVGPathGenerator.d.ts +1 -1
- package/dist/types/index.d.ts +2 -1
- package/dist/types/textmode/Canvas.d.ts +3 -3
- package/dist/types/textmode/ConversionPipeline.d.ts +7 -2
- package/dist/types/textmode/Textmodifier.d.ts +29 -20
- package/dist/types/textmode/converters/Converter.d.ts +4 -4
- package/dist/types/textmode/converters/FeatureConverter.d.ts +3 -3
- package/dist/types/textmode/font/CharacterColorMapper.d.ts +4 -9
- package/dist/types/textmode/font/CharacterExtractor.d.ts +15 -25
- package/dist/types/textmode/font/MetricsCalculator.d.ts +34 -9
- package/dist/types/textmode/font/TextmodeFont.d.ts +3 -2
- package/dist/types/textmode/font/TextureAtlas.d.ts +29 -13
- package/dist/types/textmode/font/index.d.ts +3 -1
- package/dist/types/textmode/font/types.d.ts +2 -136
- package/dist/types/textmode/font/typr/Typr.d.ts +18 -0
- package/dist/types/textmode/font/typr/types.d.ts +254 -0
- package/dist/types/textmode/font/utils/CmapParser.d.ts +47 -0
- package/dist/types/textmode/font/utils/FontConstants.d.ts +60 -0
- package/dist/types/textmode/font/utils/FontTableReader.d.ts +56 -0
- package/dist/types/textmode/font/utils/index.d.ts +9 -0
- package/dist/types/textmode/mixins/ConversionMixin.d.ts +3 -4
- package/dist/types/textmode/mixins/ExportMixin.d.ts +2 -14
- package/dist/types/textmode/mixins/RenderingMixin.d.ts +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,254 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type definitions for Typr.js - Font parsing library
|
|
3
|
+
*
|
|
4
|
+
* Comprehensive TypeScript types for all Typr font parsing structures,
|
|
5
|
+
* tables, and interfaces used throughout the font processing pipeline.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Binary reading utilities interface
|
|
9
|
+
*/
|
|
10
|
+
export interface TyprBinary {
|
|
11
|
+
/** Read signed 16-bit integer */
|
|
12
|
+
readShort: (buff: Uint8Array, p: number) => number;
|
|
13
|
+
/** Read unsigned 16-bit integer */
|
|
14
|
+
readUshort: (buff: Uint8Array, p: number) => number;
|
|
15
|
+
/** Read array of unsigned 16-bit integers */
|
|
16
|
+
readUshorts: (buff: Uint8Array, p: number, len: number) => number[];
|
|
17
|
+
/** Read unsigned 32-bit integer */
|
|
18
|
+
readUint: (buff: Uint8Array, p: number) => number;
|
|
19
|
+
/** Read ASCII string */
|
|
20
|
+
readASCII: (buff: Uint8Array, p: number, l: number) => string;
|
|
21
|
+
/** Shared typed array buffers for efficient reading */
|
|
22
|
+
t: {
|
|
23
|
+
uint8: Uint8Array;
|
|
24
|
+
int16: Int16Array;
|
|
25
|
+
uint16: Uint16Array;
|
|
26
|
+
uint32: Uint32Array;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Interface for cmap table Format 4 (Basic Multilingual Plane)
|
|
31
|
+
* Used for Unicode BMP character mapping
|
|
32
|
+
*/
|
|
33
|
+
export interface CmapTableFormat4 {
|
|
34
|
+
format: 4;
|
|
35
|
+
searchRange: number;
|
|
36
|
+
entrySelector: number;
|
|
37
|
+
rangeShift: number;
|
|
38
|
+
startCount: number[];
|
|
39
|
+
endCount: number[];
|
|
40
|
+
idRangeOffset: number[];
|
|
41
|
+
idDelta: number[];
|
|
42
|
+
glyphIdArray: number[];
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Interface for cmap table Format 12 (Extended Unicode ranges)
|
|
46
|
+
* Used for full Unicode character mapping including supplementary planes
|
|
47
|
+
*/
|
|
48
|
+
export interface CmapTableFormat12 {
|
|
49
|
+
format: 12;
|
|
50
|
+
groups: Uint32Array;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Union type for supported cmap table formats
|
|
54
|
+
*/
|
|
55
|
+
export type CmapTable = CmapTableFormat4 | CmapTableFormat12 | {
|
|
56
|
+
format: number;
|
|
57
|
+
};
|
|
58
|
+
/**
|
|
59
|
+
* Character map data from OpenType/TrueType font
|
|
60
|
+
* Contains multiple encoding tables and platform-specific mappings
|
|
61
|
+
*/
|
|
62
|
+
export interface CmapData {
|
|
63
|
+
/** Array of character mapping tables */
|
|
64
|
+
tables: CmapTable[];
|
|
65
|
+
/** Platform+encoding ID mappings to table indices */
|
|
66
|
+
ids: Record<string, number>;
|
|
67
|
+
/** Offset of cmap table in font data */
|
|
68
|
+
off: number;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Head table from OpenType/TrueType font
|
|
72
|
+
* Contains global font metrics and metadata
|
|
73
|
+
*/
|
|
74
|
+
export interface HeadTable {
|
|
75
|
+
/** Units per EM square */
|
|
76
|
+
unitsPerEm: number;
|
|
77
|
+
/** Minimum x coordinate across all glyphs */
|
|
78
|
+
xMin: number;
|
|
79
|
+
/** Minimum y coordinate across all glyphs */
|
|
80
|
+
yMin: number;
|
|
81
|
+
/** Maximum x coordinate across all glyphs */
|
|
82
|
+
xMax: number;
|
|
83
|
+
/** Maximum y coordinate across all glyphs */
|
|
84
|
+
yMax: number;
|
|
85
|
+
/** Format of location table (0 = short, 1 = long) */
|
|
86
|
+
indexToLocFormat: number;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Horizontal header table from OpenType/TrueType font
|
|
90
|
+
* Contains horizontal layout metrics
|
|
91
|
+
*/
|
|
92
|
+
export interface HheaTable {
|
|
93
|
+
/** Typographic ascender */
|
|
94
|
+
ascender: number;
|
|
95
|
+
/** Typographic descender */
|
|
96
|
+
descender: number;
|
|
97
|
+
/** Typographic line gap */
|
|
98
|
+
lineGap: number;
|
|
99
|
+
/** Maximum advance width */
|
|
100
|
+
advanceWidthMax: number;
|
|
101
|
+
/** Minimum left side bearing */
|
|
102
|
+
minLeftSideBearing: number;
|
|
103
|
+
/** Minimum right side bearing */
|
|
104
|
+
minRightSideBearing: number;
|
|
105
|
+
/** Maximum extent */
|
|
106
|
+
xMaxExtent: number;
|
|
107
|
+
/** Caret slope rise */
|
|
108
|
+
caretSlopeRise: number;
|
|
109
|
+
/** Caret slope run */
|
|
110
|
+
caretSlopeRun: number;
|
|
111
|
+
/** Caret offset */
|
|
112
|
+
caretOffset: number;
|
|
113
|
+
/** Reserved fields */
|
|
114
|
+
res0: number;
|
|
115
|
+
res1: number;
|
|
116
|
+
res2: number;
|
|
117
|
+
res3: number;
|
|
118
|
+
/** Metric data format */
|
|
119
|
+
metricDataFormat: number;
|
|
120
|
+
/** Number of horizontal metrics */
|
|
121
|
+
numberOfHMetrics: number;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Horizontal metrics table from OpenType/TrueType font
|
|
125
|
+
* Contains advance widths and left side bearings for all glyphs
|
|
126
|
+
*/
|
|
127
|
+
export interface HmtxTable {
|
|
128
|
+
/** Array of advance widths for each glyph */
|
|
129
|
+
aWidth: number[];
|
|
130
|
+
/** Array of left side bearings for each glyph */
|
|
131
|
+
lsBearing: number[];
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Maximum profile table from OpenType/TrueType font
|
|
135
|
+
* Contains the number of glyphs and other maximums
|
|
136
|
+
*/
|
|
137
|
+
export interface MaxpTable {
|
|
138
|
+
/** Total number of glyphs in the font */
|
|
139
|
+
numGlyphs: number;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Location table for glyph offsets
|
|
143
|
+
* Maps glyph indices to their byte offsets in the glyf table
|
|
144
|
+
*/
|
|
145
|
+
export type LocaTable = number[];
|
|
146
|
+
/**
|
|
147
|
+
* Glyph data structure for parsed glyphs
|
|
148
|
+
* Contains the actual glyph outline data
|
|
149
|
+
*/
|
|
150
|
+
export interface GlyphData {
|
|
151
|
+
/** Number of contours (-1 for composite glyphs) */
|
|
152
|
+
noc: number;
|
|
153
|
+
/** Bounding box coordinates */
|
|
154
|
+
xMin: number;
|
|
155
|
+
yMin: number;
|
|
156
|
+
xMax: number;
|
|
157
|
+
yMax: number;
|
|
158
|
+
/** End points of each contour */
|
|
159
|
+
endPts: number[];
|
|
160
|
+
/** Point flags indicating curve/line segments */
|
|
161
|
+
flags: number[];
|
|
162
|
+
/** X coordinates of all points */
|
|
163
|
+
xs: number[];
|
|
164
|
+
/** Y coordinates of all points */
|
|
165
|
+
ys: number[];
|
|
166
|
+
/** Composite glyph parts (for composite glyphs) */
|
|
167
|
+
parts?: any[];
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Font table parser interface
|
|
171
|
+
* Each table parser implements this interface
|
|
172
|
+
*/
|
|
173
|
+
export interface TableParser<T = any> {
|
|
174
|
+
parseTab: (data: Uint8Array, offset: number, length: number, font?: TyprFont) => T;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Extended cmap parser with format-specific methods
|
|
178
|
+
*/
|
|
179
|
+
export interface CmapParser extends TableParser<CmapData> {
|
|
180
|
+
parse4: (data: Uint8Array, offset: number) => CmapTableFormat4;
|
|
181
|
+
parse12: (data: Uint8Array, offset: number) => CmapTableFormat12;
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Collection of all table parsers
|
|
185
|
+
*/
|
|
186
|
+
export interface TyprTableParsers {
|
|
187
|
+
cmap: CmapParser;
|
|
188
|
+
head: TableParser<HeadTable>;
|
|
189
|
+
hhea: TableParser<HheaTable>;
|
|
190
|
+
maxp: TableParser<MaxpTable>;
|
|
191
|
+
hmtx: TableParser<HmtxTable>;
|
|
192
|
+
loca: TableParser<LocaTable>;
|
|
193
|
+
glyf: TableParser<(GlyphData | null)[]> & {
|
|
194
|
+
_parseGlyf: (font: TyprFont, glyphIndex: number) => GlyphData | null;
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Complete TyprFont interface representing a parsed OpenType/TrueType font
|
|
199
|
+
* This interface describes the structure returned by Typr.parse()
|
|
200
|
+
*/
|
|
201
|
+
export interface TyprFont {
|
|
202
|
+
/** Internal font data buffer */
|
|
203
|
+
_data: Uint8Array;
|
|
204
|
+
/** Font index in collection */
|
|
205
|
+
_index: number;
|
|
206
|
+
/** Font offset in data */
|
|
207
|
+
_offset: number;
|
|
208
|
+
/** Character map table */
|
|
209
|
+
cmap: CmapData;
|
|
210
|
+
/** Font header table */
|
|
211
|
+
head: HeadTable;
|
|
212
|
+
/** Horizontal header table */
|
|
213
|
+
hhea: HheaTable;
|
|
214
|
+
/** Horizontal metrics table */
|
|
215
|
+
hmtx: HmtxTable;
|
|
216
|
+
/** Maximum profile table */
|
|
217
|
+
maxp: MaxpTable;
|
|
218
|
+
/** Glyph location table */
|
|
219
|
+
loca: LocaTable;
|
|
220
|
+
/** Glyph data table - stores parsed glyph data (populated on demand) */
|
|
221
|
+
glyf: (GlyphData | null)[];
|
|
222
|
+
/** Additional font tables that may be present */
|
|
223
|
+
[tableName: string]: any;
|
|
224
|
+
}
|
|
225
|
+
/**
|
|
226
|
+
* Glyph outline data structure
|
|
227
|
+
* Contains coordinate and control point information for rendering glyphs
|
|
228
|
+
*/
|
|
229
|
+
export interface GlyphData {
|
|
230
|
+
/** Number of contours in the glyph */
|
|
231
|
+
noc: number;
|
|
232
|
+
/** X coordinates of glyph points */
|
|
233
|
+
xs: number[];
|
|
234
|
+
/** Y coordinates of glyph points */
|
|
235
|
+
ys: number[];
|
|
236
|
+
/** Indices of the last point in each contour */
|
|
237
|
+
endPts: number[];
|
|
238
|
+
/** Flags indicating point types (on-curve, off-curve, etc.) */
|
|
239
|
+
flags: number[];
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Main Typr interface
|
|
243
|
+
* Provides font parsing and table lookup functionality
|
|
244
|
+
*/
|
|
245
|
+
export interface TyprStatic {
|
|
246
|
+
/** Parse font buffer and return array of fonts */
|
|
247
|
+
parse: (buffer: ArrayBuffer) => TyprFont[];
|
|
248
|
+
/** Find a specific table in font data */
|
|
249
|
+
findTable: (data: Uint8Array, tableName: string, offset: number) => [number, number] | null;
|
|
250
|
+
/** Collection of table parsers */
|
|
251
|
+
T: TyprTableParsers;
|
|
252
|
+
/** Binary reading utilities */
|
|
253
|
+
B: TyprBinary;
|
|
254
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { TyprFont } from '../typr/types.ts';
|
|
2
|
+
import { FontTableReader } from './FontTableReader.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Specialized utility for character mapping operations.
|
|
5
|
+
* Provides high-level character extraction and validation functions.
|
|
6
|
+
*/
|
|
7
|
+
export declare class CmapParser {
|
|
8
|
+
private _tableReader;
|
|
9
|
+
constructor(tableReader: FontTableReader);
|
|
10
|
+
/**
|
|
11
|
+
* Extracts all available characters from a font's cmap tables.
|
|
12
|
+
* Returns an array of unique character strings.
|
|
13
|
+
*/
|
|
14
|
+
$extractAllCharacters(font: TyprFont): string[];
|
|
15
|
+
/**
|
|
16
|
+
* Validates whether a character exists in the font.
|
|
17
|
+
*/
|
|
18
|
+
$characterExists(font: TyprFont, character: string): boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Validates whether all characters in a string exist in the font.
|
|
21
|
+
*/
|
|
22
|
+
$allCharactersExist(font: TyprFont, text: string): boolean;
|
|
23
|
+
/**
|
|
24
|
+
* Filters out characters that don't exist in the font.
|
|
25
|
+
*/
|
|
26
|
+
$filterExistingCharacters(font: TyprFont, characters: string[]): string[];
|
|
27
|
+
/**
|
|
28
|
+
* Filters out problematic characters that might cause rendering issues.
|
|
29
|
+
*/
|
|
30
|
+
$filterProblematicCharacters(characters: string[]): string[];
|
|
31
|
+
/**
|
|
32
|
+
* Extracts characters from a Format 4 cmap table (Basic Multilingual Plane).
|
|
33
|
+
*/
|
|
34
|
+
private _extractCharactersFromFormat4;
|
|
35
|
+
/**
|
|
36
|
+
* Extracts characters from a Format 12 cmap table (Extended Unicode ranges).
|
|
37
|
+
*/
|
|
38
|
+
private _extractCharactersFromFormat12;
|
|
39
|
+
/**
|
|
40
|
+
* Calculates the glyph index for a character in a Format 4 cmap table.
|
|
41
|
+
*/
|
|
42
|
+
private _calculateGlyphIndexFormat4;
|
|
43
|
+
/**
|
|
44
|
+
* Checks if a character is valid for rendering.
|
|
45
|
+
*/
|
|
46
|
+
private _isValidCharacter;
|
|
47
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Font-related constants and configuration values.
|
|
3
|
+
* Centralizes magic numbers and configuration to improve maintainability.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Character mapping platform and encoding preferences.
|
|
7
|
+
* Ordered by preference for Unicode character mapping.
|
|
8
|
+
*/
|
|
9
|
+
export declare const CMAP_PLATFORM_PREFERENCES: readonly ["p3e1", "p3e10", "p0e3", "p0e4"];
|
|
10
|
+
/**
|
|
11
|
+
* Control characters that are allowed in text rendering.
|
|
12
|
+
* Most control characters are filtered out, but these common ones are preserved.
|
|
13
|
+
*/
|
|
14
|
+
export declare const ALLOWED_CONTROL_CHARACTERS: readonly [9, 10, 13];
|
|
15
|
+
/**
|
|
16
|
+
* Character code ranges to filter out during character extraction.
|
|
17
|
+
*/
|
|
18
|
+
export declare const FILTERED_CHARACTER_RANGES: readonly [{
|
|
19
|
+
readonly start: 0;
|
|
20
|
+
readonly end: 31;
|
|
21
|
+
}, {
|
|
22
|
+
readonly start: 127;
|
|
23
|
+
readonly end: 159;
|
|
24
|
+
}];
|
|
25
|
+
/**
|
|
26
|
+
* Font table format constants.
|
|
27
|
+
*/
|
|
28
|
+
export declare const CMAP_FORMATS: {
|
|
29
|
+
readonly BMP_UNICODE: 4;
|
|
30
|
+
readonly FULL_UNICODE: 12;
|
|
31
|
+
};
|
|
32
|
+
/**
|
|
33
|
+
* Default font metrics and sizing constants.
|
|
34
|
+
*/
|
|
35
|
+
export declare const FONT_DEFAULTS: {
|
|
36
|
+
readonly SIZE: 16;
|
|
37
|
+
readonly FAMILY_NAME: "UrsaFont";
|
|
38
|
+
readonly ATLAS_PADDING: 1;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Cache size limits to prevent excessive memory usage.
|
|
42
|
+
*/
|
|
43
|
+
export declare const CACHE_LIMITS: {
|
|
44
|
+
readonly GLYPH_INDEX_CACHE: 10000;
|
|
45
|
+
readonly CMAP_TABLE_CACHE: 100;
|
|
46
|
+
readonly FONT_METRICS_CACHE: 1000;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Sentinel values used in font tables.
|
|
50
|
+
*/
|
|
51
|
+
export declare const FONT_SENTINELS: {
|
|
52
|
+
readonly CMAP_END_MARKER: 65535;
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* WebGL texture configuration for font atlases.
|
|
56
|
+
*/
|
|
57
|
+
export declare const TEXTURE_CONFIG: {
|
|
58
|
+
readonly FILTER: "nearest";
|
|
59
|
+
readonly WRAP: "clamp-to-edge";
|
|
60
|
+
};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { TyprFont, CmapTable } from '../typr/types.ts';
|
|
2
|
+
/**
|
|
3
|
+
* Centralized font table reader that eliminates redundant font data access.
|
|
4
|
+
* Provides cached access to font tables and metrics with consistent error handling.
|
|
5
|
+
*/
|
|
6
|
+
export declare class FontTableReader {
|
|
7
|
+
private _glyphIndexCache;
|
|
8
|
+
private _cmapTableCache;
|
|
9
|
+
/**
|
|
10
|
+
* Gets the best character mapping table for Unicode text.
|
|
11
|
+
* Prefers format 4 (BMP Unicode) or format 12 (full Unicode).
|
|
12
|
+
* Results are cached per font.
|
|
13
|
+
*/
|
|
14
|
+
$getBestCmapTable(font: TyprFont): CmapTable | null;
|
|
15
|
+
/**
|
|
16
|
+
* Gets the glyph index for a given Unicode code point.
|
|
17
|
+
* Results are cached per font and character.
|
|
18
|
+
*/
|
|
19
|
+
$getGlyphIndex(font: TyprFont, codePoint: number): number;
|
|
20
|
+
/**
|
|
21
|
+
* Gets the glyph index for a character string.
|
|
22
|
+
* Convenience method that extracts the code point first.
|
|
23
|
+
*/
|
|
24
|
+
$getGlyphIndexForCharacter(font: TyprFont, character: string): number;
|
|
25
|
+
/**
|
|
26
|
+
* Gets the advance width for a glyph from the horizontal metrics table.
|
|
27
|
+
*/
|
|
28
|
+
$getGlyphAdvanceWidth(font: TyprFont, glyphIndex: number): number;
|
|
29
|
+
/**
|
|
30
|
+
* Gets font-level metrics scaled to the specified font size.
|
|
31
|
+
*/
|
|
32
|
+
$getFontMetrics(font: TyprFont, fontSize: number): {
|
|
33
|
+
ascender: number;
|
|
34
|
+
descender: number;
|
|
35
|
+
lineGap: number;
|
|
36
|
+
lineHeight: number;
|
|
37
|
+
unitsPerEm: number;
|
|
38
|
+
scale: number;
|
|
39
|
+
};
|
|
40
|
+
/**
|
|
41
|
+
* Clears all caches. Useful when fonts are updated or memory needs to be freed.
|
|
42
|
+
*/
|
|
43
|
+
$clearCache(): void;
|
|
44
|
+
/**
|
|
45
|
+
* Gets a unique identifier for a font based on its data offset and length.
|
|
46
|
+
*/
|
|
47
|
+
private _getFontId;
|
|
48
|
+
/**
|
|
49
|
+
* Gets glyph index from format 4 cmap table (BMP Unicode).
|
|
50
|
+
*/
|
|
51
|
+
private _getGlyphIndexFormat4;
|
|
52
|
+
/**
|
|
53
|
+
* Gets glyph index from format 12 cmap table (full Unicode).
|
|
54
|
+
*/
|
|
55
|
+
private _getGlyphIndexFormat12;
|
|
56
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Font utilities - centralized font processing functionality.
|
|
3
|
+
*
|
|
4
|
+
* This module provides shared utilities that eliminate code duplication
|
|
5
|
+
* across the font system components.
|
|
6
|
+
*/
|
|
7
|
+
export { FontTableReader } from './FontTableReader.ts';
|
|
8
|
+
export { CmapParser } from './CmapParser.ts';
|
|
9
|
+
export * from './FontConstants.ts';
|
|
@@ -6,7 +6,6 @@ import type { TextmodeConverter } from '../converters';
|
|
|
6
6
|
export interface ConversionCapabilities {
|
|
7
7
|
/**
|
|
8
8
|
* Adds a new converter to the pipeline.
|
|
9
|
-
* @param name A unique name for the converter.
|
|
10
9
|
* @param type The type of converter to add. Can be either "brightness" or "custom".
|
|
11
10
|
* @returns The newly created {@link TextmodeConverter} instance or `void` if the addition failed.
|
|
12
11
|
*
|
|
@@ -19,17 +18,17 @@ export interface ConversionCapabilities {
|
|
|
19
18
|
* const textmodifier = await textmode.create(canvas);
|
|
20
19
|
*
|
|
21
20
|
* // Add a new brightness converter
|
|
22
|
-
* const myConverter = textmodifier.addConverter('
|
|
21
|
+
* const myConverter = textmodifier.addConverter('brightness');
|
|
23
22
|
*
|
|
24
23
|
* // Configure the new converter
|
|
25
24
|
* myConverter.characters("▓▒░ ");
|
|
26
25
|
* myConverter.enabled(true);
|
|
27
26
|
*
|
|
28
27
|
* // Add a custom converter
|
|
29
|
-
* const customConverter = textmodifier.addConverter('
|
|
28
|
+
* const customConverter = textmodifier.addConverter('custom');
|
|
30
29
|
* ```
|
|
31
30
|
*/
|
|
32
|
-
addConverter(
|
|
31
|
+
addConverter(type: 'brightness' | 'custom'): TextmodeConverter | void;
|
|
33
32
|
/**
|
|
34
33
|
* Removes a converter from the pipeline by name or instance.
|
|
35
34
|
* @param nameOrInstance The unique name of the converter or the converter instance to remove.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Mixin } from './TextmodifierMixin';
|
|
2
2
|
import { type SVGExportOptions } from '../../export/svg';
|
|
3
3
|
import { type TXTExportOptions } from '../../export/txt';
|
|
4
|
-
import { type ImageExportOptions
|
|
4
|
+
import { type ImageExportOptions } from '../../export/image';
|
|
5
5
|
/**
|
|
6
6
|
* Interface for export capabilities that will be mixed into Textmodifier
|
|
7
7
|
*/
|
|
@@ -30,18 +30,6 @@ export interface ExportCapabilities {
|
|
|
30
30
|
*
|
|
31
31
|
* // Print to console or use otherwise
|
|
32
32
|
* console.log(textString);
|
|
33
|
-
*
|
|
34
|
-
* ////////
|
|
35
|
-
*
|
|
36
|
-
* // Example with video element
|
|
37
|
-
* const video = document.querySelector('video#myVideo');
|
|
38
|
-
* const videoTextmodifier = await textmode.create(video);
|
|
39
|
-
*
|
|
40
|
-
* // The textmode overlay will automatically update as the video plays
|
|
41
|
-
* video.play();
|
|
42
|
-
*
|
|
43
|
-
* // Get current frame as ASCII
|
|
44
|
-
* const videoFrame = videoTextmodifier.toString();
|
|
45
33
|
* ```
|
|
46
34
|
*/
|
|
47
35
|
toString(options?: Omit<TXTExportOptions, 'filename'>): string;
|
|
@@ -145,7 +133,7 @@ export interface ExportCapabilities {
|
|
|
145
133
|
* });
|
|
146
134
|
* ```
|
|
147
135
|
*/
|
|
148
|
-
saveCanvas(filename: string, format?:
|
|
136
|
+
saveCanvas(filename: string, format?: 'png' | 'jpg' | 'webp', options?: Omit<ImageExportOptions, 'filename' | 'format'>): Promise<void>;
|
|
149
137
|
}
|
|
150
138
|
/**
|
|
151
139
|
* Mixin that adds export capabilities to a class
|
|
@@ -381,6 +381,7 @@ export interface RenderingCapabilities {
|
|
|
381
381
|
* @param vertexSource The GLSL source code for the vertex shader.
|
|
382
382
|
* @param fragmentSource The GLSL source code for the fragment shader.
|
|
383
383
|
* @returns The created shader program for use in `textmode.js`.
|
|
384
|
+
* @ignore
|
|
384
385
|
*/
|
|
385
386
|
createShader(vertexSource: string, fragmentSource: string): Shader;
|
|
386
387
|
/**
|