@pixerate/editor 0.191.0 → 0.193.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.
Files changed (55) hide show
  1. package/dist/animation-editor/index.cjs +56 -56
  2. package/dist/animation-editor/index.js +2 -2
  3. package/dist/{chunk-ZQGZWFPU.cjs → chunk-3T5VCDIV.cjs} +97 -5
  4. package/dist/{chunk-RQ2EM5TY.js → chunk-5OC22IEO.js} +97 -5
  5. package/dist/{chunk-EGZM52EO.cjs → chunk-BRKVNXDZ.cjs} +354 -125
  6. package/dist/{chunk-XCDGM7TD.cjs → chunk-FR2Q2LVF.cjs} +35 -35
  7. package/dist/{chunk-LPIKXPBM.js → chunk-GHCXLQ47.js} +262 -33
  8. package/dist/{chunk-VRXXAXUT.js → chunk-MLC7HUHO.js} +1 -1
  9. package/dist/{chunk-2UR4OX3B.cjs → chunk-UYXL6ZWQ.cjs} +114 -97
  10. package/dist/{chunk-TXYXF32N.js → chunk-ZIDUPSP4.js} +35 -18
  11. package/dist/image-editor/controller.d.cts +31 -2
  12. package/dist/image-editor/controller.d.ts +31 -2
  13. package/dist/image-editor/index.cjs +1064 -923
  14. package/dist/image-editor/index.js +204 -63
  15. package/dist/image-editor/layers/model.d.cts +7 -2
  16. package/dist/image-editor/layers/model.d.ts +7 -2
  17. package/dist/image-editor/layers/serialize.d.cts +2 -0
  18. package/dist/image-editor/layers/serialize.d.ts +2 -0
  19. package/dist/image-editor/layers/shape-type-ui.d.cts +8 -2
  20. package/dist/image-editor/layers/shape-type-ui.d.ts +8 -2
  21. package/dist/image-editor/layers/text.d.cts +6 -2
  22. package/dist/image-editor/layers/text.d.ts +6 -2
  23. package/dist/image-editor/psd/type.d.cts +2 -1
  24. package/dist/image-editor/psd/type.d.ts +2 -1
  25. package/dist/image-editor/selection/tool-options.d.cts +7 -1
  26. package/dist/image-editor/selection/tool-options.d.ts +7 -1
  27. package/dist/image-editor/tools.d.cts +1 -1
  28. package/dist/image-editor/tools.d.ts +1 -1
  29. package/dist/image-editor/type-tools.d.cts +2 -2
  30. package/dist/image-editor/type-tools.d.ts +2 -2
  31. package/dist/paint-editor/index.cjs +7 -7
  32. package/dist/paint-editor/index.js +2 -2
  33. package/dist/text/layout.d.cts +93 -12
  34. package/dist/text/layout.d.ts +93 -12
  35. package/dist/text/opentype.d.cts +13 -3
  36. package/dist/text/opentype.d.ts +13 -3
  37. package/dist/text/shapers.d.cts +12 -0
  38. package/dist/text/shapers.d.ts +12 -0
  39. package/dist/text/types.d.cts +36 -2
  40. package/dist/text/types.d.ts +36 -2
  41. package/dist/vector/controller.d.cts +8 -0
  42. package/dist/vector/controller.d.ts +8 -0
  43. package/dist/vector/index.cjs +1039 -967
  44. package/dist/vector/index.js +90 -18
  45. package/dist/vector/text.d.cts +5 -3
  46. package/dist/vector/text.d.ts +5 -3
  47. package/dist/vector/textPanel.d.cts +6 -0
  48. package/dist/vector/textPanel.d.ts +6 -0
  49. package/dist/vector/types.d.cts +9 -0
  50. package/dist/vector/types.d.ts +9 -0
  51. package/package.json +1 -1
  52. package/skills/pixerate-image-editor/SKILL.md +4 -2
  53. package/skills/pixerate-image-editor/references/shapes-and-type.md +19 -5
  54. package/skills/pixerate-image-selection-masking/SKILL.md +2 -0
  55. package/skills/pixerate-vector/SKILL.md +9 -3
@@ -2,9 +2,10 @@
2
2
  * A small OpenType reader: enough of a font file to set Latin, Cyrillic, Greek and CJK text as
