// GENERATED — DO NOT EDIT

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/class.Font.html).
pub type Font

///|
pub(open) trait IFont {
  fn as_font(Self) -> Font
  fn describe(Self) -> FontDescription = _
  fn describe_with_absolute_size(Self) -> FontDescription = _
  fn get_coverage(Self, Language) -> Coverage = _
  fn get_face(Self) -> FontFace? = _
  fn get_font_map(Self) -> FontMap? = _
  fn get_glyph_extents(Self, Glyph) -> (Rectangle, Rectangle) = _
  fn get_languages(Self) -> Array[Language]? = _
  fn get_metrics(Self, Language?) -> FontMetrics = _
  fn has_char(Self, UInt) -> Bool = _
  fn serialize(Self) -> Bytes = _
}

///|
pub impl IFont for Font with fn as_font(self) {
  self
}

///|
#borrow(context, bytes, error)
extern "c" fn moonbit_pango_font_deserialize(
  context : Context,
  bytes : Bytes,
  error : Ref[@glib.Nullable[@glib.Error_]],
) -> @glib.Nullable[Font] = "moonbit_pango_font_deserialize"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/type_func.Font.deserialize.html).
pub fn Font::deserialize(
  context : &IContext,
  bytes : Bytes,
) -> Font? raise @glib.Error_ {
  let error_ : Ref[@glib.Nullable[@glib.Error_]] = Ref(@glib.Nullable::null())
  let raw_result = moonbit_pango_font_deserialize(
    context.as_context(),
    bytes,
    error_,
  )
  match error_.val.to_option() {
    Some(e) => raise e
    None => ()
  }
  raw_result.to_option()
}

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Font.describe.html).
#borrow(self)
pub extern "c" fn Font::describe(self : Font) -> FontDescription = "moonbit_pango_font_describe"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Font.describe_with_absolute_size.html).
#borrow(self)
pub extern "c" fn Font::describe_with_absolute_size(
  self : Font,
) -> FontDescription = "moonbit_pango_font_describe_with_absolute_size"

///|
#borrow(self_, language)
extern "c" fn moonbit_pango_font_get_coverage(
  self_ : Font,
  language : Language,
) -> Coverage = "moonbit_pango_font_get_coverage"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Font.get_coverage.html).
pub fn Font::get_coverage(self : Font, language : Language) -> Coverage {
  moonbit_pango_font_get_coverage(self, language)
}

///|
#borrow(self_)
extern "c" fn moonbit_pango_font_get_face(
  self_ : Font,
) -> @glib.Nullable[FontFace] = "moonbit_pango_font_get_face"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Font.get_face.html).
pub fn Font::get_face(self : Font) -> FontFace? {
  let raw_result = moonbit_pango_font_get_face(self)
  raw_result.to_option()
}

///|
#borrow(self_)
extern "c" fn moonbit_pango_font_get_font_map(
  self_ : Font,
) -> @glib.Nullable[FontMap] = "moonbit_pango_font_get_font_map"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Font.get_font_map.html).
pub fn Font::get_font_map(self : Font) -> FontMap? {
  let raw_result = moonbit_pango_font_get_font_map(self)
  raw_result.to_option()
}

///|
#borrow(self_, __out_logical_rect)
extern "c" fn moonbit_pango_font_get_glyph_extents(
  self_ : Font,
  glyph : UInt,
  __out_logical_rect : Ref[Rectangle],
) -> Rectangle = "moonbit_pango_font_get_glyph_extents"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Font.get_glyph_extents.html).
pub fn Font::get_glyph_extents(
  self : Font,
  glyph : Glyph,
) -> (Rectangle, Rectangle) {
  let __out_logical_rect = Ref(Rectangle::_zero())
  let __result = moonbit_pango_font_get_glyph_extents(
    self, glyph, __out_logical_rect,
  )
  (__result, __out_logical_rect.val)
}

///|
#borrow(self_, result)
extern "c" fn moonbit_pango_font_get_languages(
  self_ : Font,
  result : Ref[@glib.Nullable[FixedArray[Language]]],
) = "moonbit_pango_font_get_languages"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Font.get_languages.html).
pub fn Font::get_languages(self : Font) -> Array[Language]? {
  let result_ref : Ref[@glib.Nullable[FixedArray[Language]]] = Ref(
    @glib.Nullable::null(),
  )
  moonbit_pango_font_get_languages(self, result_ref)
  match result_ref.val.to_option() {
    Some(array) => Some(Array::from_fixed_array(array))
    None => None
  }
}

///|
#borrow(self_, language)
extern "c" fn moonbit_pango_font_get_metrics(
  self_ : Font,
  language : @glib.Nullable[Language],
) -> FontMetrics = "moonbit_pango_font_get_metrics"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Font.get_metrics.html).
pub fn Font::get_metrics(self : Font, language : Language?) -> FontMetrics {
  moonbit_pango_font_get_metrics(
    self,
    match language {
      Some(v) => @glib.Nullable::some(v)
      None => @glib.Nullable::null()
    },
  )
}

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Font.has_char.html).
#borrow(self)
pub extern "c" fn Font::has_char(self : Font, wc : UInt) -> Bool = "moonbit_pango_font_has_char"

///|
/// [Upstream documentation](https://gnome.pages.gitlab.gnome.org/pango/Pango/method.Font.serialize.html).
#borrow(self)
pub extern "c" fn Font::serialize(self : Font) -> Bytes = "moonbit_pango_font_serialize"

///|
impl IFont with fn describe(self) -> FontDescription {
  self.as_font().describe()
}

///|
impl IFont with fn describe_with_absolute_size(self) -> FontDescription {
  self.as_font().describe_with_absolute_size()
}

///|
impl IFont with fn get_coverage(self, language) -> Coverage {
  self.as_font().get_coverage(language)
}

///|
impl IFont with fn get_face(self) -> FontFace? {
  self.as_font().get_face()
}

///|
impl IFont with fn get_font_map(self) -> FontMap? {
  self.as_font().get_font_map()
}

///|
impl IFont with fn get_glyph_extents(self, glyph) -> (Rectangle, Rectangle) {
  self.as_font().get_glyph_extents(glyph)
}

///|
impl IFont with fn get_languages(self) -> Array[Language]? {
  self.as_font().get_languages()
}

///|
impl IFont with fn get_metrics(self, language) -> FontMetrics {
  self.as_font().get_metrics(language)
}

///|
impl IFont with fn has_char(self, wc) -> Bool {
  self.as_font().has_char(wc)
}

///|
impl IFont with fn serialize(self) -> Bytes {
  self.as_font().serialize()
}

///|
pub fn Font::as_gobject_object(self : Font) -> @gobject.Object = "%identity"

///|
pub impl @gobject.IObject for Font with fn as_object(self) {
  self.as_gobject_object()
}