pango/
attr_iterator.rs

1// Copyright 2018, The Gtk-rs Project Developers.
2// See the COPYRIGHT file at the top-level directory of this distribution.
3// Licensed under the MIT license, see the LICENSE file or <http://opensource.org/licenses/MIT>
4
5use glib::translate::*;
6use glib_sys;
7use pango_sys;
8use AttrIterator;
9use Attribute;
10use FontDescription;
11use Language;
12
13use std::ptr;
14
15impl AttrIterator {
16    pub fn get_font(
17        &mut self,
18        desc: &mut FontDescription,
19        language: Option<&Language>,
20        extra_attrs: &[&Attribute],
21    ) {
22        unsafe {
23            let stash_vec: Vec<_> = extra_attrs.iter().rev().map(|v| v.to_glib_none()).collect();
24            let mut list: *mut glib_sys::GSList = ptr::null_mut();
25            for stash in &stash_vec {
26                list = glib_sys::g_slist_prepend(list, Ptr::to(stash.0));
27            }
28
29            pango_sys::pango_attr_iterator_get_font(
30                self.to_glib_none_mut().0,
31                desc.to_glib_none_mut().0,
32                &mut language.to_glib_none().0,
33                &mut list,
34            );
35        }
36    }
37}