textmode.js 0.6.0-beta.4 → 0.6.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/dist/textmode.esm.js +1947 -2019
- package/dist/textmode.umd.js +11 -11
- package/dist/types/index.d.ts +1 -1
- package/dist/types/rendering/index.d.ts +1 -1
- package/dist/types/rendering/webgl/core/Renderer.d.ts +1 -4
- package/dist/types/rendering/webgl/core/Shader.d.ts +1 -2
- package/dist/types/rendering/webgl/materials/MaterialManager.d.ts +0 -1
- package/dist/types/textmode/TextmodeColor.d.ts +2 -13
- package/dist/types/textmode/Textmodifier.d.ts +4 -5
- package/dist/types/textmode/conversion/ConversionRegistry.d.ts +30 -2
- package/dist/types/textmode/interfaces/ITextmodifier.d.ts +5 -5
- package/dist/types/textmode/loadables/TextmodeImage.d.ts +1 -1
- package/dist/types/textmode/loadables/TextmodeSource.d.ts +21 -7
- package/dist/types/textmode/loadables/font/CharacterColorMapper.d.ts +11 -14
- package/dist/types/textmode/loadables/font/MetricsCalculator.d.ts +0 -4
- package/dist/types/textmode/loadables/font/TextmodeFont.d.ts +7 -19
- package/dist/types/textmode/loadables/font/TextureAtlas.d.ts +1 -9
- package/dist/types/textmode/loadables/font/index.d.ts +1 -1
- package/dist/types/textmode/loadables/font/types.d.ts +26 -2
- package/dist/types/textmode/loadables/font/utils/FontTableReader.d.ts +1 -12
- package/dist/types/textmode/loadables/index.d.ts +2 -4
- package/dist/types/textmode/loadables/{TextmodeVideo.d.ts → video/TextmodeVideo.d.ts} +8 -76
- package/dist/types/textmode/loadables/video/TextmodeVideoPreloader.d.ts +29 -0
- package/dist/types/textmode/loadables/video/types.d.ts +43 -0
- package/dist/types/textmode/mixins/interfaces/IRenderingMixin.d.ts +5 -13
- package/package.json +2 -1
package/dist/types/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Textmode } from './Textmode';
|
|
2
2
|
export { Textmodifier } from './textmode/Textmodifier';
|
|
3
|
-
export { GLFramebuffer as TextmodeFramebuffer
|
|
3
|
+
export { GLFramebuffer as TextmodeFramebuffer } from './rendering';
|
|
4
4
|
export { TextmodeColor } from './textmode/TextmodeColor';
|
|
5
5
|
export { TextmodeCanvas } from './textmode/Canvas';
|
|
6
6
|
export { TextmodeGrid } from './textmode/Grid';
|
|
@@ -31,10 +31,7 @@ export declare class GLRenderer implements IRenderer {
|
|
|
31
31
|
* Used by framebuffer end() to restore previous state.
|
|
32
32
|
* @internal
|
|
33
33
|
*/
|
|
34
|
-
$popFramebufferState():
|
|
35
|
-
framebuffer: WebGLFramebuffer | null;
|
|
36
|
-
viewport: [number, number, number, number];
|
|
37
|
-
};
|
|
34
|
+
$popFramebufferState(): void;
|
|
38
35
|
/**
|
|
39
36
|
* Bind a framebuffer and update CPU-side tracking.
|
|
40
37
|
* @internal
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
type GlyphColor = [number, number, number];
|
|
2
|
-
type GlyphColorResolver = (chars: string) => GlyphColor[];
|
|
3
1
|
type ColorTuple = [number, number, number] | [number, number, number, number];
|
|
4
2
|
/**
|
|
5
3
|
* Represents a color in the `textmode.js` rendering system.
|
|
@@ -12,7 +10,6 @@ type ColorTuple = [number, number, number] | [number, number, number, number];
|
|
|
12
10
|
export declare class TextmodeColor {
|
|
13
11
|
private readonly _rgba;
|
|
14
12
|
private readonly _normalized;
|
|
15
|
-
private readonly _character?;
|
|
16
13
|
/** Red component *(0-255)* */
|
|
17
14
|
readonly r: number;
|
|
18
15
|
/** Green component *(0-255)* */
|
|
@@ -27,8 +24,9 @@ export declare class TextmodeColor {
|
|
|
27
24
|
* Accepts an existing {@link TextmodeColor}, CSS hex strings, single characters
|
|
28
25
|
* (resolved through a glyph resolver), grayscale values, RGB(A) tuples, or
|
|
29
26
|
* normalized component arrays.
|
|
27
|
+
* @ignore
|
|
30
28
|
*/
|
|
31
|
-
static $from(value: TextmodeColor | string | number | ColorTuple,
|
|
29
|
+
static $from(value: TextmodeColor | string | number | ColorTuple, g?: number, b?: number, a?: number): TextmodeColor;
|
|
32
30
|
/**
|
|
33
31
|
* Create a color from RGB or RGBA components (0-255 range).
|
|
34
32
|
* @ignore
|
|
@@ -44,20 +42,12 @@ export declare class TextmodeColor {
|
|
|
44
42
|
* @ignore
|
|
45
43
|
*/
|
|
46
44
|
static $fromHex(hex: string): TextmodeColor;
|
|
47
|
-
/**
|
|
48
|
-
* Create a color representing a textmode character encoded as RGB triplet
|
|
49
|
-
* (values already normalized 0-1 for shader usage).
|
|
50
|
-
* @ignore
|
|
51
|
-
*/
|
|
52
|
-
static $fromCharacter(characterColor: [number, number, number]): TextmodeColor;
|
|
53
45
|
/** Returns a plain RGB array with integer components. */
|
|
54
46
|
get rgb(): [number, number, number];
|
|
55
47
|
/** Returns a plain RGBA array with integer components. */
|
|
56
48
|
get rgba(): [number, number, number, number];
|
|
57
49
|
/** Returns the normalized *(0-1)* RGBA array. */
|
|
58
50
|
get normalized(): [number, number, number, number];
|
|
59
|
-
/** Returns the character encoding *(0-1 range)* if this color was created from a glyph. */
|
|
60
|
-
get character(): [number, number, number] | undefined;
|
|
61
51
|
/**
|
|
62
52
|
* Create a copy of this color with a different alpha value.
|
|
63
53
|
*/
|
|
@@ -68,5 +58,4 @@ export declare class TextmodeColor {
|
|
|
68
58
|
*/
|
|
69
59
|
static $isColor(value: unknown): value is TextmodeColor;
|
|
70
60
|
}
|
|
71
|
-
export type ColorLike = TextmodeColor | string | number | [number, number, number] | [number, number, number, number];
|
|
72
61
|
export {};
|
|
@@ -9,7 +9,7 @@ import { MouseManager } from './managers/MouseManager';
|
|
|
9
9
|
import { KeyboardManager } from './managers/KeyboardManager';
|
|
10
10
|
import { TouchManager } from './managers/TouchManager';
|
|
11
11
|
import type { ITextmodifier } from './interfaces';
|
|
12
|
-
import type { GLFramebuffer,
|
|
12
|
+
import type { GLFramebuffer, GLShader } from '../rendering';
|
|
13
13
|
import type { TextmodeOptions } from './types';
|
|
14
14
|
import type { IAnimationMixin } from './mixins/interfaces/IAnimationMixin';
|
|
15
15
|
import type { IFontMixin } from './mixins/interfaces/IFontMixin';
|
|
@@ -40,9 +40,9 @@ export declare class Textmodifier extends Textmodifier_base implements ITextmodi
|
|
|
40
40
|
_keyboardManager: KeyboardManager;
|
|
41
41
|
_loading: LoadingScreenManager;
|
|
42
42
|
_textmodeDrawFramebuffer: GLFramebuffer;
|
|
43
|
-
_textmodeConversionShader:
|
|
43
|
+
_textmodeConversionShader: GLShader;
|
|
44
44
|
_textmodeFramebuffer: GLFramebuffer;
|
|
45
|
-
_presentShader:
|
|
45
|
+
_presentShader: GLShader;
|
|
46
46
|
private _pluginManager;
|
|
47
47
|
private _destroyRequested;
|
|
48
48
|
private _isRenderingFrame;
|
|
@@ -55,7 +55,7 @@ export declare class Textmodifier extends Textmodifier_base implements ITextmodi
|
|
|
55
55
|
private _resizeObserver?;
|
|
56
56
|
private _isOverlay;
|
|
57
57
|
private _targetCanvasImage?;
|
|
58
|
-
|
|
58
|
+
_sources: Set<TextmodeSource>;
|
|
59
59
|
/**
|
|
60
60
|
* Create a new Textmodifier instance.
|
|
61
61
|
* @param opts Configuration options for the Textmodifier instance.
|
|
@@ -85,7 +85,6 @@ export declare class Textmodifier extends Textmodifier_base implements ITextmodi
|
|
|
85
85
|
get overlay(): TextmodeImage | undefined;
|
|
86
86
|
get loading(): LoadingScreenManager;
|
|
87
87
|
$registerSource(source: TextmodeSource): void;
|
|
88
|
-
$notifyFontChange(): void;
|
|
89
88
|
}
|
|
90
89
|
export interface Textmodifier extends IRenderingMixin, IFontMixin, IAnimationMixin, IMouseMixin, ITouchMixin, IKeyboardMixin {
|
|
91
90
|
}
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { GLShader } from '../../rendering';
|
|
2
2
|
import type { GLRenderer } from '../../rendering/webgl/core/Renderer';
|
|
3
3
|
import type { TextmodeFont } from '../loadables/font/TextmodeFont';
|
|
4
4
|
import type { TextmodeSource } from '../loadables/TextmodeSource';
|
|
5
|
+
/**
|
|
6
|
+
* Type representing the available textmode conversion modes
|
|
7
|
+
* @ignore
|
|
8
|
+
*/
|
|
5
9
|
export type TextmodeConversionMode = 'brightness' | 'accurate' | (string & {});
|
|
10
|
+
/**
|
|
11
|
+
* Interface for the context provided to conversion strategies
|
|
12
|
+
* @ignore
|
|
13
|
+
*/
|
|
6
14
|
export interface TextmodeConversionContext {
|
|
7
15
|
renderer: GLRenderer;
|
|
8
16
|
gl: WebGL2RenderingContext;
|
|
@@ -11,11 +19,31 @@ export interface TextmodeConversionContext {
|
|
|
11
19
|
gridWidth: number;
|
|
12
20
|
gridHeight: number;
|
|
13
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Interface for a textmode conversion strategy
|
|
24
|
+
* @ignore
|
|
25
|
+
*/
|
|
14
26
|
export interface TextmodeConversionStrategy {
|
|
15
27
|
readonly id: TextmodeConversionMode;
|
|
16
|
-
createShader(context: TextmodeConversionContext):
|
|
28
|
+
createShader(context: TextmodeConversionContext): GLShader;
|
|
17
29
|
createUniforms(context: TextmodeConversionContext): Record<string, any>;
|
|
18
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Register a conversion strategy
|
|
33
|
+
* @param strategy The conversion strategy to register
|
|
34
|
+
* @ignore
|
|
35
|
+
*/
|
|
19
36
|
export declare function registerConversionStrategy(strategy: TextmodeConversionStrategy): void;
|
|
37
|
+
/**
|
|
38
|
+
* Unregister a conversion strategy by its ID
|
|
39
|
+
* @param id The ID of the conversion strategy to unregister
|
|
40
|
+
* @ignore
|
|
41
|
+
*/
|
|
20
42
|
export declare function unregisterConversionStrategy(id: TextmodeConversionMode): void;
|
|
43
|
+
/**
|
|
44
|
+
* Get a registered conversion strategy by its ID
|
|
45
|
+
* @param id The ID of the conversion strategy
|
|
46
|
+
* @returns The conversion strategy, or undefined if not found
|
|
47
|
+
* @ignore
|
|
48
|
+
*/
|
|
21
49
|
export declare function getConversionStrategy(id: TextmodeConversionMode): TextmodeConversionStrategy | undefined;
|
|
@@ -4,7 +4,7 @@ import type { TextmodeImage } from '../loadables/TextmodeImage';
|
|
|
4
4
|
import type { TextmodeSource } from '../loadables/TextmodeSource';
|
|
5
5
|
import type { TextmodeCanvas } from '../Canvas';
|
|
6
6
|
import type { AnimationController } from '../AnimationController';
|
|
7
|
-
import type { GLFramebuffer,
|
|
7
|
+
import type { GLFramebuffer, GLShader } from '../../rendering';
|
|
8
8
|
import type { GLRenderer } from '../../rendering/webgl/core/Renderer';
|
|
9
9
|
import type { MouseManager } from '../managers/MouseManager';
|
|
10
10
|
import type { KeyboardManager } from '../managers/KeyboardManager';
|
|
@@ -44,17 +44,17 @@ export interface ITextmodifier extends IRenderingMixin, IFontMixin, IAnimationMi
|
|
|
44
44
|
/** Framebuffer used for offscreen rendering @ignore */
|
|
45
45
|
readonly _textmodeDrawFramebuffer: GLFramebuffer;
|
|
46
46
|
/** Shader used for converting pixels to textmode grid format @ignore */
|
|
47
|
-
readonly _textmodeConversionShader:
|
|
47
|
+
readonly _textmodeConversionShader: GLShader;
|
|
48
48
|
/** Framebuffer used for textmode conversion @ignore */
|
|
49
49
|
readonly _textmodeFramebuffer: GLFramebuffer;
|
|
50
50
|
/** Shader used for final presentation to the screen @ignore */
|
|
51
|
-
readonly _presentShader:
|
|
51
|
+
readonly _presentShader: GLShader;
|
|
52
52
|
/** Loading screen manager for boot-time UX @ignore */
|
|
53
53
|
readonly _loading: LoadingScreenManager;
|
|
54
|
+
/** Sources registered for rendering @ignore */
|
|
55
|
+
readonly _sources: Set<TextmodeSource>;
|
|
54
56
|
/** @ignore */
|
|
55
57
|
$registerSource(source: TextmodeSource): void;
|
|
56
|
-
/** @ignore */
|
|
57
|
-
$notifyFontChange(): void;
|
|
58
58
|
/** Main render method @ignore */
|
|
59
59
|
$render(): void;
|
|
60
60
|
/**
|
|
@@ -43,6 +43,6 @@ export declare class TextmodeImage extends TextmodeSource {
|
|
|
43
43
|
* Texture parameters use NEAREST and CLAMP to align with grid sampling.
|
|
44
44
|
* @ignore
|
|
45
45
|
*/
|
|
46
|
-
static $fromSource(renderer: GLRenderer, font: TextmodeFont, source: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, gridCols: number, gridRows: number
|
|
46
|
+
static $fromSource(renderer: GLRenderer, font: TextmodeFont, source: HTMLImageElement | HTMLCanvasElement | HTMLVideoElement, gridCols: number, gridRows: number): TextmodeImage;
|
|
47
47
|
protected $getActiveTexture(): WebGLTexture;
|
|
48
48
|
}
|
|
@@ -3,11 +3,7 @@ import type { Material } from '../../rendering/webgl/materials/Material';
|
|
|
3
3
|
import { TextmodeColor } from '../TextmodeColor';
|
|
4
4
|
import type { TextmodeFont } from './font/TextmodeFont';
|
|
5
5
|
import { type TextmodeConversionMode } from '../conversion';
|
|
6
|
-
export interface TextmodeConversionOptions {
|
|
7
|
-
sampleRate?: number;
|
|
8
|
-
}
|
|
9
6
|
type GlyphColor = [number, number, number];
|
|
10
|
-
export type TextmodeColorFilterInput = TextmodeColor | string | [number, number, number] | [number, number, number, number];
|
|
11
7
|
/**
|
|
12
8
|
* Base class for drawable textmode sources (images, videos, canvas, etc.).
|
|
13
9
|
* Handles shared WebGL texture state, material creation, and color/character settings.
|
|
@@ -34,7 +30,6 @@ export declare abstract class TextmodeSource {
|
|
|
34
30
|
protected _cellColor: [number, number, number, number];
|
|
35
31
|
protected _backgroundColor: [number, number, number, number];
|
|
36
32
|
protected _glyphColors: GlyphColor[];
|
|
37
|
-
protected _glyphColorResolver: (s: string) => GlyphColor[];
|
|
38
33
|
private _characterString;
|
|
39
34
|
private _disposeListeners;
|
|
40
35
|
private _colorFilterPalette;
|
|
@@ -42,7 +37,11 @@ export declare abstract class TextmodeSource {
|
|
|
42
37
|
protected constructor(gl: WebGL2RenderingContext, renderer: GLRenderer, texture: WebGLTexture, font: TextmodeFont, originalWidth: number, originalHeight: number, width: number, height: number);
|
|
43
38
|
/**
|
|
44
39
|
* Select the conversion mode for this source.
|
|
45
|
-
*
|
|
40
|
+
*
|
|
41
|
+
* `textmode.js` includes only a single built-in conversion strategy `'brightness'`.
|
|
42
|
+
*
|
|
43
|
+
* Additional conversion strategies may be provided via add-on libraries.
|
|
44
|
+
*
|
|
46
45
|
* @param mode Conversion mode to use.
|
|
47
46
|
*/
|
|
48
47
|
conversionMode(mode: TextmodeConversionMode): this;
|
|
@@ -51,6 +50,11 @@ export declare abstract class TextmodeSource {
|
|
|
51
50
|
* @ignore
|
|
52
51
|
*/
|
|
53
52
|
$dispose(): void;
|
|
53
|
+
/**
|
|
54
|
+
* Register a callback to be invoked when this source is disposed.
|
|
55
|
+
* @param callback The callback function to register
|
|
56
|
+
* @ignore
|
|
57
|
+
*/
|
|
54
58
|
$onDispose(callback: () => void): void;
|
|
55
59
|
/**
|
|
56
60
|
* Set the invert flag, swapping character and cell colors when enabled.
|
|
@@ -123,7 +127,7 @@ export declare abstract class TextmodeSource {
|
|
|
123
127
|
* @param palette A list of colors defined as {@link TextmodeColor} instances, hex strings, or RGBA tuples (0-255).
|
|
124
128
|
* Providing an empty array or `null` disables the filter.
|
|
125
129
|
*/
|
|
126
|
-
colorFilter(palette?:
|
|
130
|
+
colorFilter(palette?: TextmodeColor[] | string[] | [number, number, number][] | [number, number, number, number][] | null): this;
|
|
127
131
|
/**
|
|
128
132
|
* Define the characters to use for brightness mapping as a string.
|
|
129
133
|
* Maximum length is 255; excess characters are ignored.
|
|
@@ -131,6 +135,11 @@ export declare abstract class TextmodeSource {
|
|
|
131
135
|
* @returns This instance for chaining.
|
|
132
136
|
*/
|
|
133
137
|
characters(chars: string): this;
|
|
138
|
+
/**
|
|
139
|
+
* Handle font change notification from the Textmodifier.
|
|
140
|
+
* @param font The new font
|
|
141
|
+
* @ignore
|
|
142
|
+
*/
|
|
134
143
|
$handleFontChange(font: TextmodeFont): void;
|
|
135
144
|
/** Return the WebGL texture currently backing this source. */
|
|
136
145
|
get texture(): WebGLTexture;
|
|
@@ -154,6 +163,11 @@ export declare abstract class TextmodeSource {
|
|
|
154
163
|
private _updateMaterial;
|
|
155
164
|
private _setColor;
|
|
156
165
|
private _applyCharacterPalette;
|
|
166
|
+
/**
|
|
167
|
+
* Create base conversion uniforms shared across all strategies.
|
|
168
|
+
* @returns Uniforms object
|
|
169
|
+
* @ignore
|
|
170
|
+
*/
|
|
157
171
|
createBaseConversionUniforms(): Record<string, any>;
|
|
158
172
|
private _getActiveConversionStrategy;
|
|
159
173
|
private _createConversionContext;
|
|
@@ -9,11 +9,15 @@ export declare class CharacterColorMapper {
|
|
|
9
9
|
constructor();
|
|
10
10
|
/**
|
|
11
11
|
* Creates TextmodeCharacter objects with unique color assignments.
|
|
12
|
+
* Returns both an array (for public API and iteration) and a Map (for O(1) lookups).
|
|
12
13
|
* @param characters Array of character strings
|
|
13
14
|
* @param font The parsed font object from Typr
|
|
14
|
-
* @returns
|
|
15
|
+
* @returns Object containing both array and map of TextmodeCharacter objects
|
|
15
16
|
*/
|
|
16
|
-
createCharacterObjects(characters: string[], font: TyprFont):
|
|
17
|
+
$createCharacterObjects(characters: string[], font: TyprFont): {
|
|
18
|
+
array: TextmodeCharacter[];
|
|
19
|
+
map: Map<string, TextmodeCharacter>;
|
|
20
|
+
};
|
|
17
21
|
/**
|
|
18
22
|
* Generates a unique RGB color for a character based on its index.
|
|
19
23
|
* @param index The index of the character
|
|
@@ -21,17 +25,10 @@ export declare class CharacterColorMapper {
|
|
|
21
25
|
*/
|
|
22
26
|
private _generateCharacterColor;
|
|
23
27
|
/**
|
|
24
|
-
* Gets
|
|
25
|
-
* @param
|
|
26
|
-
* @param
|
|
27
|
-
* @returns
|
|
28
|
-
*/
|
|
29
|
-
$getCharacterColor(character: string, characters: TextmodeCharacter[]): [number, number, number];
|
|
30
|
-
/**
|
|
31
|
-
* Gets colors for multiple characters.
|
|
32
|
-
* @param characterString String of characters to get colors for
|
|
33
|
-
* @param characters Array of TextmodeCharacter objects
|
|
34
|
-
* @returns Array of RGB colors for each character
|
|
28
|
+
* Gets glyph data for a character including advance width and path information.
|
|
29
|
+
* @param font The parsed font object from Typr
|
|
30
|
+
* @param character Character to get glyph data for
|
|
31
|
+
* @returns Parsed glyph data with advance width, or null if not found
|
|
35
32
|
*/
|
|
36
|
-
|
|
33
|
+
private _getGlyphData;
|
|
37
34
|
}
|
|
@@ -20,8 +20,4 @@ export declare class FontMetricsCalculator {
|
|
|
20
20
|
* @returns Object containing width and height dimensions
|
|
21
21
|
*/
|
|
22
22
|
$calculateMaxGlyphDimensions(characters: string[], fontSize: number, font: TyprFont): GlyphDimensions;
|
|
23
|
-
/**
|
|
24
|
-
* Clears internal caches. Useful for memory management.
|
|
25
|
-
*/
|
|
26
|
-
$clearCache(): void;
|
|
27
23
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { GLRenderer } from '../../../rendering/webgl/core/Renderer.ts';
|
|
2
2
|
import type { GLFramebuffer } from '../../../rendering/webgl/core/Framebuffer.ts';
|
|
3
3
|
import type { TextmodeCharacter } from './types.ts';
|
|
4
|
-
import type { TyprFont
|
|
4
|
+
import type { TyprFont } from './typr/types.ts';
|
|
5
5
|
/**
|
|
6
6
|
* Manages the font used for rendering characters via {@link Textmodifier.loadFont}.
|
|
7
7
|
*
|
|
@@ -14,13 +14,13 @@ import type { TyprFont, GlyphData } from './typr/types.ts';
|
|
|
14
14
|
export declare class TextmodeFont {
|
|
15
15
|
private _font;
|
|
16
16
|
private _characters;
|
|
17
|
+
private _characterMap;
|
|
17
18
|
private _fontFramebuffer;
|
|
18
19
|
private _fontSize;
|
|
19
20
|
private _textureColumns;
|
|
20
21
|
private _textureRows;
|
|
21
22
|
private _maxGlyphDimensions;
|
|
22
23
|
private _fontFace;
|
|
23
|
-
private _glyphCache;
|
|
24
24
|
private _characterExtractor;
|
|
25
25
|
private _textureAtlas;
|
|
26
26
|
private _metricsCalculator;
|
|
@@ -62,41 +62,29 @@ export declare class TextmodeFont {
|
|
|
62
62
|
*/
|
|
63
63
|
private _initializeFont;
|
|
64
64
|
/**
|
|
65
|
-
* Get the color associated with a character.
|
|
65
|
+
* Get the color associated with a character using O(1) Map lookup.
|
|
66
66
|
* @param character The character to get the color for.
|
|
67
67
|
* @returns The RGB color as an array `[r, g, b]`.
|
|
68
68
|
* @ignore
|
|
69
69
|
*/
|
|
70
70
|
$getCharacterColor(character: string): [number, number, number];
|
|
71
71
|
/**
|
|
72
|
-
* Get the colors associated with a string of characters.
|
|
72
|
+
* Get the colors associated with a string of characters using O(1) Map lookups.
|
|
73
73
|
* @param characters The string of characters to get colors for.
|
|
74
74
|
* @returns An array of RGB colors for each character in the string.
|
|
75
75
|
* Each color is represented as an array `[r, g, b]`.
|
|
76
76
|
* @ignore
|
|
77
77
|
*/
|
|
78
78
|
$getCharacterColors(characters: string): [number, number, number][];
|
|
79
|
-
/**
|
|
80
|
-
* Lazily retrieves glyph data for the given Unicode code point.
|
|
81
|
-
*
|
|
82
|
-
* Glyph data is cached after the first access to avoid repeated Typr parsing.
|
|
83
|
-
*
|
|
84
|
-
* @param codePoint Unicode code point
|
|
85
|
-
* @returns Parsed glyph data or null if unavailable
|
|
86
|
-
* @ignore
|
|
87
|
-
*/
|
|
88
|
-
getGlyphData(codePoint: number): GlyphData | null;
|
|
89
|
-
private _getGlyphIndex;
|
|
90
79
|
/**
|
|
91
80
|
* Dispose of all resources used by this font manager.
|
|
92
81
|
* @ignore
|
|
93
82
|
*/
|
|
94
83
|
$dispose(): void;
|
|
95
|
-
/**
|
|
96
|
-
* Returns the WebGL framebuffer containing the font texture atlas.
|
|
97
|
-
* @ignore
|
|
98
|
-
*/
|
|
84
|
+
/** Returns the WebGL framebuffer containing the font texture atlas. */
|
|
99
85
|
get fontFramebuffer(): GLFramebuffer;
|
|
86
|
+
/** Returns the character map for O(1) lookups. */
|
|
87
|
+
get characterMap(): Map<string, TextmodeCharacter>;
|
|
100
88
|
/** Returns the array of {@link TextmodeCharacter} objects in the font. */
|
|
101
89
|
get characters(): TextmodeCharacter[];
|
|
102
90
|
/** Returns the number of columns in the texture atlas. */
|
|
@@ -8,11 +8,10 @@ import type { TyprFont } from './typr/types.ts';
|
|
|
8
8
|
* Supports both Typr.js path-based rendering for uniform cross-browser text
|
|
9
9
|
* and fallback fillText rendering.
|
|
10
10
|
*/
|
|
11
|
-
export declare class
|
|
11
|
+
export declare class TextureAtlas {
|
|
12
12
|
private _textureCanvas;
|
|
13
13
|
private _textureContext;
|
|
14
14
|
private _renderer;
|
|
15
|
-
private _fontTableReader;
|
|
16
15
|
/**
|
|
17
16
|
* Creates a new TextureAtlasCreation instance.
|
|
18
17
|
* @param renderer The WebGL renderer instance
|
|
@@ -46,13 +45,6 @@ export declare class TextureAtlasCreation {
|
|
|
46
45
|
* @param fontData Typr.js font data
|
|
47
46
|
*/
|
|
48
47
|
private _renderCharacters;
|
|
49
|
-
/**
|
|
50
|
-
* Gets glyph data for a character using Typr.js
|
|
51
|
-
* @param fontData Typr.js font data
|
|
52
|
-
* @param character Character to get glyph data for
|
|
53
|
-
* @returns Parsed glyph data or null if not found
|
|
54
|
-
*/
|
|
55
|
-
private _getGlyphData;
|
|
56
48
|
/**
|
|
57
49
|
* Renders a glyph to the canvas using direct path rendering from glyph outline data.
|
|
58
50
|
* @param glyphData Glyph data from Typr.js
|
|
@@ -3,6 +3,6 @@ export type { TextmodeCharacter, GlyphDimensions } from './types.ts';
|
|
|
3
3
|
export type { TyprFont, CmapTable, CmapTableFormat4, CmapTableFormat12, HeadTable, HheaTable, HmtxTable, MaxpTable, CmapData, GlyphData, LocaTable, TyprStatic } from './typr/types.ts';
|
|
4
4
|
export { default as Typr } from './typr/Typr.ts';
|
|
5
5
|
export { CharacterExtraction } from './CharacterExtractor.ts';
|
|
6
|
-
export { TextureAtlasCreation } from './TextureAtlas.ts';
|
|
6
|
+
export { TextureAtlas as TextureAtlasCreation } from './TextureAtlas.ts';
|
|
7
7
|
export { FontMetricsCalculator as MetricsCalculation } from './MetricsCalculator.ts';
|
|
8
8
|
export { CharacterColorMapper as CharacterColorMapping } from './CharacterColorMapper.ts';
|
|
@@ -1,3 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Glyph outline data for a character
|
|
3
|
+
*/
|
|
4
|
+
export type GlyphData = {
|
|
5
|
+
/** Number of contours (-1 for composite glyphs) */
|
|
6
|
+
noc: number;
|
|
7
|
+
/** Bounding box coordinates */
|
|
8
|
+
xMin: number;
|
|
9
|
+
yMin: number;
|
|
10
|
+
xMax: number;
|
|
11
|
+
yMax: number;
|
|
12
|
+
/** End points of each contour */
|
|
13
|
+
endPts: number[];
|
|
14
|
+
/** Point flags indicating curve/line segments */
|
|
15
|
+
flags: number[];
|
|
16
|
+
/** X coordinates of all points */
|
|
17
|
+
xs: number[];
|
|
18
|
+
/** Y coordinates of all points */
|
|
19
|
+
ys: number[];
|
|
20
|
+
/** Advance width of the character */
|
|
21
|
+
advanceWidth: number;
|
|
22
|
+
/** Composite glyph parts (for composite glyphs) */
|
|
23
|
+
parts?: any[];
|
|
24
|
+
} | null;
|
|
1
25
|
/**
|
|
2
26
|
* Represents a single character in the {@link TextmodeFont.characters} array.
|
|
3
27
|
*/
|
|
@@ -8,8 +32,8 @@ export type TextmodeCharacter = {
|
|
|
8
32
|
unicode: number;
|
|
9
33
|
/** The shader color associated with the character. */
|
|
10
34
|
color: [number, number, number];
|
|
11
|
-
/**
|
|
12
|
-
|
|
35
|
+
/** Glyph outline data including advance width and path information. */
|
|
36
|
+
glyphData: GlyphData;
|
|
13
37
|
};
|
|
14
38
|
/**
|
|
15
39
|
* Font glyph dimensions
|
|
@@ -1,15 +1,12 @@
|
|
|
1
1
|
import type { TyprFont } from '../typr/types.ts';
|
|
2
2
|
/**
|
|
3
3
|
* Centralized font table reader that eliminates redundant font data access.
|
|
4
|
-
* Provides
|
|
4
|
+
* Provides access to font tables and metrics with consistent error handling.
|
|
5
5
|
*/
|
|
6
6
|
export declare class FontTableReader {
|
|
7
|
-
private _glyphIndexCache;
|
|
8
|
-
private _cmapTableCache;
|
|
9
7
|
/**
|
|
10
8
|
* Gets the glyph index for a given Unicode code point.
|
|
11
9
|
* Searches through all available cmap tables to find the character.
|
|
12
|
-
* Results are cached per font and character.
|
|
13
10
|
*/
|
|
14
11
|
$getGlyphIndex(font: TyprFont, codePoint: number): number;
|
|
15
12
|
/**
|
|
@@ -32,14 +29,6 @@ export declare class FontTableReader {
|
|
|
32
29
|
unitsPerEm: number;
|
|
33
30
|
scale: number;
|
|
34
31
|
};
|
|
35
|
-
/**
|
|
36
|
-
* Clears all caches. Useful when fonts are updated or memory needs to be freed.
|
|
37
|
-
*/
|
|
38
|
-
$clearCache(): void;
|
|
39
|
-
/**
|
|
40
|
-
* Gets a unique identifier for a font based on its data offset and length.
|
|
41
|
-
*/
|
|
42
|
-
private _getFontId;
|
|
43
32
|
/**
|
|
44
33
|
* Gets glyph index from format 4 cmap table (BMP Unicode).
|
|
45
34
|
*/
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export { TextmodeImage } from './TextmodeImage';
|
|
2
|
-
export { TextmodeVideo } from './TextmodeVideo';
|
|
3
|
-
export { TextmodeSource } from './TextmodeSource';
|
|
2
|
+
export { TextmodeVideo } from './video/TextmodeVideo';
|
|
4
3
|
export { TextmodeFont } from './font/TextmodeFont';
|
|
5
4
|
export type { TextmodeCharacter } from './font/types';
|
|
6
|
-
export type { TextmodeVideoOptions } from './TextmodeVideo';
|
|
7
|
-
export type { TextmodeConversionOptions } from './TextmodeSource';
|
|
5
|
+
export type { TextmodeVideoOptions } from './video/TextmodeVideo';
|
|
8
6
|
export type { TextmodeConversionMode } from '../conversion';
|