[pango/pango2: 34/115] Add pango_font_face_is_variable/monospace




commit 6461c1341adf5033d67849cb4e217a051d2a51ed
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Feb 17 17:03:40 2022 -0600

    Add pango_font_face_is_variable/monospace
    
    These are really properties of the individual
    faces, not the family.
    
    The default implementations of these functions
    simply return the corresponding family value.
    
    Add some tests for the new api.

 pango/pango-font-face-private.h |  2 ++
 pango/pango-font-face.c         | 57 +++++++++++++++++++++++++++++++++++++++++
 pango/pango-font-face.h         |  4 +++
 3 files changed, 63 insertions(+)
---
diff --git a/pango/pango-font-face-private.h b/pango/pango-font-face-private.h
index d7c2b635..8fabce44 100644
--- a/pango/pango-font-face-private.h
+++ b/pango/pango-font-face-private.h
@@ -36,6 +36,8 @@ struct _PangoFontFaceClass
   const char *           (* get_face_name)  (PangoFontFace *face);
   PangoFontDescription * (* describe)       (PangoFontFace *face);
   gboolean               (* is_synthesized) (PangoFontFace *face);
+  gboolean               (*is_monospace)    (PangoFontFace *face);
+  gboolean               (*is_variable)     (PangoFontFace *face);
   PangoFontFamily *      (* get_family)     (PangoFontFace *face);
 };
 
diff --git a/pango/pango-font-face.c b/pango/pango-font-face.c
index 933b341d..9eb46bac 100644
--- a/pango/pango-font-face.c
+++ b/pango/pango-font-face.c
@@ -21,13 +21,28 @@
 #include "config.h"
 
 #include "pango-font-face-private.h"
+#include "pango-font-family.h"
 
 
 G_DEFINE_ABSTRACT_TYPE (PangoFontFace, pango_font_face, G_TYPE_OBJECT)
 
+static gboolean
+pango_font_face_default_is_monospace (PangoFontFace *face)
+{
+  return pango_font_family_is_monospace (pango_font_face_get_family (face));
+}
+
+static gboolean
+pango_font_face_default_is_variable (PangoFontFace *face)
+{
+  return pango_font_family_is_variable (pango_font_face_get_family (face));
+}
+
 static void
 pango_font_face_class_init (PangoFontFaceClass *class G_GNUC_UNUSED)
 {
+  class->is_monospace = pango_font_face_default_is_monospace;
+  class->is_variable = pango_font_face_default_is_variable;
 }
 
 static void
@@ -120,3 +135,45 @@ pango_font_face_get_family (PangoFontFace *face)
 
   return PANGO_FONT_FACE_GET_CLASS (face)->get_family (face);
 }
+
+/**
+ * pango_font_face_is_monospace:
+ * @face: a `PangoFontFace`
+ *
+ * A monospace font is a font designed for text display where the the
+ * characters form a regular grid.
+ *
+ * See [method@Pango.FontFamily.is_monospace] for more details.
+ *
+ * Returns: `TRUE` if @face is monospace
+ *
+ * Since: 1.52
+ */
+gboolean
+pango_font_face_is_monospace (PangoFontFace *face)
+{
+  g_return_val_if_fail (PANGO_IS_FONT_FACE (face), FALSE);
+
+  return PANGO_FONT_FACE_GET_CLASS (face)->is_monospace (face);
+}
+
+/**
+ * pango_font_face_is_variable:
+ * @face: a `PangoFontFace`
+ *
+ * A variable font is a font which has axes that can be modified
+ * to produce variations.
+ *
+ * See [method@Pango.FontFamily.is_variable] for more details.
+ *
+ * Returns: `TRUE` if @face is variable
+ *
+ * Since: 1.52
+ */
+gboolean
+pango_font_face_is_variable (PangoFontFace *face)
+{
+  g_return_val_if_fail (PANGO_IS_FONT_FACE (face), FALSE);
+
+  return PANGO_FONT_FACE_GET_CLASS (face)->is_variable (face);
+}
diff --git a/pango/pango-font-face.h b/pango/pango-font-face.h
index ca606fa2..caca6ac7 100644
--- a/pango/pango-font-face.h
+++ b/pango/pango-font-face.h
@@ -37,6 +37,10 @@ PANGO_AVAILABLE_IN_ALL
 const char *            pango_font_face_get_face_name  (PangoFontFace  *face) G_GNUC_PURE;
 PANGO_AVAILABLE_IN_1_18
 gboolean                pango_font_face_is_synthesized (PangoFontFace  *face) G_GNUC_PURE;
+PANGO_AVAILABLE_IN_1_52
+gboolean                pango_font_face_is_monospace   (PangoFontFace  *face);
+PANGO_AVAILABLE_IN_1_52
+gboolean                pango_font_face_is_variable    (PangoFontFace  *face);
 
 PANGO_AVAILABLE_IN_1_46
 PangoFontFamily *       pango_font_face_get_family     (PangoFontFace  *face);


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