@unmade/text-renderer 1.0.0 → 1.1.1
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/__vite-browser-external-CijFC1_R.js +7 -0
- package/dist/baselines/index.d.ts +40 -0
- package/dist/ce-adapter/index.cjs +1 -1
- package/dist/ce-adapter/index.js +154 -152
- package/dist/chunk-3b4jIN3o.js +13 -0
- package/dist/constants.d.ts +5 -0
- package/dist/glyph/svg-glyph-converter.d.ts +42 -0
- package/dist/helpers/bbox.d.ts +33 -0
- package/dist/helpers/matrix.d.ts +8 -0
- package/dist/helpers/point.d.ts +17 -0
- package/dist/helpers/xml.d.ts +1 -0
- package/dist/index.d.ts +16 -249
- package/dist/index.js +1543 -1954
- package/dist/loading/createLoadedFont.d.ts +53 -0
- package/dist/loading/index.d.ts +4 -0
- package/dist/measuring/conversion.d.ts +2 -0
- package/dist/measuring/index.d.ts +28 -0
- package/dist/node/baselines/index.d.ts +40 -0
- package/dist/node/ce-adapter/ce-types.d.ts +171 -0
- package/dist/node/ce-adapter/extractTextPlacements.d.ts +11 -0
- package/dist/node/ce-adapter/index.d.ts +12 -0
- package/dist/node/ce-adapter/mapStateToRendererOptions.d.ts +13 -0
- package/dist/node/ce-adapter/types.d.ts +56 -0
- package/dist/node/constants.d.ts +5 -0
- package/dist/node/glyph/svg-glyph-converter.d.ts +42 -0
- package/dist/node/helpers/bbox.d.ts +33 -0
- package/dist/node/helpers/matrix.d.ts +8 -0
- package/dist/node/helpers/point.d.ts +17 -0
- package/dist/node/helpers/xml.d.ts +1 -0
- package/dist/node/index.d.ts +16 -249
- package/dist/node/index.js +821 -895
- package/dist/node/loading/createLoadedFont.d.ts +53 -0
- package/dist/node/loading/index.d.ts +4 -0
- package/dist/node/measuring/conversion.d.ts +2 -0
- package/dist/node/measuring/index.d.ts +28 -0
- package/dist/node/renderText.d.ts +5 -0
- package/dist/node/rendering/index.d.ts +42 -0
- package/dist/node/svg/index.d.ts +11 -0
- package/dist/node/types.d.ts +72 -0
- package/dist/renderText.d.ts +5 -0
- package/dist/rendering/index.d.ts +42 -0
- package/dist/svg/index.d.ts +11 -0
- package/dist/types.d.ts +72 -0
- package/dist/worker/baselines/index.d.ts +40 -0
- package/dist/worker/ce-adapter/ce-types.d.ts +171 -0
- package/dist/worker/ce-adapter/extractTextPlacements.d.ts +11 -0
- package/dist/worker/ce-adapter/index.d.ts +12 -0
- package/dist/worker/ce-adapter/mapStateToRendererOptions.d.ts +13 -0
- package/dist/worker/ce-adapter/types.d.ts +56 -0
- package/dist/worker/constants.d.ts +5 -0
- package/dist/worker/glyph/svg-glyph-converter.d.ts +42 -0
- package/dist/worker/helpers/bbox.d.ts +33 -0
- package/dist/worker/helpers/matrix.d.ts +8 -0
- package/dist/worker/helpers/point.d.ts +17 -0
- package/dist/worker/helpers/xml.d.ts +1 -0
- package/dist/worker/index.d.ts +16 -249
- package/dist/worker/index.js +8003 -9677
- package/dist/worker/loading/createLoadedFont.d.ts +53 -0
- package/dist/worker/loading/index.d.ts +4 -0
- package/dist/worker/measuring/conversion.d.ts +2 -0
- package/dist/worker/measuring/index.d.ts +28 -0
- package/dist/worker/renderText.d.ts +5 -0
- package/dist/worker/rendering/index.d.ts +42 -0
- package/dist/worker/svg/index.d.ts +11 -0
- package/dist/worker/types.d.ts +72 -0
- package/package.json +11 -10
- package/dist/__vite-browser-external-l0sNRNKZ.js +0 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Face, Font } from 'harfbuzzjs';
|
|
2
|
+
export interface SVGGlyphData {
|
|
3
|
+
svg: string;
|
|
4
|
+
viewbox: string;
|
|
5
|
+
}
|
|
6
|
+
export interface LoadedFont {
|
|
7
|
+
unitsPerEm: number;
|
|
8
|
+
names: {
|
|
9
|
+
fontFamily: string;
|
|
10
|
+
};
|
|
11
|
+
svgGlyphs?: Map<number, SVGGlyphData>;
|
|
12
|
+
charToGlyph(char: string): {
|
|
13
|
+
index: number;
|
|
14
|
+
advanceWidth: number;
|
|
15
|
+
name: string;
|
|
16
|
+
getBoundingBox(): {
|
|
17
|
+
x1: number;
|
|
18
|
+
y1: number;
|
|
19
|
+
x2: number;
|
|
20
|
+
y2: number;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
getPath(text: string, x: number, y: number, fontSize: number, options?: {
|
|
24
|
+
drawSVG?: boolean;
|
|
25
|
+
}): {
|
|
26
|
+
getBoundingBox(): {
|
|
27
|
+
x1: number;
|
|
28
|
+
y1: number;
|
|
29
|
+
x2: number;
|
|
30
|
+
y2: number;
|
|
31
|
+
};
|
|
32
|
+
toPathData(decimals?: number): string;
|
|
33
|
+
};
|
|
34
|
+
getPaths(text: string, x: number, y: number, fontSize: number, options?: {
|
|
35
|
+
drawSVG?: boolean;
|
|
36
|
+
}): Array<{
|
|
37
|
+
getBoundingBox(): {
|
|
38
|
+
x1: number;
|
|
39
|
+
y1: number;
|
|
40
|
+
x2: number;
|
|
41
|
+
y2: number;
|
|
42
|
+
};
|
|
43
|
+
toPathData(decimals?: number): string;
|
|
44
|
+
}>;
|
|
45
|
+
}
|
|
46
|
+
export declare function boundsFromPath(pathData: string): {
|
|
47
|
+
x1: number;
|
|
48
|
+
y1: number;
|
|
49
|
+
x2: number;
|
|
50
|
+
y2: number;
|
|
51
|
+
} | null;
|
|
52
|
+
export declare function transformPath(pathData: string, scaleX: number, scaleY: number, dx: number): string;
|
|
53
|
+
export declare function createLoadedFont(face: Face, font: Font, familyName: string, svgGlyphs?: Map<number, SVGGlyphData>): LoadedFont;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { createLoadedFont, LoadedFont } from './createLoadedFont';
|
|
2
|
+
export { createLoadedFont, type LoadedFont };
|
|
3
|
+
export declare const getFontCache: () => Map<string, LoadedFont>;
|
|
4
|
+
export declare const loadFont: (fontUrl: string, fetchSVGGlyphs?: boolean) => Promise<LoadedFont>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { LoadedFont } from '../loading';
|
|
2
|
+
import { BoxDimensions, PhysicalSize, TextSpacing } from '../types';
|
|
3
|
+
export interface GetFontSizeFromPhysicalSizeOptions {
|
|
4
|
+
font: LoadedFont;
|
|
5
|
+
boxDimensions: BoxDimensions;
|
|
6
|
+
physicalSize: PhysicalSize;
|
|
7
|
+
spacing?: TextSpacing;
|
|
8
|
+
}
|
|
9
|
+
export interface GetTextMetricsAtFontSizeOptions {
|
|
10
|
+
font: LoadedFont;
|
|
11
|
+
text: string;
|
|
12
|
+
fontSize: number;
|
|
13
|
+
spacing?: TextSpacing;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* This is the character we use to calculate font sizes
|
|
17
|
+
* when fixed physical text height is set for a placement.
|
|
18
|
+
*
|
|
19
|
+
* The 'I' character is used because of its flat top and bottom.
|
|
20
|
+
* https://en.wikipedia.org/wiki/Cap_height
|
|
21
|
+
*/
|
|
22
|
+
export declare const getStandardCharacter: (font: LoadedFont) => string;
|
|
23
|
+
export declare const getFontSizeFromPhysicalSize: ({ font, boxDimensions, physicalSize, spacing, }: GetFontSizeFromPhysicalSizeOptions) => number;
|
|
24
|
+
export declare const getTextMetricsAtFontSize: ({ font, text, fontSize, spacing, }: GetTextMetricsAtFontSizeOptions) => {
|
|
25
|
+
width: number;
|
|
26
|
+
height: number;
|
|
27
|
+
baseline: number;
|
|
28
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { BaselineConfig, BaselineType, BoxDimensions, VerticalTextAlignmentValues } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Normalise a baseline option (string shorthand or object) into a BaselineConfig.
|
|
4
|
+
*/
|
|
5
|
+
export declare const normaliseBaselineOption: (baseline: BaselineType | BaselineConfig | undefined) => BaselineConfig;
|
|
6
|
+
/**
|
|
7
|
+
* Validate a custom baseline SVG path string.
|
|
8
|
+
*/
|
|
9
|
+
export declare const validateCustomBaselinePath: (path: string) => void;
|
|
10
|
+
export interface GenerateFlatBaselineOptions {
|
|
11
|
+
boxDimensions: BoxDimensions;
|
|
12
|
+
totalTextHeight: number;
|
|
13
|
+
baseline: number;
|
|
14
|
+
lineHeight: number;
|
|
15
|
+
verticalAlignment?: VerticalTextAlignmentValues;
|
|
16
|
+
lineNumber?: number;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Generate a path as a baseline for straight text
|
|
20
|
+
* This can be called multiple times for multiline text by incrementing the lineNumber parameter
|
|
21
|
+
*
|
|
22
|
+
* @returns an SVG path command to draw the baseline
|
|
23
|
+
*/
|
|
24
|
+
export declare const generateFlatBaseline: ({ boxDimensions, totalTextHeight, baseline, lineHeight, verticalAlignment, lineNumber, }: GenerateFlatBaselineOptions) => string;
|
|
25
|
+
export interface GenerateCurvedBaselineOptions {
|
|
26
|
+
boxDimensions: BoxDimensions;
|
|
27
|
+
baseline: number;
|
|
28
|
+
textHeight: number;
|
|
29
|
+
verticalAlignment: VerticalTextAlignmentValues;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Generate a path command to curve text and align that text to the top of the box.
|
|
33
|
+
* Uses two quadratic bezier curves — one from the bottom left to the peak, and a
|
|
34
|
+
* second mirrored from the peak to the end.
|
|
35
|
+
*
|
|
36
|
+
* Curved text is not currently supported for multiline text.
|
|
37
|
+
*
|
|
38
|
+
* @returns an SVG path command to draw the curve
|
|
39
|
+
*/
|
|
40
|
+
export declare const generateCurvedBaseline: ({ boxDimensions, baseline, textHeight, verticalAlignment, }: GenerateCurvedBaselineOptions) => string;
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type declarations for @unmade/configuration-engine
|
|
3
|
+
*
|
|
4
|
+
* CE doesn't ship .d.ts files. These types cover the subset of the
|
|
5
|
+
* factory API and editor shape that the CE adapter needs.
|
|
6
|
+
*/
|
|
7
|
+
export interface EditorPaletteColour {
|
|
8
|
+
id: number;
|
|
9
|
+
hex: string;
|
|
10
|
+
name: string;
|
|
11
|
+
display_name?: string;
|
|
12
|
+
reference?: string | null;
|
|
13
|
+
extra?: object | null;
|
|
14
|
+
categories?: string[];
|
|
15
|
+
lab?: [number, number, number];
|
|
16
|
+
}
|
|
17
|
+
export interface EditorPalette {
|
|
18
|
+
id: number;
|
|
19
|
+
name: string;
|
|
20
|
+
slug: string;
|
|
21
|
+
colours: EditorPaletteColour[];
|
|
22
|
+
extended_palette_id?: number;
|
|
23
|
+
extendedPalette?: EditorPalette;
|
|
24
|
+
categories?: string[];
|
|
25
|
+
}
|
|
26
|
+
export interface EditorGarment {
|
|
27
|
+
slug: string;
|
|
28
|
+
size: string;
|
|
29
|
+
name?: string;
|
|
30
|
+
panels_svg?: string;
|
|
31
|
+
embellishment_positions?: EmbellishmentPosition[];
|
|
32
|
+
}
|
|
33
|
+
export interface EmbellishmentPosition {
|
|
34
|
+
placement: string;
|
|
35
|
+
width: number;
|
|
36
|
+
height: number;
|
|
37
|
+
physical_width?: number;
|
|
38
|
+
physical_height?: number;
|
|
39
|
+
physical_width_decimal: number;
|
|
40
|
+
physical_height_decimal: number;
|
|
41
|
+
physical_size_units: string;
|
|
42
|
+
baseline_path?: string;
|
|
43
|
+
rotation: number;
|
|
44
|
+
variant?: string;
|
|
45
|
+
}
|
|
46
|
+
export interface TextLibraryItemFont {
|
|
47
|
+
id: number;
|
|
48
|
+
font_url: string;
|
|
49
|
+
font_family: string;
|
|
50
|
+
letter_spacing?: number;
|
|
51
|
+
letter_spacing_outline?: number;
|
|
52
|
+
outline_width?: number;
|
|
53
|
+
fixed_colours?: Record<string, {
|
|
54
|
+
reference: string;
|
|
55
|
+
hex: string;
|
|
56
|
+
id: string;
|
|
57
|
+
text: string;
|
|
58
|
+
}>;
|
|
59
|
+
}
|
|
60
|
+
export interface TextLibraryItem {
|
|
61
|
+
id: string;
|
|
62
|
+
type: 'text';
|
|
63
|
+
fonts: TextLibraryItemFont[];
|
|
64
|
+
palette?: number;
|
|
65
|
+
}
|
|
66
|
+
export interface PlacementLibraryItem {
|
|
67
|
+
id: string;
|
|
68
|
+
type: string;
|
|
69
|
+
palette?: number;
|
|
70
|
+
}
|
|
71
|
+
export interface BasePlacementSettings {
|
|
72
|
+
manufacturing_methods?: {
|
|
73
|
+
name: string;
|
|
74
|
+
}[];
|
|
75
|
+
vertical_alignment?: string;
|
|
76
|
+
horizontal_alignment?: string;
|
|
77
|
+
}
|
|
78
|
+
export interface PlacementsSettings {
|
|
79
|
+
byId: Record<string, BasePlacementSettings>;
|
|
80
|
+
library: Record<string, PlacementLibraryItem | TextLibraryItem>;
|
|
81
|
+
}
|
|
82
|
+
export interface CombinedEditorSettings {
|
|
83
|
+
editor: string;
|
|
84
|
+
mixins: string[];
|
|
85
|
+
garments: EditorGarment[];
|
|
86
|
+
palettes: number[];
|
|
87
|
+
allPalettes: Record<number, EditorPalette>;
|
|
88
|
+
endpoints: {
|
|
89
|
+
palettes: string;
|
|
90
|
+
[key: string]: string | undefined;
|
|
91
|
+
};
|
|
92
|
+
placements?: PlacementsSettings;
|
|
93
|
+
embellishments?: PlacementsSettings;
|
|
94
|
+
[key: string]: unknown;
|
|
95
|
+
}
|
|
96
|
+
export interface BasePlacementState {
|
|
97
|
+
type: string;
|
|
98
|
+
libraryItemID: string;
|
|
99
|
+
meta?: Record<string, unknown>;
|
|
100
|
+
}
|
|
101
|
+
export interface EditorStateVals {
|
|
102
|
+
placements?: Record<string, BasePlacementState>;
|
|
103
|
+
embellishments?: Record<string, BasePlacementState>;
|
|
104
|
+
[key: string]: unknown;
|
|
105
|
+
}
|
|
106
|
+
export interface EditorState {
|
|
107
|
+
garment?: string;
|
|
108
|
+
vals?: EditorStateVals;
|
|
109
|
+
[key: string]: unknown;
|
|
110
|
+
}
|
|
111
|
+
export interface Palettes {
|
|
112
|
+
byId: Record<string, unknown>;
|
|
113
|
+
getColours(paletteId: number): EditorPaletteColour[];
|
|
114
|
+
getUsedColours(paletteId: number, ids: (number | null)[]): (EditorPaletteColour | null)[];
|
|
115
|
+
getExtendedColours(paletteId: number): EditorPaletteColour[];
|
|
116
|
+
}
|
|
117
|
+
export interface PlacementPositionResult {
|
|
118
|
+
placement: string;
|
|
119
|
+
x: number;
|
|
120
|
+
y: number;
|
|
121
|
+
width: number;
|
|
122
|
+
height: number;
|
|
123
|
+
dimensionsForCanvas: {
|
|
124
|
+
width: number;
|
|
125
|
+
height: number;
|
|
126
|
+
x: number;
|
|
127
|
+
y: number;
|
|
128
|
+
};
|
|
129
|
+
variant: string;
|
|
130
|
+
panel: string;
|
|
131
|
+
rotation: boolean;
|
|
132
|
+
physical_width: number;
|
|
133
|
+
physical_height: number;
|
|
134
|
+
physical_width_decimal: string;
|
|
135
|
+
physical_height_decimal: string;
|
|
136
|
+
physical_size_units: string;
|
|
137
|
+
}
|
|
138
|
+
export interface EditorVariant {
|
|
139
|
+
name: string;
|
|
140
|
+
placements: string[];
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Editor instance returned by CE's factory.
|
|
144
|
+
*
|
|
145
|
+
* The exact shape depends on which mixins are applied at runtime.
|
|
146
|
+
* We type the parts the CE adapter needs and treat the rest as opaque.
|
|
147
|
+
* Uses Element rather than SVGElement for cross-environment compatibility.
|
|
148
|
+
*/
|
|
149
|
+
export interface ConfigEditor {
|
|
150
|
+
getState(): EditorState & {
|
|
151
|
+
vals: NonNullable<EditorState['vals']>;
|
|
152
|
+
};
|
|
153
|
+
palettes: Palettes;
|
|
154
|
+
settings: CombinedEditorSettings;
|
|
155
|
+
placements?: {
|
|
156
|
+
initialise(): Promise<void>;
|
|
157
|
+
getAssetsAsSVGElements(state: EditorState, manufacturingMethod: string): Promise<Record<string, {
|
|
158
|
+
asset: Element;
|
|
159
|
+
position: PlacementPositionResult;
|
|
160
|
+
}>>;
|
|
161
|
+
};
|
|
162
|
+
embellishments?: {
|
|
163
|
+
initialise(): Promise<void>;
|
|
164
|
+
getAssetsAsSVGElements(state: EditorState, manufacturingMethod: string): Promise<Record<string, {
|
|
165
|
+
asset: Element;
|
|
166
|
+
position: PlacementPositionResult;
|
|
167
|
+
}>>;
|
|
168
|
+
};
|
|
169
|
+
getVariants?(): EditorVariant[];
|
|
170
|
+
getCurrentVariant?(): string;
|
|
171
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { ConfigEditor } from './ce-types';
|
|
2
|
+
import { LoadedTextPlacement } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Extract text placements from a loaded config editor instance.
|
|
5
|
+
*
|
|
6
|
+
* Reads the editor state, resolves fonts and colours from settings and
|
|
7
|
+
* palettes, and returns a structured array of text placements ready for
|
|
8
|
+
* rendering or comparison. Processes both the placements and embellishments
|
|
9
|
+
* buckets.
|
|
10
|
+
*/
|
|
11
|
+
export declare function extractTextPlacements(editor: ConfigEditor): LoadedTextPlacement[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CE Adapter for @unmade/text-renderer
|
|
3
|
+
*
|
|
4
|
+
* Utilities for extracting text placement state from a loaded
|
|
5
|
+
* @unmade/configuration-engine editor instance and mapping it to
|
|
6
|
+
* renderer options. Intended for use in server-side comparison pipelines
|
|
7
|
+
* and any environment that bridges CE state to the text-renderer.
|
|
8
|
+
*/
|
|
9
|
+
export { extractTextPlacements } from './extractTextPlacements';
|
|
10
|
+
export { mapStateToRendererOptions } from './mapStateToRendererOptions';
|
|
11
|
+
export type { BasePlacementSettings, BasePlacementState, CombinedEditorSettings, ConfigEditor, EditorGarment, EditorPalette, EditorPaletteColour, EditorState, EditorStateVals, EditorVariant, EmbellishmentPosition, Palettes, PlacementLibraryItem, PlacementPositionResult, PlacementsSettings, TextLibraryItem, TextLibraryItemFont, } from './ce-types';
|
|
12
|
+
export type { LoadedTextPlacement, TextPlacementFont, TextPlacementPosition, TextPlacementSpacing, } from './types';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { GetRenderedTextOptions } from '../types';
|
|
2
|
+
import { LoadedTextPlacement } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Map a LoadedTextPlacement to GetRenderedTextOptions for the text-renderer.
|
|
5
|
+
*
|
|
6
|
+
* Handles the key differences between config-engine and text-renderer:
|
|
7
|
+
* - American to British English ('center' -> 'centre')
|
|
8
|
+
* - isDistributed flag -> horizontalAlignment: 'distributed'
|
|
9
|
+
* - isCurved flag -> baseline: 'curved'
|
|
10
|
+
* - baselinePath -> baseline: { type: 'custom', path }
|
|
11
|
+
* - snake_case spacing -> camelCase spacing
|
|
12
|
+
*/
|
|
13
|
+
export declare function mapStateToRendererOptions(placement: LoadedTextPlacement): GetRenderedTextOptions;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { EditorPaletteColour } from './ce-types';
|
|
2
|
+
export interface TextPlacementPosition {
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
5
|
+
physicalWidth: number;
|
|
6
|
+
physicalHeight: number;
|
|
7
|
+
physicalUnits: string;
|
|
8
|
+
baselinePath?: string;
|
|
9
|
+
rotation: number;
|
|
10
|
+
}
|
|
11
|
+
export interface TextPlacementFont {
|
|
12
|
+
id: number;
|
|
13
|
+
fontUrl: string;
|
|
14
|
+
fontFamily: string;
|
|
15
|
+
letterSpacing: number;
|
|
16
|
+
letterSpacingOutline: number;
|
|
17
|
+
outlineWidth: number;
|
|
18
|
+
fixedColours?: Record<string, {
|
|
19
|
+
reference: string;
|
|
20
|
+
hex: string;
|
|
21
|
+
id: string;
|
|
22
|
+
text: string;
|
|
23
|
+
}>;
|
|
24
|
+
}
|
|
25
|
+
export interface TextPlacementSpacing {
|
|
26
|
+
letter_spacing: number;
|
|
27
|
+
letter_spacing_outline: number;
|
|
28
|
+
line_height?: number;
|
|
29
|
+
}
|
|
30
|
+
export interface LoadedTextPlacement {
|
|
31
|
+
placementId: string;
|
|
32
|
+
displayName: string;
|
|
33
|
+
source: 'placements' | 'embellishments';
|
|
34
|
+
text: string;
|
|
35
|
+
font: TextPlacementFont;
|
|
36
|
+
isCurved: boolean;
|
|
37
|
+
isDistributed: boolean;
|
|
38
|
+
verticalAlignment: string;
|
|
39
|
+
horizontalAlignment: string;
|
|
40
|
+
rotation: number;
|
|
41
|
+
spacing: TextPlacementSpacing | null;
|
|
42
|
+
fillColour: EditorPaletteColour | null;
|
|
43
|
+
outlineColour: EditorPaletteColour | null;
|
|
44
|
+
position: TextPlacementPosition;
|
|
45
|
+
userSetPhysicalSize: [number, string] | null;
|
|
46
|
+
fontMetrics: {
|
|
47
|
+
size: number;
|
|
48
|
+
height: number;
|
|
49
|
+
baseline: number;
|
|
50
|
+
width: number;
|
|
51
|
+
physicalHeight?: number;
|
|
52
|
+
physicalUnits?: string;
|
|
53
|
+
physicalFontSize?: [number, 'mm' | 'in'];
|
|
54
|
+
};
|
|
55
|
+
manufacturingMethod: string;
|
|
56
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { LoadedFont } from '../loading';
|
|
2
|
+
import { ColourInfo, ColourMap, GlyphFill } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Get the unique colours used by a font's SVG glyphs.
|
|
5
|
+
*
|
|
6
|
+
* @param font - A loaded font with svgGlyphs populated
|
|
7
|
+
* @returns Array of unique hex colour strings found in the font's SVG glyphs
|
|
8
|
+
*/
|
|
9
|
+
export declare function getFontColours(font: LoadedFont): string[];
|
|
10
|
+
/**
|
|
11
|
+
* Extract fill paths from SVG content with optional colour remapping.
|
|
12
|
+
*
|
|
13
|
+
* @param svgContent - Raw SVG string from the font's SVG table
|
|
14
|
+
* @param colourMap - Optional mapping of original colours to replacements
|
|
15
|
+
* @returns Array of GlyphFill objects
|
|
16
|
+
*/
|
|
17
|
+
export declare function extractFillsFromSVG(svgContent: string, colourMap?: ColourMap): GlyphFill[];
|
|
18
|
+
/**
|
|
19
|
+
* Apply colour map to remap a colour value.
|
|
20
|
+
*
|
|
21
|
+
* @param colour - Original colour hex string
|
|
22
|
+
* @param colourMap - Optional colour replacement mapping
|
|
23
|
+
* @returns ColourInfo with hex and optional reference
|
|
24
|
+
*/
|
|
25
|
+
export declare function applyColourMap(colour: string, colourMap?: ColourMap): ColourInfo;
|
|
26
|
+
/**
|
|
27
|
+
* Extract the inner content from a raw SVG glyph string.
|
|
28
|
+
* Strips the XML declaration and outer <svg> wrapper, returning the inner elements.
|
|
29
|
+
*/
|
|
30
|
+
export declare function extractSvgGlyphContent(rawSvg: string): string;
|
|
31
|
+
/**
|
|
32
|
+
* Namespace all IDs in SVG content to prevent collisions when multiple
|
|
33
|
+
* glyphs are embedded in the same document. Prefixes all id attributes
|
|
34
|
+
* and updates all references (href, url(), clip-path, mask, filter).
|
|
35
|
+
*/
|
|
36
|
+
export declare function namespaceSvgIds(svgContent: string, prefix: string): string;
|
|
37
|
+
/**
|
|
38
|
+
* Remap colour values in raw SVG content. Replaces fill, stroke,
|
|
39
|
+
* and stop-color attribute values according to the colour map.
|
|
40
|
+
* Also handles elements without explicit fill that default to black.
|
|
41
|
+
*/
|
|
42
|
+
export declare function remapSvgColours(svgContent: string, colourMap: ColourMap): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare class Box {
|
|
2
|
+
corners: DOMPoint[];
|
|
3
|
+
x1: number;
|
|
4
|
+
y1: number;
|
|
5
|
+
x2: number;
|
|
6
|
+
y2: number;
|
|
7
|
+
_x3: number | undefined;
|
|
8
|
+
_y3: number | undefined;
|
|
9
|
+
_x4: number | undefined;
|
|
10
|
+
_y4: number | undefined;
|
|
11
|
+
get x3(): number;
|
|
12
|
+
get y3(): number;
|
|
13
|
+
get x4(): number;
|
|
14
|
+
get y4(): number;
|
|
15
|
+
constructor(x1: number, y1: number, x2: number, y2: number, x3?: number, y3?: number, x4?: number, y4?: number);
|
|
16
|
+
transform(matrix: DOMMatrix): void;
|
|
17
|
+
toPointsArray(): number[][];
|
|
18
|
+
getBBox(): BBox;
|
|
19
|
+
}
|
|
20
|
+
export declare class BBox extends Box {
|
|
21
|
+
get x(): number;
|
|
22
|
+
get y(): number;
|
|
23
|
+
get width(): number;
|
|
24
|
+
get height(): number;
|
|
25
|
+
add(box: Box): void;
|
|
26
|
+
addPoint(x: number, y: number): void;
|
|
27
|
+
serialize(): {
|
|
28
|
+
x: number;
|
|
29
|
+
y: number;
|
|
30
|
+
width: number;
|
|
31
|
+
height: number;
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Create a matrix with optional initial values
|
|
3
|
+
* Detects what style of matrix is supported by the browser
|
|
4
|
+
*
|
|
5
|
+
* @param {Array} initialValues - the initial values for the matrix
|
|
6
|
+
* @returns {DOMMatrix} the new matrix
|
|
7
|
+
*/
|
|
8
|
+
export declare const createMatrix: (initialValues?: number[]) => DOMMatrix;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare class Point {
|
|
2
|
+
private x;
|
|
3
|
+
private y;
|
|
4
|
+
constructor(x: number, y: number);
|
|
5
|
+
get X(): number;
|
|
6
|
+
get Y(): number;
|
|
7
|
+
toSVGString(): string;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Rotate a point about a pivot point
|
|
11
|
+
*
|
|
12
|
+
* @param point - the point to rotate
|
|
13
|
+
* @param rotate - the amount in degrees
|
|
14
|
+
* @param pivotPoint - the point around which to rotate
|
|
15
|
+
* @returns the new point
|
|
16
|
+
*/
|
|
17
|
+
export declare function rotatePoint(point: Point, rotate: number, pivotPoint?: Point): Point;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function escapeXML(str: string): string;
|