1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT

use crate::Color;
use glib::translate::*;

glib::wrapper! {
    #[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Hash)]
    pub struct TextSpan(Boxed<ffi::PopplerTextSpan>);

    match fn {
        copy => |ptr| ffi::poppler_text_span_copy(mut_override(ptr)),
        free => |ptr| ffi::poppler_text_span_free(ptr),
        type_ => || ffi::poppler_text_span_get_type(),
    }
}

impl TextSpan {
    /// Obtains the color in which the text is to be rendered.
    ///
    /// # Returns
    ///
    ///
    /// ## `color`
    /// a return location for a [`Color`][crate::Color]
    #[doc(alias = "poppler_text_span_get_color")]
    #[doc(alias = "get_color")]
    pub fn color(&mut self) -> Color {
        unsafe {
            let mut color = Color::uninitialized();
            ffi::poppler_text_span_get_color(self.to_glib_none_mut().0, color.to_glib_none_mut().0);
            color
        }
    }

    /// Obtains the name of the font in which the span is to be rendered.
    ///
    /// # Returns
    ///
    /// A string containing the font name, or
    ///  [`None`] if a font is not defined.
    #[doc(alias = "poppler_text_span_get_font_name")]
    #[doc(alias = "get_font_name")]
    pub fn font_name(&mut self) -> Option<glib::GString> {
        unsafe {
            from_glib_none(ffi::poppler_text_span_get_font_name(
                self.to_glib_none_mut().0,
            ))
        }
    }

    /// Obtains the text contained in the span.
    ///
    /// # Returns
    ///
    /// A string.
    #[doc(alias = "poppler_text_span_get_text")]
    #[doc(alias = "get_text")]
    pub fn text(&mut self) -> Option<glib::GString> {
        unsafe { from_glib_none(ffi::poppler_text_span_get_text(self.to_glib_none_mut().0)) }
    }

    /// Check whether a text span is meant to be rendered using a bold font.
    ///
    /// # Returns
    ///
    /// Whether the span uses bold font.
    #[doc(alias = "poppler_text_span_is_bold_font")]
    pub fn is_bold_font(&mut self) -> bool {
        unsafe {
            from_glib(ffi::poppler_text_span_is_bold_font(
                self.to_glib_none_mut().0,
            ))
        }
    }

    /// Check wether a text span is meant to be rendered using a fixed-width font.
    ///
    /// # Returns
    ///
    /// Whether the span uses a fixed-width font.
    #[doc(alias = "poppler_text_span_is_fixed_width_font")]
    pub fn is_fixed_width_font(&mut self) -> bool {
        unsafe {
            from_glib(ffi::poppler_text_span_is_fixed_width_font(
                self.to_glib_none_mut().0,
            ))
        }
    }

    /// Check whether a text span is meant to be rendered using a serif font.
    ///
    /// # Returns
    ///
    /// Whether the span uses a serif font.
    #[doc(alias = "poppler_text_span_is_serif_font")]
    pub fn is_serif_font(&mut self) -> bool {
        unsafe {
            from_glib(ffi::poppler_text_span_is_serif_font(
                self.to_glib_none_mut().0,
            ))
        }
    }
}