@gtkx/cairo 1.2.2 → 1.4.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 +373 -0
- package/README.md +174 -0
- package/dist/context.d.ts +1 -1
- package/dist/context.d.ts.map +1 -1
- package/dist/context.js +16 -15
- package/dist/context.js.map +1 -1
- package/dist/font-face.d.ts +2 -7
- package/dist/font-face.d.ts.map +1 -1
- package/dist/font-face.js +3 -13
- package/dist/font-face.js.map +1 -1
- package/dist/lib.d.ts +1 -3
- package/dist/lib.d.ts.map +1 -1
- package/dist/lib.js +3 -4
- package/dist/lib.js.map +1 -1
- package/dist/path.d.ts.map +1 -1
- package/dist/path.js +8 -5
- package/dist/path.js.map +1 -1
- package/dist/pattern.d.ts +3 -1
- package/dist/pattern.d.ts.map +1 -1
- package/dist/pattern.js +24 -6
- package/dist/pattern.js.map +1 -1
- package/dist/region.d.ts.map +1 -1
- package/dist/region.js +6 -5
- package/dist/region.js.map +1 -1
- package/dist/scaled-font.d.ts +3 -5
- package/dist/scaled-font.d.ts.map +1 -1
- package/dist/scaled-font.js +3 -62
- package/dist/scaled-font.js.map +1 -1
- package/dist/status.d.ts +6 -0
- package/dist/status.d.ts.map +1 -0
- package/dist/status.js +17 -0
- package/dist/status.js.map +1 -0
- package/dist/structs.d.ts +1 -1
- package/dist/structs.d.ts.map +1 -1
- package/dist/structs.js +1 -1
- package/dist/structs.js.map +1 -1
- package/dist/surface.d.ts +2 -7
- package/dist/surface.d.ts.map +1 -1
- package/dist/surface.js +21 -25
- package/dist/surface.js.map +1 -1
- package/dist/text.d.ts.map +1 -1
- package/dist/text.js +20 -17
- package/dist/text.js.map +1 -1
- package/package.json +60 -61
- package/src/context.ts +15 -16
- package/src/font-face.ts +3 -25
- package/src/lib.ts +2 -5
- package/src/path.ts +8 -5
- package/src/pattern.ts +31 -7
- package/src/region.ts +5 -5
- package/src/scaled-font.ts +3 -92
- package/src/status.ts +23 -0
- package/src/structs.ts +1 -1
- package/src/surface.ts +28 -29
- package/src/text.ts +20 -17
package/dist/text.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"text.js","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAoC,
|
|
1
|
+
{"version":3,"file":"text.js","sourceRoot":"","sources":["../src/text.ts"],"names":[],"mappings":"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","sourcesContent":["import { alloc, type ExternalObject, type Handle, t } from \"@gtkx/runtime\";\nimport type { CairoGlyph, CairoTextCluster, FontExtents, TextExtents } from \"./types.js\";\n\nconst GLYPH_SIZE = 24;\nconst CLUSTER_SIZE = 8;\nconst TEXT_EXTENTS_SIZE = 48;\nconst FONT_EXTENTS_SIZE = 40;\nconst DOUBLE = t.fieldAt(t.float64);\nconst UINT64 = t.fieldAt(t.uint64);\nconst INT = t.fieldAt(t.int32);\n\nconst allocGlyphBuffer = (glyphs: CairoGlyph[]): ExternalObject<Handle> => {\n const buffer = alloc(glyphs.length * GLYPH_SIZE);\n let offset = 0;\n\n for (const glyph of glyphs) {\n UINT64.write(buffer, offset, glyph.index);\n DOUBLE.write(buffer, offset + 8, glyph.x);\n DOUBLE.write(buffer, offset + 16, glyph.y);\n offset += GLYPH_SIZE;\n }\n\n return buffer;\n};\n\nconst allocClusterBuffer = (clusters: CairoTextCluster[]): ExternalObject<Handle> => {\n const buffer = alloc(clusters.length * CLUSTER_SIZE);\n let offset = 0;\n\n for (const cluster of clusters) {\n INT.write(buffer, offset, cluster.numBytes);\n INT.write(buffer, offset + 4, cluster.numGlyphs);\n offset += CLUSTER_SIZE;\n }\n\n return buffer;\n};\n\nconst allocTextExtents = (): ExternalObject<Handle> => alloc(TEXT_EXTENTS_SIZE);\nconst allocFontExtents = (): ExternalObject<Handle> => alloc(FONT_EXTENTS_SIZE);\n\nconst readTextExtents = (handle: ExternalObject<Handle>): TextExtents => ({\n xBearing: DOUBLE.read(handle, 0) as number,\n yBearing: DOUBLE.read(handle, 8) as number,\n width: DOUBLE.read(handle, 16) as number,\n height: DOUBLE.read(handle, 24) as number,\n xAdvance: DOUBLE.read(handle, 32) as number,\n yAdvance: DOUBLE.read(handle, 40) as number,\n});\n\nconst readFontExtents = (handle: ExternalObject<Handle>): FontExtents => ({\n ascent: DOUBLE.read(handle, 0) as number,\n descent: DOUBLE.read(handle, 8) as number,\n height: DOUBLE.read(handle, 16) as number,\n maxXAdvance: DOUBLE.read(handle, 24) as number,\n maxYAdvance: DOUBLE.read(handle, 32) as number,\n});\n\nexport { allocClusterBuffer, allocFontExtents, allocGlyphBuffer, allocTextExtents, readFontExtents, readTextExtents };\n"]}
|
package/package.json
CHANGED
|
@@ -1,64 +1,63 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
"
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
"
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
"lint": {
|
|
46
|
-
"options": {
|
|
47
|
-
"cwd": ".",
|
|
48
|
-
"command": "eslint {projectRoot}"
|
|
49
|
-
}
|
|
50
|
-
}
|
|
2
|
+
"name": "@gtkx/cairo",
|
|
3
|
+
"version": "1.4.0",
|
|
4
|
+
"description": "Cairo drawing bindings for GTK: contexts, surfaces, patterns, fonts.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"gtkx",
|
|
7
|
+
"gtk",
|
|
8
|
+
"gtk4",
|
|
9
|
+
"cairo",
|
|
10
|
+
"drawing",
|
|
11
|
+
"graphics",
|
|
12
|
+
"linux",
|
|
13
|
+
"desktop"
|
|
14
|
+
],
|
|
15
|
+
"homepage": "https://gtkx.dev",
|
|
16
|
+
"bugs": {
|
|
17
|
+
"url": "https://github.com/gtkx-org/gtkx/issues"
|
|
18
|
+
},
|
|
19
|
+
"repository": {
|
|
20
|
+
"type": "git",
|
|
21
|
+
"url": "git+https://github.com/gtkx-org/gtkx.git",
|
|
22
|
+
"directory": "packages/cairo"
|
|
23
|
+
},
|
|
24
|
+
"license": "MPL-2.0",
|
|
25
|
+
"author": "Eugenio Depalo <eugeniodepalo@gmail.com>",
|
|
26
|
+
"type": "module",
|
|
27
|
+
"sideEffects": true,
|
|
28
|
+
"exports": {
|
|
29
|
+
"./package.json": "./package.json",
|
|
30
|
+
".": {
|
|
31
|
+
"types": "./dist/index.d.ts",
|
|
32
|
+
"default": "./dist/index.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"files": [
|
|
36
|
+
"dist",
|
|
37
|
+
"src"
|
|
38
|
+
],
|
|
39
|
+
"nx": {
|
|
40
|
+
"targets": {
|
|
41
|
+
"lint": {
|
|
42
|
+
"options": {
|
|
43
|
+
"cwd": ".",
|
|
44
|
+
"command": "eslint {projectRoot}"
|
|
51
45
|
}
|
|
52
|
-
|
|
53
|
-
"engines": {
|
|
54
|
-
"node": ">=24"
|
|
55
|
-
},
|
|
56
|
-
"dependencies": {
|
|
57
|
-
"@gtkx/runtime": "workspace:*"
|
|
58
|
-
},
|
|
59
|
-
"devDependencies": {
|
|
60
|
-
"@gtkx/vitest": "workspace:*",
|
|
61
|
-
"@types/node": "catalog:",
|
|
62
|
-
"fast-xml-parser": "^5.11.0"
|
|
46
|
+
}
|
|
63
47
|
}
|
|
64
|
-
}
|
|
48
|
+
},
|
|
49
|
+
"engines": {
|
|
50
|
+
"node": ">=24"
|
|
51
|
+
},
|
|
52
|
+
"dependencies": {
|
|
53
|
+
"@gtkx/runtime": "1.4.0"
|
|
54
|
+
},
|
|
55
|
+
"devDependencies": {
|
|
56
|
+
"@types/node": "^26.2.0",
|
|
57
|
+
"fast-xml-parser": "^5.11.0",
|
|
58
|
+
"@gtkx/vitest": "1.4.0"
|
|
59
|
+
},
|
|
60
|
+
"scripts": {
|
|
61
|
+
"release": "tsx ../../scripts/release-package.ts"
|
|
62
|
+
}
|
|
63
|
+
}
|
package/src/context.ts
CHANGED
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
setHandle,
|
|
9
9
|
t,
|
|
10
10
|
wrapHandle,
|
|
11
|
-
write,
|
|
12
11
|
} from "@gtkx/runtime";
|
|
13
12
|
import type {
|
|
14
13
|
Antialias,
|
|
@@ -61,6 +60,7 @@ import { allocMatrix, Matrix } from "./matrix.js";
|
|
|
61
60
|
import { parsePath } from "./path.js";
|
|
62
61
|
import { Pattern } from "./pattern.js";
|
|
63
62
|
import { ScaledFont } from "./scaled-font.js";
|
|
63
|
+
import { checkStatus } from "./status.js";
|
|
64
64
|
import { Surface } from "./surface.js";
|
|
65
65
|
import {
|
|
66
66
|
allocClusterBuffer,
|
|
@@ -74,6 +74,8 @@ import {
|
|
|
74
74
|
const CONTEXT_TYPE = cairoGType("cairo_gobject_context_get_type");
|
|
75
75
|
const RECTANGLE_SIZE = 32;
|
|
76
76
|
const RECTANGLE_LIST_COUNT_OFFSET = 16;
|
|
77
|
+
const DOUBLE = t.fieldAt(t.float64);
|
|
78
|
+
const RECTANGLE_LIST_COUNT = t.field(t.int32, RECTANGLE_LIST_COUNT_OFFSET);
|
|
77
79
|
const RECTANGLE_LIST_DATA_OFFSET = 8;
|
|
78
80
|
const POINT_ARGS = [CONTEXT_T, t.float64, t.float64];
|
|
79
81
|
const EXTENTS_ARGS = [CONTEXT_T, t.ref(t.float64), t.ref(t.float64), t.ref(t.float64), t.ref(t.float64)];
|
|
@@ -170,7 +172,6 @@ const cairoInStroke = bindCairo("cairo_in_stroke", POINT_ARGS, t.boolean);
|
|
|
170
172
|
const cairoInFill = bindCairo("cairo_in_fill", POINT_ARGS, t.boolean);
|
|
171
173
|
const cairoInClip = bindCairo("cairo_in_clip", POINT_ARGS, t.boolean);
|
|
172
174
|
const cairoCopyClipRectangleList = bindCairo("cairo_copy_clip_rectangle_list", [CONTEXT_T], RECTANGLE_LIST_T);
|
|
173
|
-
const cairoRectangleListDestroy = bindCairo("cairo_rectangle_list_destroy", [RECTANGLE_LIST_T], t.void);
|
|
174
175
|
const cairoMask = bindCairo("cairo_mask", [CONTEXT_T, PATTERN_T], t.void);
|
|
175
176
|
const cairoMaskSurface = bindCairo("cairo_mask_surface", [CONTEXT_T, SURFACE_T, t.float64, t.float64], t.void);
|
|
176
177
|
const cairoSetMatrix = bindCairo("cairo_set_matrix", [CONTEXT_T, MATRIX_T], t.void);
|
|
@@ -235,24 +236,24 @@ const allocDashBuffer = (dashes: number[]): ExternalObject<Handle> => {
|
|
|
235
236
|
const buffer = alloc(dashes.length * 8);
|
|
236
237
|
|
|
237
238
|
for (const [index, dash] of dashes.entries()) {
|
|
238
|
-
write(buffer,
|
|
239
|
+
DOUBLE.write(buffer, index * 8, dash);
|
|
239
240
|
}
|
|
240
241
|
|
|
241
242
|
return buffer;
|
|
242
243
|
};
|
|
243
244
|
|
|
244
245
|
const readDashes = (buffer: ExternalObject<Handle>, count: number): number[] =>
|
|
245
|
-
Array.from({ length: count }, (_, index) => read(buffer,
|
|
246
|
+
Array.from({ length: count }, (_, index) => DOUBLE.read(buffer, index * 8) as number);
|
|
246
247
|
|
|
247
248
|
const readRectangle = (rects: ExternalObject<Handle>, base: number): RectangleData => ({
|
|
248
|
-
x: read(rects,
|
|
249
|
-
y: read(rects,
|
|
250
|
-
width: read(rects,
|
|
251
|
-
height: read(rects,
|
|
249
|
+
x: DOUBLE.read(rects, base) as number,
|
|
250
|
+
y: DOUBLE.read(rects, base + 8) as number,
|
|
251
|
+
width: DOUBLE.read(rects, base + 16) as number,
|
|
252
|
+
height: DOUBLE.read(rects, base + 24) as number,
|
|
252
253
|
});
|
|
253
254
|
|
|
254
255
|
const readRectangleList = (listHandle: ExternalObject<Handle>): RectangleData[] => {
|
|
255
|
-
const count = read(listHandle
|
|
256
|
+
const count = RECTANGLE_LIST_COUNT.read(listHandle) as number;
|
|
256
257
|
|
|
257
258
|
if (count === 0) {
|
|
258
259
|
return [];
|
|
@@ -308,9 +309,11 @@ class Context {
|
|
|
308
309
|
/** GType of `CairoContext`, the boxed type this class is registered under. */
|
|
309
310
|
declare __type__: bigint;
|
|
310
311
|
|
|
311
|
-
/** Creates a context drawing onto `target
|
|
312
|
+
/** Creates a context drawing onto `target`, throwing when it cannot be created, such as on a finished surface. */
|
|
312
313
|
constructor(target: Surface) {
|
|
313
|
-
|
|
314
|
+
const handle = cairoCreate(getHandle(target)) as ExternalObject<Handle>;
|
|
315
|
+
checkStatus(cairoStatus(handle) as Status, "context");
|
|
316
|
+
setHandle(this, handle);
|
|
314
317
|
}
|
|
315
318
|
|
|
316
319
|
/** Begins a new sub-path at `(x, y)`, which becomes the current point. */
|
|
@@ -692,11 +695,7 @@ class Context {
|
|
|
692
695
|
|
|
693
696
|
/** Returns the current clip as a list of rectangles in user space. */
|
|
694
697
|
copyClipRectangleList(): RectangleData[] {
|
|
695
|
-
|
|
696
|
-
const rects = readRectangleList(listHandle);
|
|
697
|
-
cairoRectangleListDestroy(listHandle);
|
|
698
|
-
|
|
699
|
-
return rects;
|
|
698
|
+
return readRectangleList(cairoCopyClipRectangleList(getHandle(this)) as ExternalObject<Handle>);
|
|
700
699
|
}
|
|
701
700
|
|
|
702
701
|
/** Paints the current source using the alpha channel of `pattern` as a mask. */
|
package/src/font-face.ts
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
type WrapperClassResolver,
|
|
10
10
|
} from "@gtkx/runtime";
|
|
11
11
|
import { type FontSlant, FontType, type FontWeight, type Status } from "./enums.js";
|
|
12
|
-
import { bindCairo, cairoGType,
|
|
12
|
+
import { bindCairo, cairoGType, FONT_FACE_FULL_T, FONT_FACE_T } from "./lib.js";
|
|
13
13
|
|
|
14
14
|
/** One of the `FtSynthesize` styles a FreeType font face synthesizes. */
|
|
15
15
|
type FtSynthesize = (typeof FtSynthesize)[keyof typeof FtSynthesize];
|
|
@@ -24,24 +24,12 @@ const cairoFtFontFaceGetSynthesize = bindCairo("cairo_ft_font_face_get_synthesiz
|
|
|
24
24
|
const cairoFtFontFaceSetSynthesize = bindCairo("cairo_ft_font_face_set_synthesize", [FONT_FACE_T, t.int32], t.void);
|
|
25
25
|
const cairoToyFontFaceGetFamily = bindCairo("cairo_toy_font_face_get_family", [FONT_FACE_T], t.string("borrowed"));
|
|
26
26
|
|
|
27
|
-
const cairoFtFontFaceCreateForPattern = bindCairo(
|
|
28
|
-
"cairo_ft_font_face_create_for_pattern",
|
|
29
|
-
[FC_PATTERN_T],
|
|
30
|
-
FONT_FACE_FULL_T,
|
|
31
|
-
);
|
|
32
|
-
|
|
33
27
|
const cairoToyFontFaceCreate = bindCairo(
|
|
34
28
|
"cairo_toy_font_face_create",
|
|
35
29
|
[t.string("full"), t.int32, t.int32],
|
|
36
30
|
FONT_FACE_FULL_T,
|
|
37
31
|
);
|
|
38
32
|
|
|
39
|
-
const cairoFtFontFaceCreateForFtFace = bindCairo(
|
|
40
|
-
"cairo_ft_font_face_create_for_ft_face",
|
|
41
|
-
[FT_FACE_T, t.int32],
|
|
42
|
-
FONT_FACE_FULL_T,
|
|
43
|
-
);
|
|
44
|
-
|
|
45
33
|
const cairoFtFontFaceUnsetSynthesize = bindCairo(
|
|
46
34
|
"cairo_ft_font_face_unset_synthesize",
|
|
47
35
|
[FONT_FACE_T, t.int32],
|
|
@@ -75,7 +63,7 @@ const fontFaceClassFor: WrapperClassResolver = (handle) => {
|
|
|
75
63
|
|
|
76
64
|
/**
|
|
77
65
|
* A cairo font face (`cairo_font_face_t`): a typeface independent of size and transformation. Font faces come
|
|
78
|
-
* from
|
|
66
|
+
* from `create` or a context, and wrap as the concrete class their type reports
|
|
79
67
|
* (`instanceof ToyFontFace` after `selectFontFace`).
|
|
80
68
|
*/
|
|
81
69
|
abstract class FontFace {
|
|
@@ -89,16 +77,6 @@ abstract class FontFace {
|
|
|
89
77
|
return wrapHandle(cairoToyFontFaceCreate(family, slant, weight) as ExternalObject<Handle>, ToyFontFace);
|
|
90
78
|
}
|
|
91
79
|
|
|
92
|
-
/** Creates a font face for a FreeType `FT_Face` handle, with the given `FT_LOAD_*` flags. */
|
|
93
|
-
static createForFtFace(face: ExternalObject<Handle>, loadFlags: number): FtFontFace {
|
|
94
|
-
return wrapHandle(cairoFtFontFaceCreateForFtFace(face, loadFlags) as ExternalObject<Handle>, FtFontFace);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
/** Creates a font face for a fontconfig `FcPattern` handle. */
|
|
98
|
-
static createForPattern(pattern: ExternalObject<Handle>): FtFontFace {
|
|
99
|
-
return wrapHandle(cairoFtFontFaceCreateForPattern(pattern) as ExternalObject<Handle>, FtFontFace);
|
|
100
|
-
}
|
|
101
|
-
|
|
102
80
|
/** GType of `CairoFontFace`, the boxed type this class is registered under. */
|
|
103
81
|
declare __type__: bigint;
|
|
104
82
|
|
|
@@ -136,7 +114,7 @@ class ToyFontFace extends FontFace {
|
|
|
136
114
|
}
|
|
137
115
|
}
|
|
138
116
|
|
|
139
|
-
/** A FreeType font face
|
|
117
|
+
/** A FreeType font face returned by Cairo or another native library. */
|
|
140
118
|
class FtFontFace extends FontFace {
|
|
141
119
|
/** Returns the styles currently synthesized for the font face. */
|
|
142
120
|
getSynthesize(): FtSynthesize {
|
package/src/lib.ts
CHANGED
|
@@ -97,8 +97,6 @@ const SCALED_FONT_FULL_T: BoxedDescriptor = t.boxed("CairoScaledFont", {
|
|
|
97
97
|
getTypeFnName: "cairo_gobject_scaled_font_get_type",
|
|
98
98
|
});
|
|
99
99
|
|
|
100
|
-
const FC_PATTERN_T: BoxedDescriptor = t.boxed("FcPattern", { ownership: "borrowed", sharedLibrary: CAIRO_LIBRARY });
|
|
101
|
-
const FT_FACE_T: BoxedDescriptor = t.boxed("FT_Face", { ownership: "borrowed", sharedLibrary: CAIRO_LIBRARY });
|
|
102
100
|
const MATRIX_T: BoxedDescriptor = t.boxed("cairo_matrix_t", { ownership: "borrowed", sharedLibrary: CAIRO_LIBRARY });
|
|
103
101
|
|
|
104
102
|
const RECTANGLE_T: BoxedDescriptor = t.boxed("cairo_rectangle_t", {
|
|
@@ -117,8 +115,9 @@ const RECTANGLE_INT_ARRAY_T: BoxedDescriptor = t.boxed("cairo_rectangle_int_t[]"
|
|
|
117
115
|
});
|
|
118
116
|
|
|
119
117
|
const RECTANGLE_LIST_T: BoxedDescriptor = t.boxed("cairo_rectangle_list_t", {
|
|
120
|
-
ownership: "
|
|
118
|
+
ownership: "full",
|
|
121
119
|
sharedLibrary: CAIRO_LIBRARY,
|
|
120
|
+
freeFnName: "cairo_rectangle_list_destroy",
|
|
122
121
|
});
|
|
123
122
|
|
|
124
123
|
const GLYPH_T: BoxedDescriptor = t.boxed("cairo_glyph_t", { ownership: "borrowed", sharedLibrary: CAIRO_LIBRARY });
|
|
@@ -159,13 +158,11 @@ export {
|
|
|
159
158
|
CONTEXT_T,
|
|
160
159
|
DEVICE_T,
|
|
161
160
|
DOUBLE_BUFFER_T,
|
|
162
|
-
FC_PATTERN_T,
|
|
163
161
|
FONT_EXTENTS_T,
|
|
164
162
|
FONT_FACE_FULL_T,
|
|
165
163
|
FONT_FACE_T,
|
|
166
164
|
FONT_OPTIONS_FULL_T,
|
|
167
165
|
FONT_OPTIONS_T,
|
|
168
|
-
FT_FACE_T,
|
|
169
166
|
GLYPH_T,
|
|
170
167
|
MATRIX_T,
|
|
171
168
|
PATH_T,
|
package/src/path.ts
CHANGED
|
@@ -9,10 +9,13 @@ type SegmentReader = (data: PathBuffer, base: number) => PathData;
|
|
|
9
9
|
const ELEMENT_SIZE = 16;
|
|
10
10
|
const DATA_OFFSET = 8;
|
|
11
11
|
const NUM_DATA_OFFSET = 16;
|
|
12
|
+
const DOUBLE = t.fieldAt(t.float64);
|
|
13
|
+
const INT = t.fieldAt(t.int32);
|
|
14
|
+
const NUM_DATA = t.field(t.int32, NUM_DATA_OFFSET);
|
|
12
15
|
|
|
13
16
|
const readPoint = (data: PathBuffer, base: number): Point => ({
|
|
14
|
-
x: read(data,
|
|
15
|
-
y: read(data,
|
|
17
|
+
x: DOUBLE.read(data, base) as number,
|
|
18
|
+
y: DOUBLE.read(data, base + 8) as number,
|
|
16
19
|
});
|
|
17
20
|
|
|
18
21
|
const readMoveTo: SegmentReader = (data, base) => ({ type: "moveTo", ...readPoint(data, base + ELEMENT_SIZE) });
|
|
@@ -49,7 +52,7 @@ const segmentReaderFor = (headerType: PathDataType): SegmentReader | null => {
|
|
|
49
52
|
};
|
|
50
53
|
|
|
51
54
|
const parsePath = (pathHandle: PathBuffer): PathData[] => {
|
|
52
|
-
const numData = read(pathHandle
|
|
55
|
+
const numData = NUM_DATA.read(pathHandle) as number;
|
|
53
56
|
|
|
54
57
|
if (numData === 0) {
|
|
55
58
|
return [];
|
|
@@ -61,13 +64,13 @@ const parsePath = (pathHandle: PathBuffer): PathData[] => {
|
|
|
61
64
|
|
|
62
65
|
while (index < numData) {
|
|
63
66
|
const base = index * ELEMENT_SIZE;
|
|
64
|
-
const reader = segmentReaderFor(read(data,
|
|
67
|
+
const reader = segmentReaderFor(INT.read(data, base) as PathDataType);
|
|
65
68
|
|
|
66
69
|
if (reader !== null) {
|
|
67
70
|
segments.push(reader(data, base));
|
|
68
71
|
}
|
|
69
72
|
|
|
70
|
-
index += read(data,
|
|
73
|
+
index += INT.read(data, base + 4) as number;
|
|
71
74
|
}
|
|
72
75
|
|
|
73
76
|
return segments;
|
package/src/pattern.ts
CHANGED
|
@@ -8,7 +8,6 @@ import {
|
|
|
8
8
|
wrapHandle,
|
|
9
9
|
type WrapperClassResolver,
|
|
10
10
|
} from "@gtkx/runtime";
|
|
11
|
-
import type { Surface } from "./surface.js";
|
|
12
11
|
import type { ColorStop, LinearPoints, PathData, Point, RadialCircles, RgbaColor } from "./types.js";
|
|
13
12
|
import { type Extend, type Filter, PatternType, type Status } from "./enums.js";
|
|
14
13
|
import {
|
|
@@ -23,6 +22,8 @@ import {
|
|
|
23
22
|
} from "./lib.js";
|
|
24
23
|
import { allocMatrix, Matrix } from "./matrix.js";
|
|
25
24
|
import { parsePath } from "./path.js";
|
|
25
|
+
import { checkStatus } from "./status.js";
|
|
26
|
+
import { Surface } from "./surface.js";
|
|
26
27
|
|
|
27
28
|
type RgbaRefs = [
|
|
28
29
|
red: { value: number },
|
|
@@ -91,6 +92,7 @@ const cairoPatternSetMatrix = bindCairo("cairo_pattern_set_matrix", [PATTERN_T,
|
|
|
91
92
|
const cairoPatternGetMatrix = bindCairo("cairo_pattern_get_matrix", [PATTERN_T, MATRIX_T], t.void);
|
|
92
93
|
const cairoPatternGetType = bindCairo("cairo_pattern_get_type", [PATTERN_T], t.int32);
|
|
93
94
|
const cairoPatternGetReferenceCount = bindCairo("cairo_pattern_get_reference_count", [PATTERN_T], t.int32);
|
|
95
|
+
const cairoPatternGetSurface = bindCairo("cairo_pattern_get_surface", [PATTERN_T, t.ref(SURFACE_T)], t.int32);
|
|
94
96
|
|
|
95
97
|
const cairoPatternGetLinearPoints = bindCairo(
|
|
96
98
|
"cairo_pattern_get_linear_points",
|
|
@@ -155,6 +157,12 @@ const cairoMeshPatternGetCornerColorRgba = bindCairo(
|
|
|
155
157
|
|
|
156
158
|
const wrapPattern = (handle: unknown): Pattern => wrapHandle(handle as ExternalObject<Handle>, Pattern);
|
|
157
159
|
|
|
160
|
+
const checkPattern = <T extends Pattern>(pattern: T): T => {
|
|
161
|
+
checkStatus(pattern.status(), "pattern");
|
|
162
|
+
|
|
163
|
+
return pattern;
|
|
164
|
+
};
|
|
165
|
+
|
|
158
166
|
const readRgba = (fill: (...refs: RgbaRefs) => void): RgbaColor => {
|
|
159
167
|
const red = { value: 0 };
|
|
160
168
|
const green = { value: 0 };
|
|
@@ -203,17 +211,19 @@ abstract class Pattern {
|
|
|
203
211
|
|
|
204
212
|
/** Creates an opaque solid-color pattern. */
|
|
205
213
|
static createRgb(red: number, green: number, blue: number): Pattern {
|
|
206
|
-
return wrapPattern(cairoPatternCreateRgb(red, green, blue));
|
|
214
|
+
return checkPattern(wrapPattern(cairoPatternCreateRgb(red, green, blue)));
|
|
207
215
|
}
|
|
208
216
|
|
|
209
217
|
/** Creates a translucent solid-color pattern. */
|
|
210
218
|
static createRgba(red: number, green: number, blue: number, alpha: number): Pattern {
|
|
211
|
-
return wrapPattern(cairoPatternCreateRgba(red, green, blue, alpha));
|
|
219
|
+
return checkPattern(wrapPattern(cairoPatternCreateRgba(red, green, blue, alpha)));
|
|
212
220
|
}
|
|
213
221
|
|
|
214
222
|
/** Creates a linear gradient between `(x0, y0)` and `(x1, y1)`; add stops with `addColorStopRgba`. */
|
|
215
223
|
static createLinear(x0: number, y0: number, x1: number, y1: number): LinearPattern {
|
|
216
|
-
|
|
224
|
+
const handle = cairoPatternCreateLinear(x0, y0, x1, y1) as ExternalObject<Handle>;
|
|
225
|
+
|
|
226
|
+
return checkPattern(wrapHandle(handle, LinearPattern));
|
|
217
227
|
}
|
|
218
228
|
|
|
219
229
|
/** Creates a radial gradient between two circles; add stops with `addColorStopRgba`. */
|
|
@@ -227,17 +237,19 @@ abstract class Pattern {
|
|
|
227
237
|
): RadialPattern {
|
|
228
238
|
const handle = cairoPatternCreateRadial(cx0, cy0, radius0, cx1, cy1, radius1) as ExternalObject<Handle>;
|
|
229
239
|
|
|
230
|
-
return wrapHandle(handle, RadialPattern);
|
|
240
|
+
return checkPattern(wrapHandle(handle, RadialPattern));
|
|
231
241
|
}
|
|
232
242
|
|
|
233
243
|
/** Creates an empty mesh gradient; describe its patches with the `MeshPattern` methods. */
|
|
234
244
|
static createMesh(): MeshPattern {
|
|
235
|
-
return wrapHandle(cairoPatternCreateMesh() as ExternalObject<Handle>, MeshPattern);
|
|
245
|
+
return checkPattern(wrapHandle(cairoPatternCreateMesh() as ExternalObject<Handle>, MeshPattern));
|
|
236
246
|
}
|
|
237
247
|
|
|
238
248
|
/** Creates a pattern that paints with the content of `surface`. */
|
|
239
249
|
static createForSurface(surface: Surface): Pattern {
|
|
240
|
-
|
|
250
|
+
const handle = getHandle(surface);
|
|
251
|
+
|
|
252
|
+
return checkPattern(wrapPattern(cairoPatternCreateForSurface(handle)));
|
|
241
253
|
}
|
|
242
254
|
|
|
243
255
|
/** GType of `CairoPattern`, the boxed type this class is registered under. */
|
|
@@ -318,6 +330,18 @@ abstract class Pattern {
|
|
|
318
330
|
getReferenceCount(): number {
|
|
319
331
|
return cairoPatternGetReferenceCount(getHandle(this)) as number;
|
|
320
332
|
}
|
|
333
|
+
|
|
334
|
+
/** Returns the surface of a surface pattern; throws for a pattern that has no surface. */
|
|
335
|
+
getSurface(): Surface {
|
|
336
|
+
const surface: { value: ExternalObject<Handle> | null } = { value: null };
|
|
337
|
+
checkStatus(cairoPatternGetSurface(getHandle(this), surface) as Status, "pattern");
|
|
338
|
+
|
|
339
|
+
if (surface.value === null) {
|
|
340
|
+
throw new Error("cairo pattern has no surface");
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
return wrapHandle(surface.value, Surface);
|
|
344
|
+
}
|
|
321
345
|
}
|
|
322
346
|
|
|
323
347
|
/** A linear gradient pattern, created with `Pattern.createLinear`. */
|
package/src/region.ts
CHANGED
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
setHandle,
|
|
8
8
|
t,
|
|
9
9
|
wrapHandle,
|
|
10
|
-
write,
|
|
11
10
|
} from "@gtkx/runtime";
|
|
12
11
|
import type { RegionOverlap, Status } from "./enums.js";
|
|
13
12
|
import type { RectangleData } from "./types.js";
|
|
@@ -53,16 +52,17 @@ const cairoRegionIntersectRectangle = bindCairo("cairo_region_intersect_rectangl
|
|
|
53
52
|
const cairoRegionSubtractRectangle = bindCairo("cairo_region_subtract_rectangle", RECTANGLE_OP_ARGS, t.int32);
|
|
54
53
|
const cairoRegionUnionRectangle = bindCairo("cairo_region_union_rectangle", RECTANGLE_OP_ARGS, t.int32);
|
|
55
54
|
const cairoRegionXorRectangle = bindCairo("cairo_region_xor_rectangle", RECTANGLE_OP_ARGS, t.int32);
|
|
55
|
+
const INT = t.fieldAt(t.int32);
|
|
56
56
|
|
|
57
57
|
const allocRectangleBuffer = (rects: RectangleData[]): ExternalObject<Handle> => {
|
|
58
58
|
const buffer = alloc(rects.length * RECTANGLE_INT_SIZE);
|
|
59
59
|
let offset = 0;
|
|
60
60
|
|
|
61
61
|
for (const rect of rects) {
|
|
62
|
-
write(buffer,
|
|
63
|
-
write(buffer,
|
|
64
|
-
write(buffer,
|
|
65
|
-
write(buffer,
|
|
62
|
+
INT.write(buffer, offset, rect.x);
|
|
63
|
+
INT.write(buffer, offset + 4, rect.y);
|
|
64
|
+
INT.write(buffer, offset + 8, rect.width);
|
|
65
|
+
INT.write(buffer, offset + 12, rect.height);
|
|
66
66
|
offset += RECTANGLE_INT_SIZE;
|
|
67
67
|
}
|
|
68
68
|
|
package/src/scaled-font.ts
CHANGED
|
@@ -2,14 +2,13 @@ import {
|
|
|
2
2
|
type ExternalObject,
|
|
3
3
|
getHandle,
|
|
4
4
|
type Handle,
|
|
5
|
-
read,
|
|
6
5
|
registerWrapperClass,
|
|
7
6
|
setHandle,
|
|
8
7
|
t,
|
|
9
8
|
wrapHandle,
|
|
10
9
|
} from "@gtkx/runtime";
|
|
11
|
-
import type { FontType, Status
|
|
12
|
-
import type { CairoGlyph,
|
|
10
|
+
import type { FontType, Status } from "./enums.js";
|
|
11
|
+
import type { CairoGlyph, FontExtents, TextExtents } from "./types.js";
|
|
13
12
|
import { FontFace } from "./font-face.js";
|
|
14
13
|
import { FontOptions } from "./font-options.js";
|
|
15
14
|
import {
|
|
@@ -23,23 +22,18 @@ import {
|
|
|
23
22
|
MATRIX_T,
|
|
24
23
|
SCALED_FONT_FULL_T,
|
|
25
24
|
SCALED_FONT_T,
|
|
26
|
-
TEXT_CLUSTER_T,
|
|
27
25
|
TEXT_EXTENTS_T,
|
|
28
26
|
} from "./lib.js";
|
|
29
27
|
import { allocMatrix, Matrix } from "./matrix.js";
|
|
30
28
|
import { allocFontExtents, allocGlyphBuffer, allocTextExtents, readFontExtents, readTextExtents } from "./text.js";
|
|
31
29
|
|
|
32
30
|
const SCALED_FONT_TYPE = cairoGType("cairo_gobject_scaled_font_get_type");
|
|
33
|
-
const GLYPH_SIZE = 24;
|
|
34
|
-
const CLUSTER_SIZE = 8;
|
|
35
31
|
const cairoScaledFontStatus = bindCairo("cairo_scaled_font_status", [SCALED_FONT_T], t.int32);
|
|
36
32
|
const cairoScaledFontExtents = bindCairo("cairo_scaled_font_extents", [SCALED_FONT_T, FONT_EXTENTS_T], t.void);
|
|
37
33
|
const cairoScaledFontGetFontFace = bindCairo("cairo_scaled_font_get_font_face", [SCALED_FONT_T], FONT_FACE_T);
|
|
38
34
|
const cairoScaledFontGetFontMatrix = bindCairo("cairo_scaled_font_get_font_matrix", [SCALED_FONT_T, MATRIX_T], t.void);
|
|
39
35
|
const cairoScaledFontGetCtm = bindCairo("cairo_scaled_font_get_ctm", [SCALED_FONT_T, MATRIX_T], t.void);
|
|
40
36
|
const cairoScaledFontGetType = bindCairo("cairo_scaled_font_get_type", [SCALED_FONT_T], t.int32);
|
|
41
|
-
const cairoGlyphFree = bindCairo("cairo_glyph_free", [GLYPH_T], t.void);
|
|
42
|
-
const cairoTextClusterFree = bindCairo("cairo_text_cluster_free", [TEXT_CLUSTER_T], t.void);
|
|
43
37
|
|
|
44
38
|
const cairoScaledFontCreate = bindCairo(
|
|
45
39
|
"cairo_scaled_font_create",
|
|
@@ -77,23 +71,6 @@ const cairoScaledFontGetReferenceCount = bindCairo(
|
|
|
77
71
|
t.int32,
|
|
78
72
|
);
|
|
79
73
|
|
|
80
|
-
const cairoScaledFontTextToGlyphs = bindCairo(
|
|
81
|
-
"cairo_scaled_font_text_to_glyphs",
|
|
82
|
-
[
|
|
83
|
-
SCALED_FONT_T,
|
|
84
|
-
t.float64,
|
|
85
|
-
t.float64,
|
|
86
|
-
t.string("full"),
|
|
87
|
-
t.int32,
|
|
88
|
-
t.ref(t.struct("borrowed")),
|
|
89
|
-
t.ref(t.int32),
|
|
90
|
-
t.ref(t.struct("borrowed")),
|
|
91
|
-
t.ref(t.int32),
|
|
92
|
-
t.ref(t.int32),
|
|
93
|
-
],
|
|
94
|
-
t.int32,
|
|
95
|
-
);
|
|
96
|
-
|
|
97
74
|
const readMatrixVia = (self: ScaledFont, boundFn: BoundFunction): Matrix => {
|
|
98
75
|
const { handle, matrix } = allocMatrix();
|
|
99
76
|
boundFn(getHandle(self), handle);
|
|
@@ -101,40 +78,9 @@ const readMatrixVia = (self: ScaledFont, boundFn: BoundFunction): Matrix => {
|
|
|
101
78
|
return matrix;
|
|
102
79
|
};
|
|
103
80
|
|
|
104
|
-
const readGlyphs = (buffer: ExternalObject<Handle> | null, count: number): CairoGlyph[] => {
|
|
105
|
-
if (buffer === null) {
|
|
106
|
-
return [];
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return Array.from({ length: count }, (_, index) => {
|
|
110
|
-
const offset = index * GLYPH_SIZE;
|
|
111
|
-
|
|
112
|
-
return {
|
|
113
|
-
index: read(buffer, t.uint64, offset) as number,
|
|
114
|
-
x: read(buffer, t.float64, offset + 8) as number,
|
|
115
|
-
y: read(buffer, t.float64, offset + 16) as number,
|
|
116
|
-
};
|
|
117
|
-
});
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
const readClusters = (buffer: ExternalObject<Handle> | null, count: number): CairoTextCluster[] => {
|
|
121
|
-
if (buffer === null) {
|
|
122
|
-
return [];
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
return Array.from({ length: count }, (_, index) => {
|
|
126
|
-
const offset = index * CLUSTER_SIZE;
|
|
127
|
-
|
|
128
|
-
return {
|
|
129
|
-
numBytes: read(buffer, t.int32, offset) as number,
|
|
130
|
-
numGlyphs: read(buffer, t.int32, offset + 4) as number,
|
|
131
|
-
};
|
|
132
|
-
});
|
|
133
|
-
};
|
|
134
|
-
|
|
135
81
|
/**
|
|
136
82
|
* A cairo scaled font (`cairo_scaled_font_t`): a font face frozen at a given font matrix, transformation and
|
|
137
|
-
* set of font options, ready to measure and
|
|
83
|
+
* set of font options, ready to measure text and positioned glyphs.
|
|
138
84
|
*/
|
|
139
85
|
class ScaledFont {
|
|
140
86
|
static {
|
|
@@ -228,41 +174,6 @@ class ScaledFont {
|
|
|
228
174
|
getReferenceCount(): number {
|
|
229
175
|
return cairoScaledFontGetReferenceCount(getHandle(this)) as number;
|
|
230
176
|
}
|
|
231
|
-
|
|
232
|
-
/** Shapes `text` starting at `(x, y)` into glyphs, clusters and the flags describing their order. */
|
|
233
|
-
textToGlyphs(x: number, y: number, text: string): [CairoGlyph[], CairoTextCluster[], TextClusterFlags] {
|
|
234
|
-
const glyphsRef: { value: ExternalObject<Handle> | null } = { value: null };
|
|
235
|
-
const numGlyphsRef = { value: 0 };
|
|
236
|
-
const clustersRef: { value: ExternalObject<Handle> | null } = { value: null };
|
|
237
|
-
const numClustersRef = { value: 0 };
|
|
238
|
-
const clusterFlagsRef = { value: 0 };
|
|
239
|
-
|
|
240
|
-
cairoScaledFontTextToGlyphs(
|
|
241
|
-
getHandle(this),
|
|
242
|
-
x,
|
|
243
|
-
y,
|
|
244
|
-
text,
|
|
245
|
-
-1,
|
|
246
|
-
glyphsRef,
|
|
247
|
-
numGlyphsRef,
|
|
248
|
-
clustersRef,
|
|
249
|
-
numClustersRef,
|
|
250
|
-
clusterFlagsRef,
|
|
251
|
-
);
|
|
252
|
-
|
|
253
|
-
const glyphs = readGlyphs(glyphsRef.value, numGlyphsRef.value);
|
|
254
|
-
const clusters = readClusters(clustersRef.value, numClustersRef.value);
|
|
255
|
-
|
|
256
|
-
if (glyphsRef.value !== null) {
|
|
257
|
-
cairoGlyphFree(glyphsRef.value);
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
if (clustersRef.value !== null) {
|
|
261
|
-
cairoTextClusterFree(clustersRef.value);
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
return [glyphs, clusters, clusterFlagsRef.value as TextClusterFlags];
|
|
265
|
-
}
|
|
266
177
|
}
|
|
267
178
|
|
|
268
179
|
export { ScaledFont };
|