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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
use crate::Direction;
use crate::Font;
use crate::FontDescription;
use crate::FontFamily;
use crate::FontMap;
use crate::FontMetrics;
use crate::Fontset;
use crate::Gravity;
use crate::GravityHint;
use crate::Language;
use crate::Matrix;
use glib::object::IsA;
use glib::translate::*;
use std::fmt;
use std::mem;
use std::ptr;
glib::wrapper! {
#[doc(alias = "PangoContext")]
pub struct Context(Object<ffi::PangoContext, ffi::PangoContextClass>);
match fn {
type_ => || ffi::pango_context_get_type(),
}
}
impl Context {
#[doc(alias = "pango_context_new")]
pub fn new() -> Context {
unsafe { from_glib_full(ffi::pango_context_new()) }
}
#[doc(alias = "pango_context_changed")]
pub fn changed(&self) {
unsafe {
ffi::pango_context_changed(self.to_glib_none().0);
}
}
#[doc(alias = "pango_context_get_base_dir")]
#[doc(alias = "get_base_dir")]
pub fn base_dir(&self) -> Direction {
unsafe { from_glib(ffi::pango_context_get_base_dir(self.to_glib_none().0)) }
}
#[doc(alias = "pango_context_get_base_gravity")]
#[doc(alias = "get_base_gravity")]
pub fn base_gravity(&self) -> Gravity {
unsafe { from_glib(ffi::pango_context_get_base_gravity(self.to_glib_none().0)) }
}
#[doc(alias = "pango_context_get_font_description")]
#[doc(alias = "get_font_description")]
pub fn font_description(&self) -> Option<FontDescription> {
unsafe {
from_glib_none(ffi::pango_context_get_font_description(
self.to_glib_none().0,
))
}
}
#[doc(alias = "pango_context_get_font_map")]
#[doc(alias = "get_font_map")]
pub fn font_map(&self) -> Option<FontMap> {
unsafe { from_glib_none(ffi::pango_context_get_font_map(self.to_glib_none().0)) }
}
#[doc(alias = "pango_context_get_gravity")]
#[doc(alias = "get_gravity")]
pub fn gravity(&self) -> Gravity {
unsafe { from_glib(ffi::pango_context_get_gravity(self.to_glib_none().0)) }
}
#[doc(alias = "pango_context_get_gravity_hint")]
#[doc(alias = "get_gravity_hint")]
pub fn gravity_hint(&self) -> GravityHint {
unsafe { from_glib(ffi::pango_context_get_gravity_hint(self.to_glib_none().0)) }
}
#[doc(alias = "pango_context_get_language")]
#[doc(alias = "get_language")]
pub fn language(&self) -> Option<Language> {
unsafe { from_glib_full(ffi::pango_context_get_language(self.to_glib_none().0)) }
}
#[doc(alias = "pango_context_get_matrix")]
#[doc(alias = "get_matrix")]
pub fn matrix(&self) -> Option<Matrix> {
unsafe { from_glib_none(ffi::pango_context_get_matrix(self.to_glib_none().0)) }
}
#[doc(alias = "pango_context_get_metrics")]
#[doc(alias = "get_metrics")]
pub fn metrics(
&self,
desc: Option<&FontDescription>,
language: Option<&Language>,
) -> Option<FontMetrics> {
unsafe {
from_glib_full(ffi::pango_context_get_metrics(
self.to_glib_none().0,
desc.to_glib_none().0,
mut_override(language.to_glib_none().0),
))
}
}
#[cfg(any(feature = "v1_44", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_44")))]
#[doc(alias = "pango_context_get_round_glyph_positions")]
#[doc(alias = "get_round_glyph_positions")]
pub fn is_round_glyph_positions(&self) -> bool {
unsafe {
from_glib(ffi::pango_context_get_round_glyph_positions(
self.to_glib_none().0,
))
}
}
#[doc(alias = "pango_context_get_serial")]
#[doc(alias = "get_serial")]
pub fn serial(&self) -> u32 {
unsafe { ffi::pango_context_get_serial(self.to_glib_none().0) }
}
#[doc(alias = "pango_context_list_families")]
pub fn list_families(&self) -> Vec<FontFamily> {
unsafe {
let mut families = ptr::null_mut();
let mut n_families = mem::MaybeUninit::uninit();
ffi::pango_context_list_families(
self.to_glib_none().0,
&mut families,
n_families.as_mut_ptr(),
);
FromGlibContainer::from_glib_container_num(families, n_families.assume_init() as usize)
}
}
#[doc(alias = "pango_context_load_font")]
pub fn load_font(&self, desc: &FontDescription) -> Option<Font> {
unsafe {
from_glib_full(ffi::pango_context_load_font(
self.to_glib_none().0,
desc.to_glib_none().0,
))
}
}
#[doc(alias = "pango_context_load_fontset")]
pub fn load_fontset(&self, desc: &FontDescription, language: &Language) -> Option<Fontset> {
unsafe {
from_glib_full(ffi::pango_context_load_fontset(
self.to_glib_none().0,
desc.to_glib_none().0,
mut_override(language.to_glib_none().0),
))
}
}
#[doc(alias = "pango_context_set_base_dir")]
pub fn set_base_dir(&self, direction: Direction) {
unsafe {
ffi::pango_context_set_base_dir(self.to_glib_none().0, direction.into_glib());
}
}
#[doc(alias = "pango_context_set_base_gravity")]
pub fn set_base_gravity(&self, gravity: Gravity) {
unsafe {
ffi::pango_context_set_base_gravity(self.to_glib_none().0, gravity.into_glib());
}
}
#[doc(alias = "pango_context_set_font_description")]
pub fn set_font_description(&self, desc: &FontDescription) {
unsafe {
ffi::pango_context_set_font_description(self.to_glib_none().0, desc.to_glib_none().0);
}
}
#[doc(alias = "pango_context_set_font_map")]
pub fn set_font_map(&self, font_map: &impl IsA<FontMap>) {
unsafe {
ffi::pango_context_set_font_map(
self.to_glib_none().0,
font_map.as_ref().to_glib_none().0,
);
}
}
#[doc(alias = "pango_context_set_gravity_hint")]
pub fn set_gravity_hint(&self, hint: GravityHint) {
unsafe {
ffi::pango_context_set_gravity_hint(self.to_glib_none().0, hint.into_glib());
}
}
#[doc(alias = "pango_context_set_language")]
pub fn set_language(&self, language: &Language) {
unsafe {
ffi::pango_context_set_language(
self.to_glib_none().0,
mut_override(language.to_glib_none().0),
);
}
}
#[doc(alias = "pango_context_set_matrix")]
pub fn set_matrix(&self, matrix: Option<&Matrix>) {
unsafe {
ffi::pango_context_set_matrix(self.to_glib_none().0, matrix.to_glib_none().0);
}
}
#[cfg(any(feature = "v1_44", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_44")))]
#[doc(alias = "pango_context_set_round_glyph_positions")]
pub fn set_round_glyph_positions(&self, round_positions: bool) {
unsafe {
ffi::pango_context_set_round_glyph_positions(
self.to_glib_none().0,
round_positions.into_glib(),
);
}
}
}
impl Default for Context {
fn default() -> Self {
Self::new()
}
}
impl fmt::Display for Context {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("Context")
}
}