#![warn(missing_docs)]
mod document;
mod page;
mod outline;
mod destination;
mod encoder;
mod error;
mod context;
mod image;
pub mod prelude;
pub type Real = libharu_sys::HPDF_REAL;
#[derive(Debug, Clone)]
pub struct Color {
pub red: Real,
pub green: Real,
pub blue: Real,
}
impl Copy for Color {}
impl From<(Real, Real, Real)> for Color {
fn from(v: (Real, Real, Real)) -> Self {
Self { red: v.0, green: v.1, blue: v.2 }
}
}
#[derive(Debug, Clone)]
pub struct CmykColor {
pub cyan: Real,
pub magenta: Real,
pub yellow: Real,
pub keyplate: Real,
}
impl Copy for CmykColor {}
impl From<(Real, Real, Real, Real)> for CmykColor {
fn from(v: (Real, Real, Real, Real)) -> Self {
Self { cyan: v.0, magenta: v.1, yellow: v.2, keyplate: v.3 }
}
}
#[derive(Debug, Clone)]
pub struct Point {
pub x: Real,
pub y: Real,
}
impl Copy for Point {}
impl From<(Real, Real)> for Point {
fn from(v: (Real, Real)) -> Self {
Self { x: v.0, y: v.1 }
}
}
#[derive(Debug, Clone)]
pub struct Rect {
pub left: Real,
pub top: Real,
pub right: Real,
pub bottom: Real,
}
impl Copy for Rect {}
impl From<(Real, Real, Real, Real)> for Rect {
fn from(v: (Real, Real, Real, Real)) -> Self {
Self { left: v.0, top: v.1, right: v.2, bottom: v.3 }
}
}
pub struct Font<'a> {
font: libharu_sys::HPDF_Font,
_doc: &'a prelude::Document,
}
impl<'a> Font<'a> {
pub(crate) fn new(_doc: &'a prelude::Document, font: libharu_sys::HPDF_Font) -> Self {
Self { font, _doc }
}
#[inline]
pub(crate) fn handle(&self) -> libharu_sys::HPDF_Font {
self.font
}
pub fn name(&self) -> anyhow::Result<&str> {
unsafe {
let name = libharu_sys::HPDF_Font_GetFontName(self.handle());
let s = std::ffi::CStr::from_ptr(name).to_str()?;
Ok(s)
}
}
}