pango/auto/
font_family.rs

1// This file was generated by gir (https://github.com/gtk-rs/gir)
2// from gir-files (https://github.com/gtk-rs/gir-files)
3// DO NOT EDIT
4
5use glib::object::IsA;
6use glib::translate::*;
7use glib::GString;
8use pango_sys;
9use std::fmt;
10use std::mem;
11use std::ptr;
12use FontFace;
13
14glib_wrapper! {
15    pub struct FontFamily(Object<pango_sys::PangoFontFamily, pango_sys::PangoFontFamilyClass, FontFamilyClass>);
16
17    match fn {
18        get_type => || pango_sys::pango_font_family_get_type(),
19    }
20}
21
22pub const NONE_FONT_FAMILY: Option<&FontFamily> = None;
23
24pub trait FontFamilyExt: 'static {
25    fn get_name(&self) -> Option<GString>;
26
27    fn is_monospace(&self) -> bool;
28
29    fn list_faces(&self) -> Vec<FontFace>;
30}
31
32impl<O: IsA<FontFamily>> FontFamilyExt for O {
33    fn get_name(&self) -> Option<GString> {
34        unsafe {
35            from_glib_none(pango_sys::pango_font_family_get_name(
36                self.as_ref().to_glib_none().0,
37            ))
38        }
39    }
40
41    fn is_monospace(&self) -> bool {
42        unsafe {
43            from_glib(pango_sys::pango_font_family_is_monospace(
44                self.as_ref().to_glib_none().0,
45            ))
46        }
47    }
48
49    fn list_faces(&self) -> Vec<FontFace> {
50        unsafe {
51            let mut faces = ptr::null_mut();
52            let mut n_faces = mem::uninitialized();
53            pango_sys::pango_font_family_list_faces(
54                self.as_ref().to_glib_none().0,
55                &mut faces,
56                &mut n_faces,
57            );
58            FromGlibContainer::from_glib_container_num(faces, n_faces as usize)
59        }
60    }
61}
62
63impl fmt::Display for FontFamily {
64    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
65        write!(f, "FontFamily")
66    }
67}