diff options
author | Antonio Ospite <ao2@ao2.it> | 2017-10-11 18:51:13 +0200 |
---|---|---|
committer | Bryce Harrington <bryce@osg.samsung.com> | 2017-12-04 13:58:34 -0800 |
commit | 15559b54af473d720da9e03b0e769c54a53505a9 (patch) | |
tree | 44803ff66f4f67ed3eebe98c2fb05a39a18e14b7 /src/cairo-svg.h | |
parent | 84fc0ce91d1a57d20500f710abc0e17de82c67df (diff) | |
download | cairo-15559b54af473d720da9e03b0e769c54a53505a9.tar.gz |
svg: add a new function to specify the SVG document unit
Add a cairo_svg_surface_set_document_unit() function to allow users to
set a unit for the width and height values of the root <svg> element.
In particular this allows to draw in pixels and still have the expected
result when generating SVG output.
Add also the correspondent getter function.
Fixes: https://bugs.freedesktop.org/show_bug.cgi?id=90166
Reviewed-by: Bryce Harrington <bryce@osg.samsung.com>
Diffstat (limited to 'src/cairo-svg.h')
-rw-r--r-- | src/cairo-svg.h | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/src/cairo-svg.h b/src/cairo-svg.h index 592c645f6..95434dcf6 100644 --- a/src/cairo-svg.h +++ b/src/cairo-svg.h @@ -53,6 +53,46 @@ typedef enum _cairo_svg_version { CAIRO_SVG_VERSION_1_2 } cairo_svg_version_t; +/** + * cairo_svg_version_t: + * + * @CAIRO_SVG_UNIT_USER: User unit, a value in the current coordinate system. + * If used in the root element for the initial coordinate systems it + * corresponds to pixels. (Since 1.16) + * @CAIRO_SVG_UNIT_EM: The size of the element's font. (Since 1.16) + * @CAIRO_SVG_UNIT_EX: The x-height of the element’s font. (Since 1.16) + * @CAIRO_SVG_UNIT_PX: Pixels (1px = 1/96th of 1in). (Since 1.16) + * @CAIRO_SVG_UNIT_IN: Inches (1in = 2.54cm = 96px). (Since 1.16) + * @CAIRO_SVG_UNIT_CM: Centimeters (1cm = 96px/2.54). (Since 1.16) + * @CAIRO_SVG_UNIT_MM: Millimeters (1mm = 1/10th of 1cm). (Since 1.16) + * @CAIRO_SVG_UNIT_PT: Points (1pt = 1/72th of 1in). (Since 1.16) + * @CAIRO_SVG_UNIT_PC: Picas (1pc = 1/6th of 1in). (Since 1.16) + * @CAIRO_SVG_UNIT_PERCENT: Percent, a value that is some fraction of another + * reference value. (Since 1.16) + * + * #cairo_svg_unit_t is used to describe the units valid for coordinates and + * lengths in the SVG specification. + * + * See also: + * https://www.w3.org/TR/SVG/coords.html#Units + * https://www.w3.org/TR/SVG/types.html#DataTypeLength + * https://www.w3.org/TR/css-values-3/#lengths + * + * Since: 1.16 + **/ +typedef enum _cairo_svg_unit { + CAIRO_SVG_UNIT_USER = 0, + CAIRO_SVG_UNIT_EM, + CAIRO_SVG_UNIT_EX, + CAIRO_SVG_UNIT_PX, + CAIRO_SVG_UNIT_IN, + CAIRO_SVG_UNIT_CM, + CAIRO_SVG_UNIT_MM, + CAIRO_SVG_UNIT_PT, + CAIRO_SVG_UNIT_PC, + CAIRO_SVG_UNIT_PERCENT +} cairo_svg_unit_t; + cairo_public cairo_surface_t * cairo_svg_surface_create (const char *filename, double width_in_points, @@ -75,6 +115,13 @@ cairo_svg_get_versions (cairo_svg_version_t const **versions, cairo_public const char * cairo_svg_version_to_string (cairo_svg_version_t version); +cairo_public void +cairo_svg_surface_set_document_unit (cairo_surface_t *surface, + cairo_svg_unit_t unit); + +cairo_public cairo_svg_unit_t +cairo_svg_surface_get_document_unit (cairo_surface_t *surface); + CAIRO_END_DECLS #else /* CAIRO_HAS_SVG_SURFACE */ |