[pango/pango2-windows: 89/130] font: add properties




commit f280777ed4f65e74f9804754d3e675ac05866757
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jun 11 15:31:00 2022 -0400

    font: add properties

 pango/pango-font.c | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 81 insertions(+)
---
diff --git a/pango/pango-font.c b/pango/pango-font.c
index 9b9028a2f..95f8a3ae5 100644
--- a/pango/pango-font.c
+++ b/pango/pango-font.c
@@ -32,6 +32,8 @@
 #include "pango-fontmap-private.h"
 #include "pango-impl-utils.h"
 
+#include <hb-gobject.h>
+
 /**
  * PangoFont:
  *
@@ -39,6 +41,18 @@
  * rendering-system-independent manner.
  */
 
+enum {
+  PROP_FACE = 1,
+  PROP_SIZE,
+  PROP_DPI,
+  PROP_GRAVITY,
+  PROP_MATRIX,
+  PROP_HB_FONT,
+  N_PROPERTIES
+};
+
+static GParamSpec *properties[N_PROPERTIES] = { NULL, };
+
 G_DEFINE_ABSTRACT_TYPE (PangoFont, pango_font, G_TYPE_OBJECT)
 
 static void
@@ -52,6 +66,45 @@ pango_font_finalize (GObject *object)
   G_OBJECT_CLASS (pango_font_parent_class)->finalize (object);
 }
 
+static void
+pango_font_get_property (GObject    *object,
+                         guint       property_id,
+                         GValue     *value,
+                         GParamSpec *pspec)
+{
+  PangoFont *font = PANGO_FONT (object);
+
+  switch (property_id)
+    {
+    case PROP_FACE:
+      g_value_set_object (value, font->face);
+      break;
+
+    case PROP_SIZE:
+      g_value_set_int (value, font->size);
+      break;
+
+    case PROP_DPI:
+      g_value_set_float (value, font->dpi);
+      break;
+
+    case PROP_GRAVITY:
+      g_value_set_enum (value, font->gravity);
+      break;
+
+    case PROP_MATRIX:
+      g_value_set_boxed (value, &font->matrix);
+      break;
+
+    case PROP_HB_FONT:
+      g_value_set_boxed (value, pango_font_get_hb_font (font));
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    }
+}
+
 static gboolean
 pango_font_default_is_hinted (PangoFont *font)
 {
@@ -92,11 +145,39 @@ pango_font_class_init (PangoFontClass *class G_GNUC_UNUSED)
   GObjectClass *object_class = G_OBJECT_CLASS (class);
 
   object_class->finalize = pango_font_finalize;
+  object_class->get_property = pango_font_get_property;
 
   class->is_hinted = pango_font_default_is_hinted;
   class->get_scale_factors = pango_font_default_get_scale_factors;
   class->get_matrix = pango_font_default_get_matrix;
   class->get_absolute_size = pango_font_default_get_absolute_size;
+
+  properties[PROP_FACE] =
+      g_param_spec_object ("face", NULL, NULL, PANGO_TYPE_FONT_FACE,
+                           G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+  properties[PROP_SIZE] =
+      g_param_spec_int ("size", NULL, NULL, 0, G_MAXINT, 0,
+                        G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+  properties[PROP_DPI] =
+      g_param_spec_float ("dpi", NULL, NULL, 0, G_MAXFLOAT, 96.0,
+                          G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+  properties[PROP_GRAVITY] =
+      g_param_spec_enum ("gravity", NULL, NULL, PANGO_TYPE_GRAVITY,
+                         PANGO_GRAVITY_AUTO,
+                         G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+  properties[PROP_MATRIX] =
+      g_param_spec_boxed ("matrix", NULL, NULL, PANGO_TYPE_MATRIX,
+                          G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+  properties[PROP_HB_FONT] =
+      g_param_spec_boxed ("hb-font", NULL, NULL, HB_GOBJECT_TYPE_FONT,
+                          G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+  g_object_class_install_properties (object_class, N_PROPERTIES, properties);
 }
 
 static void


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