1#![warn(missing_docs)]
4mod document;
5mod page;
6mod outline;
7mod destination;
8mod encoder;
9mod error;
10mod context;
11mod image;
12
13pub mod prelude;
15
16pub type Real = libharu_sys::HPDF_REAL;
18
19#[derive(Debug, Clone)]
21pub struct Color {
22 pub red: Real,
24
25 pub green: Real,
27
28 pub blue: Real,
30}
31
32impl Copy for Color {}
33
34impl From<(Real, Real, Real)> for Color {
35 fn from(v: (Real, Real, Real)) -> Self {
36 Self { red: v.0, green: v.1, blue: v.2 }
37 }
38}
39
40#[derive(Debug, Clone)]
42pub struct CmykColor {
43 pub cyan: Real,
45
46 pub magenta: Real,
48
49 pub yellow: Real,
51
52 pub keyplate: Real,
54}
55
56impl Copy for CmykColor {}
57
58impl From<(Real, Real, Real, Real)> for CmykColor {
59 fn from(v: (Real, Real, Real, Real)) -> Self {
60 Self { cyan: v.0, magenta: v.1, yellow: v.2, keyplate: v.3 }
61 }
62}
63#[derive(Debug, Clone)]
65pub struct Point {
66 pub x: Real,
68
69 pub y: Real,
71}
72
73impl Copy for Point {}
74
75impl From<(Real, Real)> for Point {
76 fn from(v: (Real, Real)) -> Self {
77 Self { x: v.0, y: v.1 }
78 }
79}
80
81#[derive(Debug, Clone)]
83pub struct Rect {
84 pub left: Real,
86
87 pub top: Real,
89
90 pub right: Real,
92
93 pub bottom: Real,
95}
96
97impl Copy for Rect {}
98
99impl From<(Real, Real, Real, Real)> for Rect {
100 fn from(v: (Real, Real, Real, Real)) -> Self {
101 Self { left: v.0, top: v.1, right: v.2, bottom: v.3 }
102 }
103}
104
105pub struct Font<'a> {
107 font: libharu_sys::HPDF_Font,
108 _doc: &'a prelude::Document,
109}
110
111impl<'a> Font<'a> {
112 pub(crate) fn new(_doc: &'a prelude::Document, font: libharu_sys::HPDF_Font) -> Self {
113 Self { font, _doc }
114 }
115
116 #[inline]
117 pub(crate) fn handle(&self) -> libharu_sys::HPDF_Font {
118 self.font
119 }
120
121 pub fn name(&self) -> anyhow::Result<&str> {
123 unsafe {
124 let name = libharu_sys::HPDF_Font_GetFontName(self.handle());
125
126 let s = std::ffi::CStr::from_ptr(name).to_str()?;
127
128 Ok(s)
129 }
130 }
131}