From c5758bf996f7fc490f2c9a03b860c7dfa48c5bd0 Mon Sep 17 00:00:00 2001 From: Sergey Fedorov Date: Sun, 16 Aug 2026 10:43:19 +0000 Subject: [PATCH 2/7] rsvg: Add the public RsvgRectangle, RsvgUnit and RsvgLength types These are the types the librsvg 2.46 API is expressed in. Adding them on their own already fixes part of what downstream projects trip over, since several of them fail to compile purely on 'RsvgRectangle was not declared in this scope' before reaching any function call. RsvgUnit carries members for units this build never reports, because absolute lengths are normalized to inches while parsing. They exist so that code written against 2.46 compiles and handles them gracefully. Also list rsvg_handle_set_stylesheet and rsvg_handle_internal_set_testing in rsvg.symbols; both are public but were never exported on Windows. --- librsvg/rsvg.h | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++ rsvg.symbols | 2 ++ 2 files changed, 77 insertions(+) diff --git a/librsvg/rsvg.h b/librsvg/rsvg.h index f166c654b..2d5113705 100644 --- a/librsvg/rsvg.h +++ b/librsvg/rsvg.h @@ -75,6 +75,7 @@ typedef struct RsvgHandlePrivate RsvgHandlePrivate; typedef struct _RsvgHandleClass RsvgHandleClass; typedef struct _RsvgDimensionData RsvgDimensionData; typedef struct _RsvgPositionData RsvgPositionData; +typedef struct _RsvgRectangle RsvgRectangle; /** * RsvgHandleClass: @@ -125,6 +126,80 @@ struct _RsvgPositionData { int y; }; +/** + * RsvgRectangle: + * @x: X coordinate of the left side of the rectangle + * @y: Y coordinate of the the top side of the rectangle + * @width: width of the rectangle + * @height: height of the rectangle + * + * A data structure for holding a rectangle. + * + * Since: 2.46 + */ +struct _RsvgRectangle { + double x; + double y; + double width; + double height; +}; + +/** + * RsvgUnit: + * @RSVG_UNIT_PERCENT: percentage values; where 1.0 means 100%. + * @RSVG_UNIT_PX: pixels + * @RSVG_UNIT_EM: em, or the current font size + * @RSVG_UNIT_EX: x-height of the current font + * @RSVG_UNIT_IN: inches + * @RSVG_UNIT_CM: centimeters + * @RSVG_UNIT_MM: millimeters + * @RSVG_UNIT_PT: points, or 1/72 inch + * @RSVG_UNIT_PC: picas, or 1/6 inch (12 points) + * @RSVG_UNIT_CH: advance measure of a '0' character + * + * Units for the #RsvgLength struct. These have the same meaning as + * CSS length + * units. + * + * Note that this build of librsvg normalizes absolute lengths to inches while + * parsing, so lengths that were authored as cm, + * mm, pt or pc are + * reported as %RSVG_UNIT_IN with an equivalent value. The other enum members + * exist so that code written against librsvg 2.46 and later compiles and + * handles them gracefully. + * + * Since: 2.46 + */ +typedef enum { + RSVG_UNIT_PERCENT, + RSVG_UNIT_PX, + RSVG_UNIT_EM, + RSVG_UNIT_EX, + RSVG_UNIT_IN, + RSVG_UNIT_CM, + RSVG_UNIT_MM, + RSVG_UNIT_PT, + RSVG_UNIT_PC, + RSVG_UNIT_CH +} RsvgUnit; + +/** + * RsvgLength: + * @length: numeric part of the length + * @unit: unit part of the length + * + * #RsvgLength values are used in rsvg_handle_get_intrinsic_dimensions(), for + * example, to return the CSS length values of the width and + * height attributes of an <svg> + * element. + * + * Since: 2.46 + */ +typedef struct { + double length; + RsvgUnit unit; +} RsvgLength; + void rsvg_cleanup (void); void rsvg_set_default_dpi (double dpi); diff --git a/rsvg.symbols b/rsvg.symbols index d224c5646..44bce7189 100644 --- a/rsvg.symbols +++ b/rsvg.symbols @@ -10,6 +10,8 @@ rsvg_handle_get_pixbuf rsvg_handle_get_pixbuf_sub rsvg_handle_get_type rsvg_handle_has_sub +rsvg_handle_internal_set_testing +rsvg_handle_set_stylesheet rsvg_handle_new rsvg_handle_new_from_data rsvg_handle_new_from_file -- 2.43.0