[pango/pango2: 118/201] Add pango_font_family_is_generic
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/pango2: 118/201] Add pango_font_family_is_generic
- Date: Sat, 11 Jun 2022 02:22:30 +0000 (UTC)
commit 4328f6d7ea5a9762ac5ff0879a835168e4415ce5
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]