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
244
245
246
247
248
249
250
251
252
253
// This file was generated by gir (4b09025) from gir-files (71d73f0)
// DO NOT EDIT

use AttrList;
use Direction;
use Error;
use Rectangle;
use Stretch;
use Style;
use Variant;
use Weight;
use ffi;
use glib;
use glib::translate::*;
use std::mem;
use std::ptr;


//pub fn break_(text: &str, length: i32, analysis: /*Ignored*/&mut Analysis, attrs: /*Ignored*/&[&LogAttr]) {
//    unsafe { TODO: call ffi::pango_break() }
//}

pub fn config_key_get(key: &str) -> Option<String> {
    unsafe {
        from_glib_full(ffi::pango_config_key_get(key.to_glib_none().0))
    }
}

pub fn config_key_get_system(key: &str) -> Option<String> {
    unsafe {
        from_glib_full(ffi::pango_config_key_get_system(key.to_glib_none().0))
    }
}

//pub fn default_break<'a, P: Into<Option<&'a /*Ignored*/Analysis>>>(text: &str, length: i32, analysis: P, attrs: /*Ignored*/&mut LogAttr, attrs_len: i32) {
//    unsafe { TODO: call ffi::pango_default_break() }
//}

pub fn extents_to_pixels<'a, 'b, P: Into<Option<&'a Rectangle>>, Q: Into<Option<&'b Rectangle>>>(inclusive: P, nearest: Q) {
    let inclusive = inclusive.into();
    let nearest = nearest.into();
    unsafe {
        ffi::pango_extents_to_pixels(mut_override(inclusive.to_glib_none().0), mut_override(nearest.to_glib_none().0));
    }
}

pub fn find_base_dir(text: &str, length: i32) -> Direction {
    unsafe {
        from_glib(ffi::pango_find_base_dir(text.to_glib_none().0, length))
    }
}

//pub fn find_map(language: &mut Language, engine_type_id: u32, render_type_id: u32) -> /*Ignored*/Option<Map> {
//    unsafe { TODO: call ffi::pango_find_map() }
//}

pub fn find_paragraph_boundary(text: &str, length: i32) -> (i32, i32) {
    unsafe {
        let mut paragraph_delimiter_index = mem::uninitialized();
        let mut next_paragraph_start = mem::uninitialized();
        ffi::pango_find_paragraph_boundary(text.to_glib_none().0, length, &mut paragraph_delimiter_index, &mut next_paragraph_start);
        (paragraph_delimiter_index, next_paragraph_start)
    }
}

pub fn get_lib_subdirectory() -> Option<String> {
    unsafe {
        from_glib_none(ffi::pango_get_lib_subdirectory())
    }
}

//pub fn get_log_attrs(text: &str, length: i32, level: i32, language: &mut Language, log_attrs: /*Ignored*/&[&LogAttr]) {
//    unsafe { TODO: call ffi::pango_get_log_attrs() }
//}

pub fn get_sysconf_subdirectory() -> Option<String> {
    unsafe {
        from_glib_none(ffi::pango_get_sysconf_subdirectory())
    }
}

pub fn is_zero_width(ch: char) -> bool {
    unsafe {
        from_glib(ffi::pango_is_zero_width(ch.to_glib()))
    }
}

//pub fn itemize<'a, P: Into<Option<&'a /*Ignored*/AttrIterator>>>(context: &Context, text: &str, start_index: i32, length: i32, attrs: &AttrList, cached_iter: P) -> /*Ignored*/Vec<Item> {
//    unsafe { TODO: call ffi::pango_itemize() }
//}

//pub fn itemize_with_base_dir<'a, P: Into<Option<&'a /*Ignored*/AttrIterator>>>(context: &Context, base_dir: Direction, text: &str, start_index: i32, length: i32, attrs: &AttrList, cached_iter: P) -> /*Ignored*/Vec<Item> {
//    unsafe { TODO: call ffi::pango_itemize_with_base_dir() }
//}

//pub fn lookup_aliases(fontname: &str, families: /*Unimplemented*/Vec<String>) -> i32 {
//    unsafe { TODO: call ffi::pango_lookup_aliases() }
//}

//#[cfg(feature = "v1_31")]
//pub fn markup_parser_finish(context: /*Ignored*/&glib::MarkupParseContext) -> Result<(AttrList, String, char), Error> {
//    unsafe { TODO: call ffi::pango_markup_parser_finish() }
//}

//#[cfg(feature = "v1_31")]
//pub fn markup_parser_new(accel_marker: char) -> /*Ignored*/Option<glib::MarkupParseContext> {
//    unsafe { TODO: call ffi::pango_markup_parser_new() }
//}

//pub fn module_register(module: /*Ignored*/&mut IncludedModule) {
//    unsafe { TODO: call ffi::pango_module_register() }
//}

pub fn parse_enum<'a, P: Into<Option<&'a str>>>(type_: glib::types::Type, str: P, warn: bool) -> Option<(i32, String)> {
    let str = str.into();
    let str = str.to_glib_none();
    unsafe {
        let mut value = mem::uninitialized();
        let mut possible_values = ptr::null_mut();
        let ret = from_glib(ffi::pango_parse_enum(type_.to_glib(), str.0, &mut value, warn.to_glib(), &mut possible_values));
        if ret { Some((value, from_glib_full(possible_values))) } else { None }
    }
}

