pdfium/
glyph_path.rs

1// PDFium-rs -- Modern Rust interface to PDFium, the PDF library from Google
2//
3// Copyright (c) 2025 Martin van der Werff <github (at) newinnovations.nl>
4//
5// This file is part of PDFium-rs.
6//
7// PDFium-rs is free software: you can redistribute it and/or modify it under the terms of
8// the GNU General Public License as published by the Free Software Foundation, either version 3
9// of the License, or (at your option) any later version.
10//
11// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
12// IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
13// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
14// DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
15// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
16// BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
17// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
18// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
19
20use crate::{
21    error::{PdfiumError, PdfiumResult},
22    pdfium_types::{GlyphPathHandle, Handle, FPDF_GLYPHPATH},
23};
24
25/// # Rust interface to FPDF_GLYPHPATH
26#[derive(Debug, Clone)]
27pub struct PdfiumGlyphPath {
28    handle: GlyphPathHandle,
29}
30
31impl PdfiumGlyphPath {
32    pub(crate) fn new_from_handle(handle: FPDF_GLYPHPATH) -> PdfiumResult<Self> {
33        if handle.is_null() {
34            Err(PdfiumError::NullHandle)
35        } else {
36            Ok(Self {
37                handle: Handle::new_const(handle), // TODO: check close is not needed
38            })
39        }
40    }
41}
42
43impl From<&PdfiumGlyphPath> for FPDF_GLYPHPATH {
44    fn from(glyph_path: &PdfiumGlyphPath) -> Self {
45        glyph_path.handle.handle()
46    }
47}