3
3
  * outlines without a third-party library. It reads TrueType (`glyf`) and CFF (`CFF `, CID-keyed
4
4
  * included) outlines, `cmap` (formats 4 and 12), horizontal metrics, `kern` (format 0) and `GPOS`
5
- * pair kerning (lookup type 2, formats 1 and 2, the `kern` feature), and the family, PostScript
6
- * name, weight and style. It does not apply `GSUB` (ligatures, contextual forms) or complex-script
7
- * shaping, so Arabic, Indic and similar scripts set as isolated glyphs.
5
+ * pair kerning (lookup type 2, formats 1 and 2, the `kern` feature), vertical metrics (`vhea`,
6
+ * `vmtx`, `VORG`) and vertical alternates (`GSUB` single substitutions of the `vert` feature), and
7
+ * the family, PostScript name, weight and style. It applies no other `GSUB` (ligatures, contextual
8
+ * forms) or complex-script shaping, so Arabic, Indic and similar scripts set as isolated glyphs.
8
9
  *
9
10
  * The result has the shape of opentype.js's `Font` that `createOutlineTextShaper` takes, so hosts
10
11
  * can pass either. Written from the OpenType specification (TrueType glyph outlines, the CFF
@@ -31,6 +32,15 @@ export interface OpenTypeFont extends OutlineFontFace {
31
32
  kerning(left: number, right: number): number;
32
33
  /** A glyph's outline in font units, y up, origin on the baseline. */
33
34
  glyphPath(glyph: number): OutlinePathCommand[];
35
+ /** Whether the font has vertical metrics (`vhea` and `vmtx`). */
36
+ readonly hasVerticalMetrics: boolean;
37
+ /** A glyph's vertical alternate (the `vert` feature), or the glyph itself when it has none. */
38
+ verticalGlyph(glyph: number): number;
39
+ getVerticalMetrics(char: string): {
40
+ advance: number;
41
+ originY: number;
42
+ alternate: boolean;
43
+ };
34
44
  }
35
45
  /**
36
46
  * Reads a TrueType or OpenType font (`.ttf`, `.otf`, or face `index` of a `.ttc` collection).
@@ -2,9 +2,10 @@
2
2
  * A small OpenType reader: enough of a font file to set Latin, Cyrillic, Greek and CJK text as
3
3
  * outlines without a third-party library. It reads TrueType (`glyf`) and CFF (`CFF `, CID-keyed
4
4
  * included) outlines, `cmap` (formats 4 and 12), horizontal metrics, `kern` (format 0) and `GPOS`
5
- * pair kerning (lookup type 2, formats 1 and 2, the `kern` feature), and the family, PostScript
6
- * name, weight and style. It does not apply `GSUB` (ligatures, contextual forms) or complex-script
7
- * shaping, so Arabic, Indic and similar scripts set as isolated glyphs.
5
+ * pair kerning (lookup type 2, formats 1 and 2, the `kern` feature), vertical metrics (`vhea`,
6
+ * `vmtx`, `VORG`) and vertical alternates (`GSUB` single substitutions of the `vert` feature), and
7
+ * the family, PostScript name, weight and style. It applies no other `GSUB` (ligatures, contextual
8
+ * forms) or complex-script shaping, so Arabic, Indic and similar scripts set as isolated glyphs.
8
9
  *
9
10
  * The result has the shape of opentype.js's `Font` that `createOutlineTextShaper` takes, so hosts
10
11
  * can pass either. Written from the OpenType specification (TrueType glyph outlines, the CFF
@@ -31,6 +32,15 @@ export interface OpenTypeFont extends OutlineFontFace {
31
32
  kerning(left: number, right: number): number;
32
33
  /** A glyph's outline in font units, y up, origin on the baseline. */
33
34
  glyphPath(glyph: number): OutlinePathCommand[];
35
+ /** Whether the font has vertical metrics (`vhea` and `vmtx`). */
36
+ readonly hasVerticalMetrics: boolean;
37
+ /** A glyph's vertical alternate (the `vert` feature), or the glyph itself when it has none. */
38
+ verticalGlyph(glyph: number): number;
39
+ getVerticalMetrics(char: string): {
40
+ advance: number;
41
+ originY: number;
42
+ alternate: boolean;
43
+ };
34
44
  }
