@ts-for-gir/templates 4.0.0-beta.38 → 4.0.0-beta.40
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/package.json +1 -1
- package/templates/gjs/cairo.d.ts +90 -4
package/package.json
CHANGED
package/templates/gjs/cairo.d.ts
CHANGED
|
@@ -52,6 +52,23 @@ import Cairo from '<%- Cairo.importPath %>';
|
|
|
52
52
|
yAdvance: number;
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
+
/**
|
|
56
|
+
* Font metrics in user-space coordinates (cairo_font_extents_t).
|
|
57
|
+
* Not present in cairo-gobject GIR; defined locally to match the C API.
|
|
58
|
+
*/
|
|
59
|
+
export interface FontExtents {
|
|
60
|
+
/** Distance the font extends above the baseline */
|
|
61
|
+
ascent: number;
|
|
62
|
+
/** Distance the font extends below the baseline (positive for typical fonts) */
|
|
63
|
+
descent: number;
|
|
64
|
+
/** Recommended vertical distance between baselines for consecutive lines */
|
|
65
|
+
height: number;
|
|
66
|
+
/** Maximum X advance for any glyph */
|
|
67
|
+
max_x_advance: number;
|
|
68
|
+
/** Maximum Y advance for any glyph (typically 0 for horizontal text) */
|
|
69
|
+
max_y_advance: number;
|
|
70
|
+
}
|
|
71
|
+
|
|
55
72
|
/**
|
|
56
73
|
* The main Cairo drawing context
|
|
57
74
|
*
|
|
@@ -540,6 +557,39 @@ import Cairo from '<%- Cairo.importPath %>';
|
|
|
540
557
|
*/
|
|
541
558
|
textExtents(utf8: string): TextExtents;
|
|
542
559
|
|
|
560
|
+
/**
|
|
561
|
+
* Gets the font extents for the currently selected font
|
|
562
|
+
* @returns Font extents in user-space coordinates
|
|
563
|
+
*/
|
|
564
|
+
getFontExtents(): FontExtents;
|
|
565
|
+
|
|
566
|
+
/**
|
|
567
|
+
* Renders an array of glyphs at the current point (low-level text API)
|
|
568
|
+
* @param glyphs Array of glyphs to show
|
|
569
|
+
*/
|
|
570
|
+
showGlyphs(glyphs: Glyph[]): void;
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* Renders glyphs with embedded text and cluster mapping (e.g. for PDF/PS)
|
|
574
|
+
* @param utf8 UTF-8 text string
|
|
575
|
+
* @param glyphs Array of glyphs
|
|
576
|
+
* @param clusters Cluster mapping (bytes to glyphs)
|
|
577
|
+
* @param clusterFlags Direction of cluster mapping
|
|
578
|
+
*/
|
|
579
|
+
showTextGlyphs(
|
|
580
|
+
utf8: string,
|
|
581
|
+
glyphs: Glyph[],
|
|
582
|
+
clusters: TextCluster[],
|
|
583
|
+
clusterFlags: TextClusterFlags,
|
|
584
|
+
): void;
|
|
585
|
+
|
|
586
|
+
/**
|
|
587
|
+
* Computes the extents of an array of glyphs in user-space coordinates
|
|
588
|
+
* @param glyphs Array of glyphs
|
|
589
|
+
* @returns Extents as [x_bearing, y_bearing, width, height, x_advance, y_advance]
|
|
590
|
+
*/
|
|
591
|
+
glyphExtents(glyphs: Glyph[]): TextExtents;
|
|
592
|
+
|
|
543
593
|
/**
|
|
544
594
|
* Translates the current transformation matrix
|
|
545
595
|
* @param tx Translation in the X direction
|
|
@@ -615,6 +665,21 @@ import Cairo from '<%- Cairo.importPath %>';
|
|
|
615
665
|
* Finishes the surface and drops all references to external resources
|
|
616
666
|
*/
|
|
617
667
|
finish(): void;
|
|
668
|
+
|
|
669
|
+
/**
|
|
670
|
+
* Attaches user data to the surface (C API: cairo_surface_set_user_data)
|
|
671
|
+
* @param key Key for the user data
|
|
672
|
+
* @param userData Data to attach
|
|
673
|
+
* @param destroy Optional callback when the surface is destroyed or data is replaced
|
|
674
|
+
*/
|
|
675
|
+
set_user_data(key: UserDataKey, userData: unknown, destroy?: (data: unknown) => void): Status;
|
|
676
|
+
|
|
677
|
+
/**
|
|
678
|
+
* Returns user data attached to the surface (C API: cairo_surface_get_user_data)
|
|
679
|
+
* @param key Key used when setting the data
|
|
680
|
+
* @returns The attached data or null
|
|
681
|
+
*/
|
|
682
|
+
get_user_data(key: UserDataKey): unknown;
|
|
618
683
|
}
|
|
619
684
|
|
|
620
685
|
/**
|
|
@@ -828,14 +893,35 @@ import Cairo from '<%- Cairo.importPath %>';
|
|
|
828
893
|
export class ScaledFont extends Cairo.ScaledFont {}
|
|
829
894
|
|
|
830
895
|
/**
|
|
831
|
-
* A glyph object used for storing and manipulating glyphs
|
|
896
|
+
* A glyph object used for storing and manipulating glyphs (cairo_glyph_t).
|
|
897
|
+
* Defined locally so the template works even when the generated cairo-1.0
|
|
898
|
+
* does not include this record (GIR may omit it in some setups).
|
|
832
899
|
*/
|
|
833
|
-
export
|
|
900
|
+
export interface Glyph {
|
|
901
|
+
index: number;
|
|
902
|
+
x: number;
|
|
903
|
+
y: number;
|
|
904
|
+
}
|
|
834
905
|
|
|
835
906
|
/**
|
|
836
|
-
* A text cluster object used for storing and manipulating text clusters
|
|
907
|
+
* A text cluster object used for storing and manipulating text clusters (cairo_text_cluster_t).
|
|
908
|
+
* Defined locally so the template works even when the generated cairo-1.0
|
|
909
|
+
* does not include this record (GIR may omit it in some setups).
|
|
837
910
|
*/
|
|
838
|
-
export
|
|
911
|
+
export interface TextCluster {
|
|
912
|
+
num_bytes: number;
|
|
913
|
+
num_glyphs: number;
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
/**
|
|
917
|
+
* Key for attaching user data to surfaces/contexts (cairo_user_data_key_t).
|
|
918
|
+
* In C only the key's address matters; in GJS any object can serve as key.
|
|
919
|
+
* Not in cairo-gobject GIR; defined locally for set_user_data/get_user_data.
|
|
920
|
+
*/
|
|
921
|
+
export interface UserDataKey {
|
|
922
|
+
/** Unused in C; present only for ABI. In GJS keys are typically plain objects. */
|
|
923
|
+
readonly unused?: number;
|
|
924
|
+
}
|
|
839
925
|
|
|
840
926
|
/**
|
|
841
927
|
* A font options object used for storing and manipulating font options
|