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
// This file was generated by gir (https://github.com/gtk-rs/gir)
// from gir-files (https://github.com/gtk-rs/gir-files)
// DO NOT EDIT
use crate::FontDescription;
#[cfg(any(feature = "v1_46", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_46")))]
use crate::FontFamily;
use glib::object::IsA;
use glib::translate::*;
use std::fmt;
use std::mem;
use std::ptr;
glib::wrapper! {
/// A [`FontFace`][crate::FontFace] is used to represent a group of fonts with
/// the same family, slant, weight, and width, but varying sizes.
///
/// This is an Abstract Base Class, you cannot instantiate it.
///
/// # Implements
///
/// [`FontFaceExt`][trait@crate::prelude::FontFaceExt]
#[doc(alias = "PangoFontFace")]
pub struct FontFace(Object<ffi::PangoFontFace, ffi::PangoFontFaceClass>);
match fn {
type_ => || ffi::pango_font_face_get_type(),
}
}
impl FontFace {
pub const NONE: Option<&'static FontFace> = None;
}
/// Trait containing all [`struct@FontFace`] methods.
///
/// # Implementors
///
/// [`FontFace`][struct@crate::FontFace]
pub trait FontFaceExt: 'static {
/// Returns a font description that matches the face.
///
/// The resulting font description will have the family, style,
/// variant, weight and stretch of the face, but its size field
/// will be unset.
///
/// # Returns
///
/// a newly-created [`FontDescription`][crate::FontDescription] structure
/// holding the description of the face. Use `Pango::FontDescription::free()`
/// to free the result.
#[doc(alias = "pango_font_face_describe")]
fn describe(&self) -> FontDescription;
/// Gets a name representing the style of this face.
///
/// Note that a font family may contain multiple faces
/// with the same name (e.g. a variable and a non-variable
/// face for the same style).
///
/// # Returns
///
/// the face name for the face. This string is
/// owned by the face object and must not be modified or freed.
#[doc(alias = "pango_font_face_get_face_name")]
#[doc(alias = "get_face_name")]
fn face_name(&self) -> glib::GString;
/// Gets the [`FontFamily`][crate::FontFamily] that @self belongs to.
///
/// # Returns
///
/// the [`FontFamily`][crate::FontFamily]
#[cfg(any(feature = "v1_46", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_46")))]
#[doc(alias = "pango_font_face_get_family")]
#[doc(alias = "get_family")]
fn family(&self) -> FontFamily;
/// Returns whether a [`FontFace`][crate::FontFace] is synthesized.
///
/// This will be the case if the underlying font rendering engine
/// creates this face from another face, by shearing, emboldening,
/// lightening or modifying it in some other way.
///
/// # Returns
///
/// whether @self is synthesized
#[doc(alias = "pango_font_face_is_synthesized")]
fn is_synthesized(&self) -> bool;
/// List the available sizes for a font.
///
/// This is only applicable to bitmap fonts. For scalable fonts, stores
/// [`None`] at the location pointed to by @sizes and 0 at the location pointed
/// to by @n_sizes. The sizes returned are in Pango units and are sorted
/// in ascending order.
///
/// # Returns
///
///
/// ## `sizes`
///
/// location to store a pointer to an array of int. This array
/// should be freed with g_free().
#[doc(alias = "pango_font_face_list_sizes")]
fn list_sizes(&self) -> Vec<i32>;
}
impl<O: IsA<FontFace>> FontFaceExt for O {
fn describe(&self) -> FontDescription {
unsafe {
from_glib_full(ffi::pango_font_face_describe(
self.as_ref().to_glib_none().0,
))
}
}
fn face_name(&self) -> glib::GString {
unsafe {
from_glib_none(ffi::pango_font_face_get_face_name(
self.as_ref().to_glib_none().0,
))
}
}
#[cfg(any(feature = "v1_46", feature = "dox"))]
#[cfg_attr(feature = "dox", doc(cfg(feature = "v1_46")))]
fn family(&self) -> FontFamily {
unsafe {
from_glib_none(ffi::pango_font_face_get_family(
self.as_ref().to_glib_none().0,
))
}
}
fn is_synthesized(&self) -> bool {
unsafe {
from_glib(ffi::pango_font_face_is_synthesized(
self.as_ref().to_glib_none().0,
))
}
}
fn list_sizes(&self) -> Vec<i32> {
unsafe {
let mut sizes = ptr::null_mut();
let mut n_sizes = mem::MaybeUninit::uninit();
ffi::pango_font_face_list_sizes(
self.as_ref().to_glib_none().0,
&mut sizes,
n_sizes.as_mut_ptr(),
);
FromGlibContainer::from_glib_full_num(sizes, n_sizes.assume_init() as _)
}
}
}
impl fmt::Display for FontFace {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
f.write_str("FontFace")
}
}