35
45
  /**
36
46
  * Reads a TrueType or OpenType font (`.ttf`, `.otf`, or face `index` of a `.ttc` collection).
@@ -42,11 +42,23 @@ export interface OutlineFontFace {
42
42
  getAdvanceWidth(text: string, fontSize: number, options?: {
43
43
  kerning?: boolean;
44
44
  }): number;
45
+ /** `vertical`: the font's vertical alternates (`vert`), where it has them (faces without `getVerticalMetrics` ignore it). */
45
46
  getPath(text: string, x: number, y: number, fontSize: number, options?: {
46
47
  kerning?: boolean;
48
+ vertical?: boolean;
47
49
  }): {
48
50
  commands: OutlinePathCommand[];
49
51
  };
52
+ /**
53
+ * Vertical metrics of one character set upright, in font units: its advance down the column, the
54
+ * distance from the top of its cell to its baseline, and whether it has a vertical alternate.
55
+ * Optional (opentype.js lacks it): vertical text then uses the ascender and descender.
56
+ */
57
+ getVerticalMetrics?(char: string): {
58
+ advance: number;
59
+ originY: number;
60
+ alternate: boolean;
61
+ };
50
62
  names?: {
51
63
  fontFamily?: Record<string, string>;
52
64
  postScriptName?: Record<string, string>;
@@ -42,11 +42,23 @@ export interface OutlineFontFace {
42
42
  getAdvanceWidth(text: string, fontSize: number, options?: {
43
43
  kerning?: boolean;
44
44
  }): number;
45
+ /** `vertical`: the font's vertical alternates (`vert`), where it has them (faces without `getVerticalMetrics` ignore it). */
45
46
  getPath(text: string, x: number, y: number, fontSize: number, options?: {
46
47
  kerning?: boolean;
48
+ vertical?: boolean;
47
49
  }): {
48
50
  commands: OutlinePathCommand[];
49
51
  };
52
+ /**
53
+ * Vertical metrics of one character set upright, in font units: its advance down the column, the
54
+ * distance from the top of its cell to its baseline, and whether it has a vertical alternate.
55
+ * Optional (opentype.js lacks it): vertical text then uses the ascender and descender.
56
+ */
57
+ getVerticalMetrics?(char: string): {
58
+ advance: number;
59
+ originY: number;
60
+ alternate: boolean;
61
+ };
50
62
  names?: {
51
63
  fontFamily?: Record<string, string>;
52
64
  postScriptName?: Record<string, string>;
@@ -38,7 +38,20 @@ export interface TextStyle {
38
38
  strikethrough?: boolean;
39
39
  /** PostScript name from a PSD (`ArialMT`), kept so the exact face can be found and written back. */
40
40
  postScriptName?: string;
41
+ /**
42
+ * Vertical text only: set Latin and other horizontal-script characters upright, one under the
43
+ * other, instead of turned sideways (Photoshop's Standard Vertical Roman Alignment off). Default
44
+ * false. No effect on horizontal text.
45
+ */
46
+ upright?: boolean;
41
47
  }
48
+ /**
49
+ * Which way text runs. `horizontal`: lines left to right, stacked downwards. `vertical`: columns
50
+ * top to bottom, stacked right to left; CJK characters stand upright and other scripts are turned
51
+ * 90° clockwise (unless their style is `upright`).
52
+ */
53
+ export type TextOrientation = 'horizontal' | 'vertical';
54
+ export declare const TEXT_ORIENTATIONS: readonly TextOrientation[];
42
55
  /** A character style over `length` UTF-16 code units of the text, in order. */
43
56
  export interface TextRun {
44
57
  length: number;
@@ -71,6 +84,20 @@ export interface TextFont {
71
84
  size: number;
72
85
  postScriptName?: string;
73
86
  }
87
+ /** How a shaper sets a character upright in a vertical column (pixels). */
88
+ export interface TextVerticalMetrics {
89
+ /** Advance down the column. */
90
+ advance: number;
91
+ /** Distance from the top of the character's cell to its horizontal baseline. */
92
+ originY: number;
93
+ /** Whether the font has a vertical alternate (OpenType `vert`) the shaper draws with `{ vertical: true }`. */
94
+ alternate: boolean;
95
+ }
96
+ /** Options for drawing or outlining text. */
97
+ export interface TextGlyphOptions {
98
+ /** Use the font's vertical alternates (`vert`), for upright characters in vertical text. */
99
+ vertical?: boolean;
100
+ }
74
101
  /**
75
102
  * What layout and rendering need from fonts. Implement `outline` (glyph outlines, pure) or `draw`
76
103
  * (onto a 2D canvas), or both.
@@ -94,9 +121,16 @@ export interface TextShaper {
94
121
  */
95
122
  measure(text: string, font: TextFont): ArrayLike<number>;
96
123
  /** Glyph outlines of `text` with its start on the baseline at (`x`, `y`), pixels, y down. */
97
- outline?(text: string, font: TextFont, x: number, y: number): BezierPath;
124
+ outline?(text: string, font: TextFont, x: number, y: number, options?: TextGlyphOptions): BezierPath;
98
125
  /** Draws `text` with its start on the baseline at (`x`, `y`) in the context's current transform, fill style and alpha. */
99
- draw?(ctx: CanvasRenderingContext2D, text: string, font: TextFont, x: number, y: number): void;
126
+ draw?(ctx: CanvasRenderingContext2D, text: string, font: TextFont, x: number, y: number, options?: TextGlyphOptions): void;
127
+ /**
128
+ * Vertical metrics of one character (a code point) set upright, from the font's `vhea` / `vmtx`.
129
+ * Optional: without it, vertical layout uses the font's ascent + descent as the advance and its
130
+ * ascent as the origin, and has no vertical alternates (brackets and dashes are then turned
131
+ * sideways, and 、。 moved to the upper right of their cell).
132
+ */
133
+ vertical?(char: string, font: TextFont): TextVerticalMetrics;
100
134
  /** Families this shaper can draw (for font pickers and agents), when it can tell. */
101
135
  families?(): string[];
102
136
  }
@@ -38,7 +38,20 @@ export interface TextStyle {
38
38
  strikethrough?: boolean;
39
39
  /** PostScript name from a PSD (`ArialMT`), kept so the exact face can be found and written back. */
40
40
  postScriptName?: string;
41
+ /**
42
+ * Vertical text only: set Latin and other horizontal-script characters upright, one under the
43
+ * other, instead of turned sideways (Photoshop's Standard Vertical Roman Alignment off). Default
44
+ * false. No effect on horizontal text.
45
+ */
46
+ upright?: boolean;
41
47
  }
48
+ /**
49
+ * Which way text runs. `horizontal`: lines left to right, stacked downwards. `vertical`: columns
50
+ * top to bottom, stacked right to left; CJK characters stand upright and other scripts are turned
51
+ * 90° clockwise (unless their style is `upright`).
52
+ */
53
+ export type TextOrientation = 'horizontal' | 'vertical';
54
+ export declare const TEXT_ORIENTATIONS: readonly TextOrientation[];
42
55
  /** A character style over `length` UTF-16 code units of the text, in order. */
43
56
  export interface TextRun {
44
57
  length: number;
@@ -71,6 +84,20 @@ export interface TextFont {
71
84
  size: number;
72
85
  postScriptName?: string;
73
86
  }
87
+ /** How a shaper sets a character upright in a vertical column (pixels). */
88
+ export interface TextVerticalMetrics {
89
+ /** Advance down the column. */
90
+ advance: number;
91
+ /** Distance from the top of the character's cell to its horizontal baseline. */
92
+ originY: number;
93
+ /** Whether the font has a vertical alternate (OpenType `vert`) the shaper draws with `{ vertical: true }`. */
94
+ alternate: boolean;
95
+ }
96
+ /** Options for drawing or outlining text. */
97
+ export interface TextGlyphOptions {
98
+ /** Use the font's vertical alternates (`vert`), for upright characters in vertical text. */
99
+ vertical?: boolean;
100
+ }
74
101
  /**
75
102
  * What layout and rendering need from fonts. Implement `outline` (glyph outlines, pure) or `draw`
76
103
  * (onto a 2D canvas), or both.
@@ -94,9 +121,16 @@ export interface TextShaper {
94
121
  */
95
122
  measure(text: string, font: TextFont): ArrayLike<number>;
96
123
  /** Glyph outlines of `text` with its start on the baseline at (`x`, `y`), pixels, y down. */
97
- outline?(text: string, font: TextFont, x: number, y: number): BezierPath;
124
+ outline?(text: string, font: TextFont, x: number, y: number, options?: TextGlyphOptions): BezierPath;
98
125
  /** Draws `text` with its start on the baseline at (`x`, `y`) in the context's current transform, fill style and alpha. */
99
- draw?(ctx: CanvasRenderingContext2D, text: string, font: TextFont, x: number, y: number): void;
126
+ draw?(ctx: CanvasRenderingContext2D, text: string, font: TextFont, x: number, y: number, options?: TextGlyphOptions): void;
127
+ /**
128
+ * Vertical metrics of one character (a code point) set upright, from the font's `vhea` / `vmtx`.
129
+ * Optional: without it, vertical layout uses the font's ascent + descent as the advance and its
130
+ * ascent as the origin, and has no vertical alternates (brackets and dashes are then turned
131
+ * sideways, and 、。 moved to the upper right of their cell).
132
+ */
133
+ vertical?(char: string, font: TextFont): TextVerticalMetrics;
100
134
  /** Families this shaper can draw (for font pickers and agents), when it can tell. */
101
135
  families?(): string[];
102
136
  }
@@ -143,6 +143,8 @@ export interface VectorTextInput extends VectorStyle {
143
143
  }>, 'kind' | 'path'>;
144
144
  font?: Partial<VectorCharacterStyle>;
145
145
  paragraph?: VectorParagraphStyle;
146
+ /** Point and area text: `vertical` sets columns running down, right to left (default horizontal). */
147
+ orientation?: 'horizontal' | 'vertical';
146
148
  name?: string;
147
149
  }
148
150
  /** A constraint reference from loose input: an anchor by `subpath` / `index` (or its `id` as `anchor`), its handle, its segment, or a path as a circle. */
@@ -2249,6 +2251,7 @@ export declare class VectorEditorController {
2249
2251
  styleTexts(patch: {
2250
2252
  style?: Record<string, unknown>;
2251
2253
  paragraph?: Record<string, unknown>;
2254
+ orientation?: 'horizontal' | 'vertical';
2252
2255
  }, options?: {
2253
2256
  ids?: readonly string[];
2254
2257
  merge?: string;
@@ -2264,6 +2267,11 @@ export declare class VectorEditorController {
2264
2267
  * the node's own space). One undo step.
2265
2268
  */
2266
2269
  setTextFrame(id: string, patch: Record<string, unknown>): VectorActionResult;
2270
+ /**
2271
+ * Horizontal ↔ vertical text (Type › Type Orientation) for point and area text: the text, styles
2272
+ * and frame stay; lines become columns running down, right to left, or back. One undo step.
2273
+ */
2274
+ setTextOrientation(id: string, orientation: 'horizontal' | 'vertical'): VectorActionResult;
2267
2275
  /**
2268
2276
  * Turns path `pathId` into text set along it (Type on a Path): a text node in its place, its
2269
2277
  * anchors the text's path, its paint dropped for the text defaults (or `input`'s). Returns the
@@ -143,6 +143,8 @@ export interface VectorTextInput extends VectorStyle {
143
143
  }>, 'kind' | 'path'>;
144
144
  font?: Partial<VectorCharacterStyle>;
145
145
  paragraph?: VectorParagraphStyle;
146
+ /** Point and area text: `vertical` sets columns running down, right to left (default horizontal). */
147
+ orientation?: 'horizontal' | 'vertical';
146
148
  name?: string;
147
149
  }
148
150
  /** A constraint reference from loose input: an anchor by `subpath` / `index` (or its `id` as `anchor`), its handle, its segment, or a path as a circle. */
@@ -2249,6 +2251,7 @@ export declare class VectorEditorController {
2249
2251
  styleTexts(patch: {
2250
2252
  style?: Record<string, unknown>;
2251
2253
  paragraph?: Record<string, unknown>;
2254
+ orientation?: 'horizontal' | 'vertical';
2252
2255
  }, options?: {
2253
2256
  ids?: readonly string[];
2254
2257
  merge?: string;
@@ -2264,6 +2267,11 @@ export declare class VectorEditorController {
2264
2267
  * the node's own space). One undo step.
2265
2268
  */
2266
2269
  setTextFrame(id: string, patch: Record<string, unknown>): VectorActionResult;
2270
+ /**
2271
+ * Horizontal ↔ vertical text (Type › Type Orientation) for point and area text: the text, styles
2272
+ * and frame stay; lines become columns running down, right to left, or back. One undo step.
2273
+ */
2274
+ setTextOrientation(id: string, orientation: 'horizontal' | 'vertical'): VectorActionResult;
2267
2275
  /**
2268
2276
  * Turns path `pathId` into text set along it (Type on a Path): a text node in its place, its
2269
2277
  * anchors the text's path, its paint dropped for the text defaults (or `input`'s). Returns the