1use glib::object::IsA;
6use glib::translate::*;
7use glib::GString;
8use pango_sys;
9use std::fmt;
10use std::mem;
11use std::ptr;
12use FontDescription;
13
14glib_wrapper! {
15 pub struct FontFace(Object<pango_sys::PangoFontFace, pango_sys::PangoFontFaceClass, FontFaceClass>);
16
17 match fn {
18 get_type => || pango_sys::pango_font_face_get_type(),
19 }
20}
21
22pub const NONE_FONT_FACE: Option<&FontFace> = None;
23
24pub trait FontFaceExt: 'static {
25 fn describe(&self) -> Option<FontDescription>;
26
27 fn get_face_name(&self) -> Option<GString>;
28
29 fn is_synthesized(&self) -> bool;
30
31 fn list_sizes(&self) -> Vec<i32>;
32}
33
34impl<O: IsA<FontFace>> FontFaceExt for O {
35 fn describe(&self) -> Option<FontDescription> {
36 unsafe {
37 from_glib_full(pango_sys::pango_font_face_describe(
38 self.as_ref().to_glib_none().0,
39 ))
40 }
41 }
42
43 fn get_face_name(&self) -> Option<GString> {
44 unsafe {
45 from_glib_none(pango_sys::pango_font_face_get_face_name(
46 self.as_ref().to_glib_none().0,
47 ))
48 }
49 }
50
51 fn is_synthesized(&self) -> bool {
52 unsafe {
53 from_glib(pango_sys::pango_font_face_is_synthesized(
54 self.as_ref().to_glib_none().0,
55 ))
56 }
57 }
58
59 fn list_sizes(&self) -> Vec<i32> {
60 unsafe {
61 let mut sizes = ptr::null_mut();
62 let mut n_sizes = mem::uninitialized();
63 pango_sys::pango_font_face_list_sizes(
64 self.as_ref().to_glib_none().0,
65 &mut sizes,
66 &mut n_sizes,
67 );
68 FromGlibContainer::from_glib_full_num(sizes, n_sizes as usize)
69 }
70 }
71}
72
73impl fmt::Display for FontFace {
74 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
75 write!(f, "FontFace")
76 }
77}