pub fn parse_markup(markup_text: &str, length: i32, accel_marker: char) -> Result<(AttrList, String, char), Error> {
    unsafe {
        let mut attr_list = ptr::null_mut();
        let mut text = ptr::null_mut();
        let mut accel_char = mem::uninitialized();
        let mut error = ptr::null_mut();
        let _ = ffi::pango_parse_markup(markup_text.to_glib_none().0, length, accel_marker.to_glib(), &mut attr_list, &mut text, &mut accel_char, &mut error);
        if error.is_null() { Ok((from_glib_full(attr_list), from_glib_full(text), from_glib(accel_char))) } else { Err(from_glib_full(error)) }
    }
}

pub fn parse_stretch(str: &str, warn: bool) -> Option<Stretch> {
    unsafe {
        let mut stretch = mem::uninitialized();
        let ret = from_glib(ffi::pango_parse_stretch(str.to_glib_none().0, &mut stretch, warn.to_glib()));
        if ret { Some(from_glib(stretch)) } else { None }
    }
}

pub fn parse_style(str: &str, warn: bool) -> Option<Style> {
    unsafe {
        let mut style = mem::uninitialized();
        let ret = from_glib(ffi::pango_parse_style(str.to_glib_none().0, &mut style, warn.to_glib()));
        if ret { Some(from_glib(style)) } else { None }
    }
}

pub fn parse_variant(str: &str, warn: bool) -> Option<Variant> {
    unsafe {
        let mut variant = mem::uninitialized();
        let ret = from_glib(ffi::pango_parse_variant(str.to_glib_none().0, &mut variant, warn.to_glib()));
        if ret { Some(from_glib(variant)) } else { None }
    }
}

pub fn parse_weight(str: &str, warn: bool) -> Option<Weight> {
    unsafe {
        let mut weight = mem::uninitialized();
        let ret = from_glib(ffi::pango_parse_weight(str.to_glib_none().0, &mut weight, warn.to_glib()));
        if ret { Some(from_glib(weight)) } else { None }
    }
}

pub fn quantize_line_geometry(thickness: &mut i32, position: &mut i32) {
    unsafe {
        ffi::pango_quantize_line_geometry(thickness, position);
    }
}

//pub fn read_line<P: Into<Option</*Unimplemented*/Fundamental: Pointer>>>(stream: P, str: /*Ignored*/glib::String) -> i32 {
//    unsafe { TODO: call ffi::pango_read_line() }
//}

//pub fn reorder_items(logical_items: /*Ignored*/&[&Item]) -> /*Ignored*/Vec<Item> {
//    unsafe { TODO: call ffi::pango_reorder_items() }
//}

//pub fn scan_int(pos: /*Unimplemented*/String) -> Option<i32> {
//    unsafe { TODO: call ffi::pango_scan_int() }
//}

//pub fn scan_string(pos: /*Unimplemented*/String, out: /*Ignored*/glib::String) -> bool {
//    unsafe { TODO: call ffi::pango_scan_string() }
//}

//pub fn scan_word(pos: /*Unimplemented*/String, out: /*Ignored*/glib::String) -> bool {
//    unsafe { TODO: call ffi::pango_scan_word() }
//}

//pub fn shape(text: &str, length: i32, analysis: /*Ignored*/&Analysis, glyphs: &mut GlyphString) {
//    unsafe { TODO: call ffi::pango_shape() }
//}

//#[cfg(feature = "v1_32")]
//pub fn shape_full<'a, P: Into<Option<&'a str>>>(item_text: &str, item_length: i32, paragraph_text: P, paragraph_length: i32, analysis: /*Ignored*/&Analysis, glyphs: &mut GlyphString) {
//    unsafe { TODO: call ffi::pango_shape_full() }
//}

//pub fn skip_space(pos: /*Unimplemented*/String) -> bool {
//    unsafe { TODO: call ffi::pango_skip_space() }
//}

pub fn split_file_list(str: &str) -> Vec<String> {
    unsafe {
        FromGlibPtrContainer::from_glib_full(ffi::pango_split_file_list(str.to_glib_none().0))
    }
}

pub fn trim_string(str: &str) -> Option<String> {
    unsafe {
        from_glib_full(ffi::pango_trim_string(str.to_glib_none().0))
    }
}

pub fn unichar_direction(ch: char) -> Direction {
    unsafe {
        from_glib(ffi::pango_unichar_direction(ch.to_glib()))
    }
}

pub fn units_from_double(d: f64) -> i32 {
    unsafe {
        ffi::pango_units_from_double(d)
    }
}

pub fn units_to_double(i: i32) -> f64 {
    unsafe {
        ffi::pango_units_to_double(i)
    }
}

pub fn version() -> i32 {
    unsafe {
        ffi::pango_version()
    }
}

pub fn version_check(required_major: i32, required_minor: i32, required_micro: i32) -> Option<String> {
    unsafe {
        from_glib_none(ffi::pango_version_check(required_major, required_minor, required_micro))
    }
}

pub fn version_string() -> Option<String> {
    unsafe {
        from_glib_none(ffi::pango_version_string())
    }
}