text-shaper 0.1.12 → 0.1.14

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.
@@ -2,6 +2,32 @@
2
2
  * Bitmap manipulation utilities
3
3
  */
4
4
  import { type Bitmap, PixelMode } from "./types.ts";
5
+ import type { Matrix2D, Matrix3x3 } from "../render/outline-transform.ts";
6
+ export interface BitmapTransformOptions {
7
+ /** Glyph bearing X (left edge from origin) */
8
+ bearingX?: number;
9
+ /** Glyph bearing Y (top edge from origin) */
10
+ bearingY?: number;
11
+ /** Optional translation in 26.6 units (applied after matrix) */
12
+ offsetX26?: number;
13
+ /** Optional translation in 26.6 units (applied after matrix) */
14
+ offsetY26?: number;
15
+ }
16
+ export interface RasterMetrics {
17
+ width: number;
18
+ height: number;
19
+ bearingX: number;
20
+ bearingY: number;
21
+ ascent: number;
22
+ descent: number;
23
+ }
24
+ export interface RasterEffectOptions {
25
+ blur?: number;
26
+ be?: number;
27
+ border?: number;
28
+ shadowX?: number;
29
+ shadowY?: number;
30
+ }
5
31
  /**
6
32
  * Embolden a bitmap by dilating pixel values
7
33
  * Makes text bolder by spreading coverage in x and y directions
@@ -147,3 +173,67 @@ export declare function expandToFit(dst: Bitmap, src: Bitmap, srcX: number, srcY
147
173
  srcOffsetX: number;
148
174
  srcOffsetY: number;
149
175
  };
176
+ /**
177
+ * Subtract src from dst (alias for subBitmaps)
178
+ */
179
+ export declare function subtractBitmap(dst: Bitmap, src: Bitmap, srcX?: number, srcY?: number): void;
180
+ /**
181
+ * Fix outline bitmap by removing glyph interior (alias for fixOutline)
182
+ */
183
+ export declare function fixOutlineBitmap(outlineBitmap: Bitmap, glyphBitmap: Bitmap, glyphX?: number, glyphY?: number, threshold?: number): void;
184
+ /**
185
+ * Measure rasterized glyph ascent/descent from bitmap coverage
186
+ */
187
+ export declare function measureRasterGlyph(bitmap: Bitmap, bearingX: number, bearingY: number): {
188
+ ascent: number;
189
+ descent: number;
190
+ };
191
+ /**
192
+ * Expand raster metrics to account for blur/border/shadow padding
193
+ */
194
+ export declare function expandRasterMetrics(metrics: RasterMetrics, options: RasterEffectOptions): RasterMetrics & {
195
+ padLeft: number;
196
+ padRight: number;
197
+ padTop: number;
198
+ padBottom: number;
199
+ };
200
+ /**
201
+ * Embolden bitmap and adjust bearing by padding to avoid clipping
202
+ */
203
+ export declare function emboldenBitmapWithBearing(bitmap: Bitmap, bearingX: number, bearingY: number, xStrength: number, yStrength: number): {
204
+ bitmap: Bitmap;
205
+ bearingX: number;
206
+ bearingY: number;
207
+ };
208
+ /**
209
+ * Transform bitmap using 2D affine matrix with bilinear resampling
210
+ */
211
+ export declare function transformBitmap2D(bitmap: Bitmap, matrix: Matrix2D, options?: BitmapTransformOptions): {
212
+ bitmap: Bitmap;
213
+ bearingX: number;
214
+ bearingY: number;
215
+ };
216
+ /**
217
+ * Transform bitmap using 3x3 matrix with perspective and bilinear resampling
218
+ */
219
+ export declare function transformBitmap3D(bitmap: Bitmap, matrix: Matrix3x3, options?: BitmapTransformOptions): {
220
+ bitmap: Bitmap;
221
+ bearingX: number;
222
+ bearingY: number;
223
+ };
224
+ /**
225
+ * Shear bitmap horizontally (synthetic italic)
226
+ */
227
+ export declare function shearBitmapX(bitmap: Bitmap, amount: number, options?: BitmapTransformOptions): {
228
+ bitmap: Bitmap;
229
+ bearingX: number;
230
+ bearingY: number;
231
+ };
232
+ /**
233
+ * Shear bitmap vertically
234
+ */
235
+ export declare function shearBitmapY(bitmap: Bitmap, amount: number, options?: BitmapTransformOptions): {
236
+ bitmap: Bitmap;
237
+ bearingX: number;
238
+ bearingY: number;
239
+ };
@@ -3,6 +3,7 @@
3
3
  */
4
4
  import type { Font } from "../font/font.ts";
5
5
  import { type GlyphPath } from "../render/path.ts";
6
+ import type { Matrix2D, Matrix3x3 } from "../render/outline-transform.ts";
6
7
  import type { GlyphId } from "../types.ts";
7
8
  import { type Bitmap, PixelMode, type RasterizedGlyph, type RasterizeOptions } from "./types.ts";
8
9
  /**
@@ -26,6 +27,19 @@ export declare function rasterizeGlyph(font: Font, glyphId: GlyphId, fontSize: n
26
27
  /** Use TrueType hinting if available */
27
28
  hinting?: boolean;
28
29
  }): RasterizedGlyph | null;
30
+ /**
31
+ * Rasterize a glyph and apply a bitmap transform (2D or 3D)
32
+ */
33
+ export declare function rasterizeGlyphWithTransform(font: Font, glyphId: GlyphId, fontSize: number, matrix: Matrix2D | Matrix3x3, options?: {
34
+ pixelMode?: PixelMode;
35
+ padding?: number;
36
+ /** Use TrueType hinting if available */
37
+ hinting?: boolean;
38
+ /** Translation offset in 26.6 units (applied after matrix) */
39
+ offsetX26?: number;
40
+ /** Translation offset in 26.6 units (applied after matrix) */
41
+ offsetY26?: number;
42
+ }): RasterizedGlyph | null;
29
43
  /**
30
44
  * Rasterize text string using shaped glyphs
31
45
  * @param font Font to use for rendering
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "text-shaper",
3
- "version": "0.1.12",
3
+ "version": "0.1.14",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/wiedymi/text-shaper.git"