[pango/pango2: 100/168] Add pango_font_family_is_generic




commit 293185884b590a43d329a2bb170ba74a864d4faa
Author: Matthias Clasen <mclasen redhat com>
Date:   Sun Mar 13 09:37:23 2022 -0400

    Add pango_font_family_is_generic

 pango/pango-font-family-private.h |  1 +
 pango/pango-font-family.c         | 26 ++++++++++++++++++++++++++
 pango/pango-font-family.h         |  2 ++
 3 files changed, 29 insertions(+)
---
diff --git a/pango/pango-font-family-private.h b/pango/pango-font-family-private.h
index 5d391262..c7f3b6c2 100644
--- a/pango/pango-font-family-private.h
+++ b/pango/pango-font-family-private.h
@@ -34,6 +34,7 @@ struct _PangoFontFamilyClass
   GObjectClass parent_class;
 
   const char *    (* get_name)     (PangoFontFamily *family);
+  gboolean        (* is_generic)   (PangoFontFamily *family);
   gboolean        (* is_monospace) (PangoFontFamily *family);
   gboolean        (* is_variable)  (PangoFontFamily *family);
 
diff --git a/pango/pango-font-family.c b/pango/pango-font-family.c
index 072cc1af..274f62ea 100644
--- a/pango/pango-font-family.c
+++ b/pango/pango-font-family.c
@@ -60,6 +60,12 @@ G_DEFINE_ABSTRACT_TYPE_WITH_CODE (PangoFontFamily, pango_font_family, G_TYPE_OBJ
 static PangoFontFace *pango_font_family_real_get_face (PangoFontFamily *family,
                                                        const char      *name);
 
+static gboolean
+pango_font_family_default_is_generic (PangoFontFamily *family)
+{
+  return FALSE;
+}
+
 static gboolean
 pango_font_family_default_is_monospace (PangoFontFamily *family)
 {
@@ -75,6 +81,7 @@ pango_font_family_default_is_variable (PangoFontFamily *family)
 static void
 pango_font_family_class_init (PangoFontFamilyClass *class G_GNUC_UNUSED)
 {
+  class->is_generic = pango_font_family_default_is_generic;
   class->is_monospace = pango_font_family_default_is_monospace;
   class->is_variable = pango_font_family_default_is_variable;
   class->get_face = pango_font_family_real_get_face;
@@ -152,6 +159,25 @@ pango_font_family_get_face (PangoFontFamily *family,
   return PANGO_FONT_FAMILY_GET_CLASS (family)->get_face (family, name);
 }
 
+/**
+ * pango_font_family_is_generic:
+ * @family: a `PangoFontFamily`
+ *
+ * A generic family is using a generic name such as 'sans' or
+ * 'monospace', and collects fonts matching those characteristics.
+ *
+ * Generic families are often used as fallback.
+ *
+ * Return value: %TRUE if the family is generic
+ */
+gboolean
+pango_font_family_is_generic (PangoFontFamily  *family)
+{
+  g_return_val_if_fail (PANGO_IS_FONT_FAMILY (family), FALSE);
+
+  return PANGO_FONT_FAMILY_GET_CLASS (family)->is_generic (family);
+}
+
 /**
  * pango_font_family_is_monospace:
  * @family: a `PangoFontFamily`
diff --git a/pango/pango-font-family.h b/pango/pango-font-family.h
index 927352eb..0947cbab 100644
--- a/pango/pango-font-family.h
+++ b/pango/pango-font-family.h
@@ -34,6 +34,8 @@ PANGO_DECLARE_INTERNAL_TYPE (PangoFontFamily, pango_font_family, PANGO, FONT_FAM
 
 PANGO_AVAILABLE_IN_ALL
 const char *            pango_font_family_get_name      (PangoFontFamily  *family) G_GNUC_PURE;
+PANGO_AVAILABLE_IN_ALL
+gboolean                pango_font_family_is_generic    (PangoFontFamily  *family) G_GNUC_PURE;
 PANGO_AVAILABLE_IN_1_4
 gboolean                pango_font_family_is_monospace  (PangoFontFamily  *family) G_GNUC_PURE;
 PANGO_AVAILABLE_IN_1_44


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]