imagescript 1.3.1 → 3.1.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/LICENSE +4 -1
- package/README.md +76 -26
- package/THIRD_PARTY_NOTICES.md +156 -0
- package/dist/animation.d.ts +55 -0
- package/dist/animation.js +167 -0
- package/dist/codecs/crc.d.ts +9 -0
- package/dist/codecs/crc.js +29 -0
- package/dist/codecs/exif.d.ts +11 -0
- package/dist/codecs/exif.js +27 -0
- package/dist/codecs/gif.d.ts +44 -0
- package/dist/codecs/gif.js +401 -0
- package/dist/codecs/jpeg.d.ts +35 -0
- package/dist/codecs/jpeg.js +980 -0
- package/dist/codecs/png.d.ts +97 -0
- package/dist/codecs/png.js +664 -0
- package/dist/codecs/quantize.d.ts +25 -0
- package/dist/codecs/quantize.js +302 -0
- package/dist/codecs/tga.d.ts +16 -0
- package/dist/codecs/tga.js +203 -0
- package/dist/codecs/tiff.d.ts +6 -0
- package/dist/codecs/tiff.js +546 -0
- package/dist/codecs/vp8-tables.d.ts +10 -0
- package/dist/codecs/vp8-tables.js +17 -0
- package/dist/codecs/vp8.d.ts +8 -0
- package/dist/codecs/vp8.js +711 -0
- package/dist/codecs/vp8l.d.ts +62 -0
- package/dist/codecs/vp8l.js +909 -0
- package/dist/codecs/webp.d.ts +67 -0
- package/dist/codecs/webp.js +280 -0
- package/dist/codecs/zlib.d.ts +22 -0
- package/dist/codecs/zlib.js +607 -0
- package/dist/frame.d.ts +57 -0
- package/dist/frame.js +65 -0
- package/dist/gif.d.ts +31 -0
- package/dist/gif.js +20 -0
- package/dist/image-type.d.ts +24 -0
- package/dist/image-type.js +64 -0
- package/dist/image.d.ts +553 -0
- package/dist/image.js +1156 -0
- package/dist/index.d.ts +23 -0
- package/dist/index.js +20 -0
- package/dist/package.json +1 -0
- package/dist/render/font.d.ts +92 -0
- package/dist/render/font.js +954 -0
- package/dist/render/hinting.d.ts +110 -0
- package/dist/render/hinting.js +1236 -0
- package/dist/render/svg.d.ts +11 -0
- package/dist/render/svg.js +1717 -0
- package/dist/render/text.d.ts +63 -0
- package/dist/render/text.js +342 -0
- package/dist/text-layout.d.ts +46 -0
- package/dist/text-layout.js +35 -0
- package/dist/util/blur.d.ts +13 -0
- package/dist/util/blur.js +146 -0
- package/dist/util/mem.d.ts +10 -0
- package/dist/util/mem.js +23 -0
- package/dist/util/resample.d.ts +12 -0
- package/dist/util/resample.js +99 -0
- package/dist/util/utf8.d.ts +5 -0
- package/dist/util/utf8.js +55 -0
- package/dist/version.d.ts +1 -0
- package/dist/version.js +1 -0
- package/licenses/Apache-2.0.txt +202 -0
- package/licenses/FTL.txt +169 -0
- package/licenses/README.ijg +260 -0
- package/package.json +31 -7
- package/ImageScript.d.ts +0 -954
- package/ImageScript.js +0 -1669
- package/bench/_.mjs +0 -166
- package/bench/all.mjs +0 -4
- package/bench/blur.mjs +0 -59
- package/bench/flip.mjs +0 -63
- package/bench/overlay.mjs +0 -35
- package/bench/package.json +0 -7
- package/bench/readme.md +0 -64
- package/bench/resize.mjs +0 -52
- package/codecs/LICENSE +0 -21
- package/codecs/lib.d.ts +0 -50
- package/codecs/lib.js +0 -6
- package/codecs/lib.mjs +0 -1
- package/codecs/node/bin/arm64-darwin.node +0 -0
- package/codecs/node/bin/arm64-linux.node +0 -0
- package/codecs/node/bin/x64-darwin.node +0 -0
- package/codecs/node/bin/x64-linux.node +0 -0
- package/codecs/node/bin/x64-win32.node +0 -0
- package/codecs/node/index.js +0 -3
- package/codecs/node/index.mjs +0 -6
- package/codecs/package.json +0 -14
- package/codecs/readme.md +0 -38
- package/codecs/wasm/bin/codecs.wasm +0 -0
- package/codecs/wasm/bin/simd.wasm +0 -0
- package/codecs/wasm/bundle/browser.js +0 -1
- package/codecs/wasm/index.js +0 -1
- package/codecs/wasm/index.mjs +0 -1
- package/png/README.md +0 -1
- package/png/node.js +0 -1137
- package/png/src/crc.mjs +0 -49
- package/png/src/mem.mjs +0 -24
- package/png/src/png.mjs +0 -254
- package/png/src/zlib.mjs +0 -618
- package/tsconfig.json +0 -21
- package/utils/mem.js +0 -26
- package/v2/codecs/magic.js +0 -25
- package/v2/framebuffer.d.ts +0 -67
- package/v2/framebuffer.js +0 -2352
- package/v2/framebuffer.mjs +0 -126
- package/v2/framebuffer.rs +0 -1264
- package/v2/index.d.ts +0 -84
- package/v2/index.js +0 -261
- package/v2/ops/blur.mjs +0 -303
- package/v2/ops/color.mjs +0 -277
- package/v2/ops/crop.mjs +0 -64
- package/v2/ops/fill.mjs +0 -33
- package/v2/ops/flip.mjs +0 -33
- package/v2/ops/index.mjs +0 -9
- package/v2/ops/iterator.mjs +0 -34
- package/v2/ops/overlay.mjs +0 -63
- package/v2/ops/resize.mjs +0 -166
- package/v2/ops/rotate.mjs +0 -117
- package/v2/util/mem.mjs +0 -24
- package/wasm/any/font.wasm +0 -0
- package/wasm/any/gif.wasm +0 -0
- package/wasm/any/jpeg.wasm +0 -0
- package/wasm/any/png.wasm +0 -0
- package/wasm/any/svg.wasm +0 -0
- package/wasm/any/tiff.wasm +0 -0
- package/wasm/node/font.js +0 -142
- package/wasm/node/gif.js +0 -76
- package/wasm/node/jpeg.js +0 -92
- package/wasm/node/png.js +0 -49
- package/wasm/node/svg.js +0 -56
- package/wasm/node/tiff.js +0 -47
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* TrueType hinting interpreter. Where the TrueType specification leaves details open, its behavior and parts of its
|
|
3
|
+
* logic follow FreeType's TrueType interpreter (src/truetype/ttinterp.c): fixed point rounding, original distances
|
|
4
|
+
* on the unscaled outline (IP, IUP, MDRP, MD), the IUP interpolation, the movement along near-perpendicular vectors
|
|
5
|
+
* and the tolerance of invalid references. Portions of this software are copyright © 2026 The FreeType Project
|
|
6
|
+
* (https://freetype.org). All rights reserved. FreeType License, see THIRD_PARTY_NOTICES.md and licenses/FTL.txt
|
|
7
|
+
*/
|
|
8
|
+
import { Font, PathCommand } from './font.js';
|
|
9
|
+
interface Vector {
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
}
|
|
13
|
+
interface GraphicsState {
|
|
14
|
+
pv: Vector;
|
|
15
|
+
fv: Vector;
|
|
16
|
+
dv: Vector;
|
|
17
|
+
rp0: number;
|
|
18
|
+
rp1: number;
|
|
19
|
+
rp2: number;
|
|
20
|
+
zp0: number;
|
|
21
|
+
zp1: number;
|
|
22
|
+
zp2: number;
|
|
23
|
+
loop: number;
|
|
24
|
+
minimumDistance: number;
|
|
25
|
+
cvtCutIn: number;
|
|
26
|
+
singleWidthCutIn: number;
|
|
27
|
+
singleWidth: number;
|
|
28
|
+
deltaBase: number;
|
|
29
|
+
deltaShift: number;
|
|
30
|
+
autoFlip: boolean;
|
|
31
|
+
/** null: rounding off */
|
|
32
|
+
round: {
|
|
33
|
+
period: number;
|
|
34
|
+
phase: number;
|
|
35
|
+
threshold: number;
|
|
36
|
+
} | null;
|
|
37
|
+
instructControl: number;
|
|
38
|
+
}
|
|
39
|
+
interface Zone {
|
|
40
|
+
curX: Float64Array;
|
|
41
|
+
curY: Float64Array;
|
|
42
|
+
orgX: Float64Array;
|
|
43
|
+
orgY: Float64Array;
|
|
44
|
+
/** unscaled original positions (font units), measurements between original glyph points use them */
|
|
45
|
+
orusX: Float64Array;
|
|
46
|
+
orusY: Float64Array;
|
|
47
|
+
touchX: Uint8Array;
|
|
48
|
+
touchY: Uint8Array;
|
|
49
|
+
on: Uint8Array;
|
|
50
|
+
ends: number[];
|
|
51
|
+
}
|
|
52
|
+
interface FunctionDef {
|
|
53
|
+
code: Uint8Array;
|
|
54
|
+
start: number;
|
|
55
|
+
end: number;
|
|
56
|
+
}
|
|
57
|
+
/** state of a font at one size, after the font and control value programs ran */
|
|
58
|
+
interface SizeState {
|
|
59
|
+
ppem: number;
|
|
60
|
+
/** 26.6 units per font unit */
|
|
61
|
+
scale: number;
|
|
62
|
+
/** the same as 16.16 fixed point number */
|
|
63
|
+
scaleFixed: number;
|
|
64
|
+
cvt: Float64Array;
|
|
65
|
+
storage: Int32Array;
|
|
66
|
+
state: GraphicsState;
|
|
67
|
+
twilight: Zone;
|
|
68
|
+
functions: Map<number, FunctionDef>;
|
|
69
|
+
instructions: Map<number, FunctionDef>;
|
|
70
|
+
/** set if the font and control value programs failed, the font is then rendered unhinted */
|
|
71
|
+
broken: boolean;
|
|
72
|
+
}
|
|
73
|
+
export interface HintedGlyph {
|
|
74
|
+
/** outline in pixels, relative to the pen position (y up) */
|
|
75
|
+
path: PathCommand[];
|
|
76
|
+
/** advance width in whole pixels */
|
|
77
|
+
advance: number;
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Executes TrueType instructions for one font
|
|
81
|
+
*/
|
|
82
|
+
export declare class Hinter {
|
|
83
|
+
font: Font;
|
|
84
|
+
fpgm: Uint8Array;
|
|
85
|
+
prep: Uint8Array;
|
|
86
|
+
cvt: Int16Array;
|
|
87
|
+
maxStack: number;
|
|
88
|
+
maxStorage: number;
|
|
89
|
+
maxTwilight: number;
|
|
90
|
+
sizes: Map<number, SizeState>;
|
|
91
|
+
/** 26.6 units per font unit (16.16 fixed point) of the glyph being loaded */
|
|
92
|
+
private scaleFixed;
|
|
93
|
+
constructor(font: Font);
|
|
94
|
+
/** whether the font has hinting instructions (a font program, control value program or control values) */
|
|
95
|
+
get hasInstructions(): boolean;
|
|
96
|
+
private size;
|
|
97
|
+
/**
|
|
98
|
+
* Hints a glyph at a size
|
|
99
|
+
* @param size pixels per em
|
|
100
|
+
* @return the hinted outline, or null if the glyph can't be hinted (it is then rendered unhinted)
|
|
101
|
+
*/
|
|
102
|
+
glyph(glyph: number, size: number): HintedGlyph | null;
|
|
103
|
+
/**
|
|
104
|
+
* Loads, scales and hints a glyph (recursively for composites)
|
|
105
|
+
* @return the glyph zone (with 4 phantom points after the outline points)
|
|
106
|
+
*/
|
|
107
|
+
private load;
|
|
108
|
+
private phantoms;
|
|
109
|
+
}
|
|
110
|
+
export {};
|