pangocairo/
font_map.rs

1// Copyright 2017, 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 cairo;
6use glib::object::IsA;
7use glib::translate::*;
8use pango;
9use pango_cairo_sys;
10use FontMap;
11
12pub trait FontMapExtManual {
13    fn get_font_type(&self) -> cairo::FontType;
14}
15
16impl<O: IsA<FontMap>> FontMapExtManual for O {
17    fn get_font_type(&self) -> cairo::FontType {
18        unsafe {
19            pango_cairo_sys::pango_cairo_font_map_get_font_type(self.as_ref().to_glib_none().0)
20                .into()
21        }
22    }
23}
24
25impl FontMap {
26    pub fn new_for_font_type(fonttype: cairo::FontType) -> Option<pango::FontMap> {
27        unsafe {
28            from_glib_full(pango_cairo_sys::pango_cairo_font_map_new_for_font_type(
29                fonttype.into(),
30            ))
31        }
32    }
33
34    pub fn new() -> Option<pango::FontMap> {
35        unsafe { from_glib_full(pango_cairo_sys::pango_cairo_font_map_new()) }
36    }
37}