Skip to content
This repository has been archived by the owner on Jun 8, 2021. It is now read-only.

Commit

Permalink
Merge pull request #165 from meh/everything
Browse files Browse the repository at this point in the history
Better support for PDF, SVG and PostScript.
  • Loading branch information
GuillaumeGomez authored Nov 15, 2018
2 parents c17c3ee + d39b674 commit d00687e
Show file tree
Hide file tree
Showing 9 changed files with 1,141 additions and 3 deletions.
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ name = "cairo"
[features]
purge-lgpl-docs = ["gtk-rs-lgpl-docs"]
png = ["cairo-sys-rs/png"]
pdf = ["cairo-sys-rs/pdf"]
svg = ["cairo-sys-rs/svg"]
ps = ["cairo-sys-rs/ps"]
use_glib = ["glib", "glib-sys", "gobject-sys", "cairo-sys-rs/use_glib"]
embed-lgpl-docs = ["gtk-rs-lgpl-docs"]
v1_12 = ["cairo-sys-rs/v1_12"]
Expand Down
3 changes: 3 additions & 0 deletions cairo-sys-rs/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@ v1_12 = []
v1_14 = ["v1_12"]
xlib = ["x11"]
png = []
pdf = []
svg = []
ps = []
xcb = []
use_glib = ["glib-sys", "gobject-sys", "glib"]

Expand Down
22 changes: 22 additions & 0 deletions cairo-sys-rs/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -430,6 +430,28 @@ pub enum RegionOverlap {
#[cfg(feature = "use_glib")]
gvalue_impl!(RegionOverlap, ::gobject::cairo_gobject_region_overlap_get_type);

#[cfg(any(feature = "pdf", feature = "dox"))]
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum PdfVersion {
_1_4,
_1_5,
}
#[cfg(any(feature = "svg", feature = "dox"))]
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum SvgVersion {
_1_1,
_1_2,
}
#[cfg(any(feature = "ps", feature = "dox"))]
#[repr(C)]
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum PsLevel {
_2,
_3,
}

#[cfg(test)]
mod tests {
use super::*;
Expand Down
58 changes: 58 additions & 0 deletions cairo-sys-rs/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,13 @@ use enums::{
Operator,
};

#[cfg(any(feature = "pdf", feature = "dox"))]
use enums::PdfVersion;
#[cfg(any(feature = "svg", feature = "dox"))]
use enums::SvgVersion;
#[cfg(any(feature = "ps", feature = "dox"))]
use enums::PsLevel;

macro_rules! debug_impl {
($name:ty) => {
impl ::std::fmt::Debug for $name {
Expand Down Expand Up @@ -565,6 +572,57 @@ extern "C" {
#[cfg(any(feature = "png", feature = "dox"))]
pub fn cairo_surface_write_to_png_stream(surface: *mut cairo_surface_t, write_func: cairo_write_func_t, closure: *mut c_void) -> Status;

// CAIRO PDF
#[cfg(any(feature = "pdf", feature = "dox"))]
pub fn cairo_pdf_surface_create (filename: *const c_char,
width_in_points: c_double,
height_in_points: c_double) -> *mut cairo_surface_t;
#[cfg(any(feature = "pdf", feature = "dox"))]
pub fn cairo_pdf_surface_create_for_stream (write_func: cairo_write_func_t,
closure: *mut c_void,
width_in_points: c_double,
height_in_points: c_double) -> *mut cairo_surface_t;
#[cfg(any(feature = "pdf", feature = "dox"))]
pub fn cairo_pdf_surface_restrict_to_version (surface: *mut cairo_surface_t, version: PdfVersion);
// CAIRO SVG
#[cfg(any(feature = "svg", feature = "dox"))]
pub fn cairo_svg_surface_create (filename: *const c_char,
width_in_points: c_double,
height_in_points: c_double) -> *mut cairo_surface_t;
#[cfg(any(feature = "svg", feature = "dox"))]
pub fn cairo_svg_surface_create_for_stream (write_func: cairo_write_func_t,
closure: *mut c_void,
width_in_points: c_double,
height_in_points: c_double) -> *mut cairo_surface_t;
#[cfg(any(feature = "svg", feature = "dox"))]
pub fn cairo_svg_surface_restrict_to_version (surface: *mut cairo_surface_t, version: SvgVersion);
// CAIRO PS
#[cfg(any(feature = "ps", feature = "dox"))]
pub fn cairo_ps_surface_create (filename: *const c_char,
width_in_points: c_double,
height_in_points: c_double) -> *mut cairo_surface_t;
#[cfg(any(feature = "ps", feature = "dox"))]
pub fn cairo_ps_surface_create_for_stream (write_func: cairo_write_func_t,
closure: *mut c_void,
width_in_points: c_double,
height_in_points: c_double) -> *mut cairo_surface_t;
#[cfg(any(feature = "ps", feature = "dox"))]
pub fn cairo_ps_surface_restrict_to_level (surface: *mut cairo_surface_t, version: PsLevel);
#[cfg(any(feature = "ps", feature = "dox"))]
pub fn cairo_ps_surface_set_eps (surface: *mut cairo_surface_t, eps: cairo_bool_t);
#[cfg(any(feature = "ps", feature = "dox"))]
pub fn cairo_ps_surface_get_eps (surface: *mut cairo_surface_t) -> cairo_bool_t;
#[cfg(any(feature = "ps", feature = "dox"))]
pub fn cairo_ps_surface_set_size (surface: *mut cairo_surface_t,
width_in_points: f64,
height_in_points: f64);
#[cfg(any(feature = "ps", feature = "dox"))]
pub fn cairo_ps_surface_dsc_begin_setup (surface: *mut cairo_surface_t);
#[cfg(any(feature = "ps", feature = "dox"))]
pub fn cairo_ps_surface_dsc_begin_page_setup (surface: *mut cairo_surface_t);
#[cfg(any(feature = "ps", feature = "dox"))]
pub fn cairo_ps_surface_dsc_comment (surface: *mut cairo_surface_t, comment: *const c_char);

// CAIRO XCB
#[cfg(any(feature = "xcb", feature = "dox"))]
pub fn cairo_xcb_surface_create(connection: *mut xcb_connection_t,
Expand Down
12 changes: 9 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,6 @@ pub use image_surface::{
ImageSurfaceData,
};

pub use pdf_surface::PDFSurface;

#[cfg(any(feature = "xcb", feature = "dox"))]
pub use xcb::{
XCBConnection,
Expand All @@ -163,7 +161,6 @@ pub mod prelude;
mod font;
mod context;
mod error;
mod pdf_surface;
mod image_surface;
#[cfg(any(feature = "png", feature = "dox"))]
mod image_surface_png;
Expand All @@ -176,6 +173,15 @@ mod matrices;
#[cfg(any(feature = "xcb", feature = "dox"))]
mod xcb;

#[cfg(any(feature = "pdf", feature = "svg", feature = "ps", feature = "dox"))]
mod support;
#[cfg(any(feature = "pdf", feature = "dox"))]
pub mod pdf;
#[cfg(any(feature = "svg", feature = "dox"))]
pub mod svg;
#[cfg(any(feature = "ps", feature = "dox"))]
pub mod ps;

#[cfg(any(target_os = "macos", target_os = "ios", feature = "dox"))]
mod quartz_surface;
#[cfg(any(target_os = "macos", target_os = "ios", feature = "dox"))]
Expand Down
Loading

0 comments on commit d00687e

Please sign in to comment.