[pango/pango2: 83/178] Clean up font properties




commit 8893347f8a5fe79f745b9df3824764eca8e52416
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Jun 11 21:34:33 2022 -0400

    Clean up font properties
    
    Call the matrices transform and ctm, to clearly
    separate the two. Add some more properties and
    getters.

 pango/pango-font-private.h   |  18 ++--
 pango/pango-font.c           | 244 +++++++++++++++++++++++++++++--------------
 pango/pango-font.h           |  14 ++-
 pango/pango-hbface-private.h |   2 +-
 pango/pango-hbface.c         |  32 +++---
 pango/pango-hbfont.c         |  78 ++++++++++----
 pango/pango-hbfont.h         |   4 +-
 pango/pango-userfont.c       |  13 ++-
 pango/pango-userfont.h       |   4 +-
 pango/pangocairo-font.c      |  12 +--
 pango/serializer.c           |   2 +-
 11 files changed, 278 insertions(+), 145 deletions(-)
---
diff --git a/pango/pango-font-private.h b/pango/pango-font-private.h
index e3bb6881c..4f498eefc 100644
--- a/pango/pango-font-private.h
+++ b/pango/pango-font-private.h
@@ -40,7 +40,7 @@ struct _PangoFont
   int size; /* point size, scaled by PANGO_SCALE */
   float dpi;
   PangoGravity gravity;
-  PangoMatrix matrix;
+  PangoMatrix ctm;
 
 #ifdef HAVE_CAIRO
   cairo_font_options_t *options;
@@ -68,9 +68,8 @@ struct _PangoFontClass
   void                   (* get_scale_factors)  (PangoFont      *font,
                                                  double         *x_scale,
                                                  double         *y_scale);
-  void                   (* get_matrix)         (PangoFont      *font,
+  void                   (* get_transform)      (PangoFont      *font,
                                                  PangoMatrix    *matrix);
-  int                    (* get_absolute_size)  (PangoFont      *font);
 };
 
 #define PANGO_FONT_CLASS(klass)      (G_TYPE_CHECK_CLASS_CAST ((klass), PANGO_TYPE_FONT, PangoFontClass))
@@ -105,24 +104,19 @@ pango_font_set_gravity (PangoFont    *font,
 }
 
 static inline void
-pango_font_set_matrix (PangoFont         *font,
-                       const PangoMatrix *matrix)
+pango_font_set_ctm (PangoFont         *font,
+                    const PangoMatrix *ctm)
 {
-  font->matrix = *matrix;
+  font->ctm = ctm ? *ctm : (PangoMatrix) PANGO_MATRIX_INIT;
 }
 
 gboolean pango_font_is_hinted         (PangoFont *font);
 void     pango_font_get_scale_factors (PangoFont *font,
                                        double    *x_scale,
                                        double    *y_scale);
-void     pango_font_get_matrix        (PangoFont   *font,
+void     pango_font_get_transform     (PangoFont   *font,
                                        PangoMatrix *matrix);
 
-static inline int pango_font_get_absolute_size (PangoFont *font)
-{
-  return PANGO_FONT_GET_CLASS (font)->get_absolute_size (font);
-}
-
 gboolean pango_font_description_is_similar       (const PangoFontDescription *a,
                                                   const PangoFontDescription *b);
 
diff --git a/pango/pango-font.c b/pango/pango-font.c
index 24d6add45..8433b5013 100644
--- a/pango/pango-font.c
+++ b/pango/pango-font.c
@@ -41,13 +41,38 @@
  * rendering-system-independent manner.
  */
 
+/* {{{ Utilities */
+
+static char *
+features_to_string (hb_feature_t *features,
+                    unsigned int  n_features)
+{
+  GString *s;
+  char buf[128];
+
+  s = g_string_new ("");
+
+  for (unsigned int i = 0; i < n_features; i++)
+    {
+      hb_feature_to_string (&features[i], buf, sizeof (buf));
+      if (s->len > 0)
+        g_string_append_c (s, ',');
+      g_string_append (s, buf);
+    }
+
+  return g_string_free (s, FALSE);
+}
+
+/* }}} */
+/* {{{ PangoFont implementation */
+
 enum {
   PROP_FACE = 1,
+  PROP_HB_FONT,
   PROP_SIZE,
   PROP_DPI,
   PROP_GRAVITY,
-  PROP_MATRIX,
-  PROP_HB_FONT,
+  PROP_FEATURES,
   N_PROPERTIES
 };
 
@@ -80,6 +105,10 @@ pango_font_get_property (GObject    *object,
       g_value_set_object (value, font->face);
       break;
 
+    case PROP_HB_FONT:
+      g_value_set_boxed (value, pango_font_get_hb_font (font));
+      break;
+
     case PROP_SIZE:
       g_value_set_int (value, font->size);
       break;
@@ -92,12 +121,17 @@ pango_font_get_property (GObject    *object,
       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));
+    case PROP_FEATURES:
+      {
+        hb_feature_t features[64];
+        guint n_features;
+        char *s;
+
+        pango_font_get_features (font, features, sizeof (features), &n_features);
+        s = features_to_string (features, n_features);
+        g_value_set_string (value, s);
+        g_free (s);
+      }
       break;
 
     default:
@@ -120,23 +154,19 @@ pango_font_default_get_scale_factors (PangoFont *font,
 }
 
 static void
-pango_font_default_get_matrix (PangoFont   *font,
-                               PangoMatrix *matrix)
+pango_font_default_get_transform (PangoFont   *font,
+                                  PangoMatrix *matrix)
 {
   *matrix = (PangoMatrix) PANGO_MATRIX_INIT;
 }
 
-static int
-pango_font_default_get_absolute_size (PangoFont *font)
+static void
+pango_font_default_get_features (PangoFont    *font,
+                                 hb_feature_t *features,
+                                 guint         len,
+                                 guint        *num_features)
 {
-  PangoFontDescription *desc;
-  int size;
-
-  desc = pango_font_describe_with_absolute_size (font);
-  size = pango_font_description_get_size (desc);
-  pango_font_description_free (desc);
-
-  return size;
+  *num_features = 0;
 }
 
 static void
@@ -147,15 +177,19 @@ pango_font_class_init (PangoFontClass *class G_GNUC_UNUSED)
   object_class->finalize = pango_font_finalize;
   object_class->get_property = pango_font_get_property;
 
+  class->get_features = pango_font_default_get_features;
   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;
+  class->get_transform = pango_font_default_get_transform;
 
   properties[PROP_FACE] =
       g_param_spec_object ("face", NULL, NULL, PANGO_TYPE_FONT_FACE,
                            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);
+
   properties[PROP_SIZE] =
       g_param_spec_int ("size", NULL, NULL, 0, G_MAXINT, 0,
                         G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
@@ -169,13 +203,9 @@ pango_font_class_init (PangoFontClass *class G_GNUC_UNUSED)
                          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);
+  properties[PROP_FEATURES] =
+      g_param_spec_string ("features", NULL, NULL, NULL,
+                           G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
 
   g_object_class_install_properties (object_class, N_PROPERTIES, properties);
 }
@@ -184,9 +214,62 @@ static void
 pango_font_init (PangoFont *font)
 {
   font->gravity = PANGO_GRAVITY_AUTO;
-  font->matrix = (PangoMatrix) PANGO_MATRIX_INIT;
+  font->ctm = (PangoMatrix) PANGO_MATRIX_INIT;
+}
+
+/* }}} */
+/* {{{ Private API */
+
+/*< private >
+ * pango_font_get_transform:
+ * @font: a `PangoFont`
+ * @matrix: the matrix to fill in
+ *
+ * Gets the matrix for the transformation from 'font space' to 'user space'.
+ */
+void
+pango_font_get_transform (PangoFont   *font,
+                          PangoMatrix *matrix)
+{
+  PANGO_FONT_GET_CLASS (font)->get_transform (font, matrix);
+}
+
+/*< private >
+ * pango_font_is_hinted:
+ * @font: a `PangoFont`
+ *
+ * Gets whether this font is hinted.
+ *
+ * Returns: %TRUE if @font is hinted
+ */
+gboolean
+pango_font_is_hinted (PangoFont *font)
+{
+  return PANGO_FONT_GET_CLASS (font)->is_hinted (font);
+}
+
+/*< private >
+ * pango_font_get_scale_factors:
+ * @font: a `PangoFont`
+ * @x_scale: return location for X scale
+ * @y_scale: return location for Y scale
+ *
+ * Gets the font scale factors of the ctm for this font.
+ *
+ * The ctm is the matrix set on the context that this font was
+ * loaded for.
+ */
+void
+pango_font_get_scale_factors (PangoFont *font,
+                              double    *x_scale,
+                              double    *y_scale)
+{
+  PANGO_FONT_GET_CLASS (font)->get_scale_factors (font, x_scale, y_scale);
 }
 
+/* }}} */
+/* {{{ Public API */
+
 /**
  * pango_font_describe:
  * @font: a `PangoFont`
@@ -250,10 +333,10 @@ pango_font_describe_with_absolute_size (PangoFont *font)
  * output variables and returns.
  */
 void
-pango_font_get_glyph_extents  (PangoFont      *font,
-                               PangoGlyph      glyph,
-                               PangoRectangle *ink_rect,
-                               PangoRectangle *logical_rect)
+pango_font_get_glyph_extents (PangoFont      *font,
+                              PangoGlyph      glyph,
+                              PangoRectangle *ink_rect,
+                              PangoRectangle *logical_rect)
 {
   if (G_UNLIKELY (!font))
     {
@@ -331,6 +414,8 @@ pango_font_get_metrics (PangoFont     *font,
 PangoFontFace *
 pango_font_get_face (PangoFont *font)
 {
+  g_return_val_if_fail (PANGO_IS_FONT (font), NULL);
+
   return font->face;
 }
 
@@ -362,72 +447,79 @@ pango_font_get_hb_font (PangoFont *font)
 }
 
 /**
- * pango_font_get_features:
+ * pango_font_get_size:
  * @font: a `PangoFont`
- * @features: (out caller-allocates) (array length=len): Array to features in
- * @len: the length of @features
- * @num_features: (inout): the number of used items in @features
  *
- * Obtain the OpenType features that are provided by the font.
- *
- * These are passed to the rendering system, together with features
- * that have been explicitly set via attributes.
+ * Returns the size of the font, scaled by `PANGO_SCALE`.
  *
- * Note that this does not include OpenType features which the
- * rendering system enables by default.
+ * Return value: the size of the font
  */
-void
-pango_font_get_features (PangoFont    *font,
-                         hb_feature_t *features,
-                         guint         len,
-                         guint        *num_features)
+int
+pango_font_get_size (PangoFont *font)
 {
-  if (PANGO_FONT_GET_CLASS (font)->get_features)
-    PANGO_FONT_GET_CLASS (font)->get_features (font, features, len, num_features);
+  g_return_val_if_fail (PANGO_IS_FONT (font), 0);
+
+  return font->size;
 }
 
-/*< private >
- * pango_font_get_matrix:
+/**
+ * pango_font_get_absolute_size:
  * @font: a `PangoFont`
  *
- * Gets the matrix for the transformation from 'font space' to 'user space'.
+ * Returns the pixel size of the font, scaled by `PANGO_SCALE`.
+ *
+ * Return value: the pixel size of the font
  */
-void
-pango_font_get_matrix (PangoFont   *font,
-                       PangoMatrix *matrix)
+double
+pango_font_get_absolute_size (PangoFont *font)
 {
-  PANGO_FONT_GET_CLASS (font)->get_matrix (font, matrix);
+  g_return_val_if_fail (PANGO_IS_FONT (font), 0.);
+
+  return font->size * font->dpi / 72.;
 }
 
-/*< private >
- * pango_font_is_hinted:
+/**
+ * pango_font_get_gravity:
  * @font: a `PangoFont`
  *
- * Gets whether this font is hinted.
+ * Returns the gravity of the font.
  *
- * Returns: %TRUE if @font is hinted
+ * Return value: the gravity of the font
  */
-gboolean
-pango_font_is_hinted (PangoFont *font)
+PangoGravity
+pango_font_get_gravity (PangoFont *font)
 {
-  return PANGO_FONT_GET_CLASS (font)->is_hinted (font);
+  g_return_val_if_fail (PANGO_IS_FONT (font), PANGO_GRAVITY_SOUTH);
+
+  return font->gravity;
 }
 
-/*< private >
- * pango_font_get_scale_factors:
+/**
+ * pango_font_get_features:
  * @font: a `PangoFont`
- * @x_scale: return location for X scale
- * @y_scale: return location for Y scale
+ * @features: (out caller-allocates) (array length=len): Array to features in
+ * @len: the length of @features
+ * @num_features: (inout): the number of used items in @features
  *
- * Gets the font scale factors of the ctm for this font.
+ * Obtain the OpenType features that are provided by the font.
  *
- * The ctm is the matrix set on the context that this font was
- * loaded for.
+ * These are passed to the rendering system, together with features
+ * that have been explicitly set via attributes.
+ *
+ * Note that this does not include OpenType features which the
+ * rendering system enables by default.
  */
 void
-pango_font_get_scale_factors (PangoFont *font,
-                              double    *x_scale,
-                              double    *y_scale)
+pango_font_get_features (PangoFont    *font,
+                         hb_feature_t *features,
+                         guint         len,
+                         guint        *num_features)
 {
-  PANGO_FONT_GET_CLASS (font)->get_scale_factors (font, x_scale, y_scale);
+  g_return_if_fail (PANGO_IS_FONT (font));
+
+  PANGO_FONT_GET_CLASS (font)->get_features (font, features, len, num_features);
 }
+
+/* }}} */
+
+/* vim:set foldmethod=marker expandtab: */
diff --git a/pango/pango-font.h b/pango/pango-font.h
index 7aa1e0e09..878aa2b94 100644
--- a/pango/pango-font.h
+++ b/pango/pango-font.h
@@ -51,13 +51,23 @@ void                  pango_font_get_glyph_extents (PangoFont        *font,
 PANGO_AVAILABLE_IN_ALL
 PangoFontFace *       pango_font_get_face          (PangoFont        *font);
 
+PANGO_AVAILABLE_IN_ALL
+hb_font_t *           pango_font_get_hb_font       (PangoFont        *font);
+
+PANGO_AVAILABLE_IN_ALL
+int                   pango_font_get_size          (PangoFont        *font);
+
+PANGO_AVAILABLE_IN_ALL
+double                pango_font_get_absolute_size (PangoFont        *font);
+
+PANGO_AVAILABLE_IN_ALL
+PangoGravity          pango_font_get_gravity       (PangoFont        *font);
+
 PANGO_AVAILABLE_IN_ALL
 void                  pango_font_get_features      (PangoFont        *font,
                                                     hb_feature_t     *features,
                                                     guint             len,
                                                     guint            *num_features);
-PANGO_AVAILABLE_IN_ALL
-hb_font_t *           pango_font_get_hb_font       (PangoFont        *font);
 
 PANGO_AVAILABLE_IN_ALL
 GBytes *              pango_font_serialize         (PangoFont        *font);
diff --git a/pango/pango-hbface-private.h b/pango/pango-hbface-private.h
index b9b918042..403ff66d7 100644
--- a/pango/pango-hbface-private.h
+++ b/pango/pango-hbface-private.h
@@ -36,7 +36,7 @@ struct _PangoHbFace
   hb_face_t *face;
   hb_variation_t *variations;
   unsigned int n_variations;
-  PangoMatrix *matrix;
+  PangoMatrix *transform;
   double x_scale, y_scale;
   PangoLanguageSet *languages;
   gboolean embolden;
diff --git a/pango/pango-hbface.c b/pango/pango-hbface.c
index 6ff15d0c0..e180f0d44 100644
--- a/pango/pango-hbface.c
+++ b/pango/pango-hbface.c
@@ -250,8 +250,8 @@ ensure_faceid (PangoHbFace *self)
   while ((p = strpbrk (p, " =,")) != NULL)
     *p = '?';
 
-  if (self->matrix)
-    slant = pango_matrix_get_slant_ratio (self->matrix);
+  if (self->transform)
+    slant = pango_matrix_get_slant_ratio (self->transform);
   else
     slant = 0.;
 
@@ -329,7 +329,7 @@ G_DEFINE_FINAL_TYPE (PangoHbFace, pango_hb_face, PANGO_TYPE_FONT_FACE)
 static void
 pango_hb_face_init (PangoHbFace *self)
 {
-  self->matrix = NULL;
+  self->transform = NULL;
   self->x_scale = self->y_scale = 1.;
 }
 
@@ -345,8 +345,8 @@ pango_hb_face_finalize (GObject *object)
   if (self->languages)
     g_object_unref (self->languages);
   g_free (self->variations);
-  if (self->matrix)
-    g_free (self->matrix);
+  if (self->transform)
+    g_free (self->transform);
 
   G_OBJECT_CLASS (pango_hb_face_parent_class)->finalize (object);
 }
@@ -642,13 +642,13 @@ void
 pango_hb_face_set_matrix (PangoHbFace       *self,
                           const PangoMatrix *matrix)
 {
-  if (!self->matrix)
-    self->matrix = g_new (PangoMatrix, 1);
+  if (!self->transform)
+    self->transform = g_new (PangoMatrix, 1);
 
-  *self->matrix = *matrix;
+  *self->transform = *matrix;
 
-  pango_matrix_get_font_scale_factors (self->matrix, &self->x_scale, &self->y_scale);
-  pango_matrix_scale (self->matrix, 1./self->x_scale, 1./self->y_scale);
+  pango_matrix_get_font_scale_factors (self->transform, &self->x_scale, &self->y_scale);
+  pango_matrix_scale (self->transform, 1./self->x_scale, 1./self->y_scale);
 }
 
 /* }}} */
@@ -847,7 +847,7 @@ pango_hb_face_new_synthetic (PangoHbFace                *face,
     pango_hb_face_set_matrix (self, transform);
 
   self->embolden = embolden;
-  self->synthetic = self->embolden || (self->matrix != NULL);
+  self->synthetic = self->embolden || (self->transform != NULL);
 
   desc = pango_font_description_copy (PANGO_FONT_FACE (face)->description);
   pango_font_description_merge (desc, description, TRUE);
@@ -923,15 +923,15 @@ pango_hb_face_new_instance (PangoHbFace                *face,
   self->index = face->index;
   self->instance_id = face->instance_id;
 
-  if (face->matrix)
+  if (face->transform)
     {
-      self->matrix = g_memdup2 (face->matrix, sizeof (PangoMatrix));
+      self->transform = g_memdup2 (face->transform, sizeof (PangoMatrix));
       self->x_scale = face->x_scale;
       self->y_scale = face->y_scale;
     }
 
   self->embolden = face->embolden;
-  self->synthetic = self->embolden || (self->matrix != NULL);
+  self->synthetic = self->embolden || (self->transform != NULL);
 
   self->variations = g_memdup2 (variations, sizeof (hb_variation_t) * n_variations);
   self->n_variations = n_variations;
@@ -1061,7 +1061,7 @@ pango_hb_face_get_embolden (PangoHbFace *self)
  * pango_hb_face_get_transform:
  * @self: a `PangoHbFace`
  *
- * Gets the transform that this face uses.
+ * Gets the transform from 'font space' to 'user space' that this face uses.
  *
  * This is the 'font matrix' which is used for
  * sythetic italics and width variations.
@@ -1073,7 +1073,7 @@ pango_hb_face_get_transform (PangoHbFace *self)
 {
   g_return_val_if_fail (PANGO_IS_HB_FACE (self), NULL);
 
-  return self->matrix;
+  return self->transform;
 }
 
 /* }}} */
diff --git a/pango/pango-hbfont.c b/pango/pango-hbfont.c
index 78ecee2d3..7fe0b52d5 100644
--- a/pango/pango-hbfont.c
+++ b/pango/pango-hbfont.c
@@ -383,7 +383,7 @@ create_hex_box_info (PangoHbFont *self)
 
   /* Load mini_font */
   context = pango_font_map_create_context (map);
-  pango_context_set_matrix (context, &font->matrix);
+  pango_context_set_matrix (context, &font->ctm);
   pango_context_set_language (context, pango_script_get_sample_language (G_UNICODE_SCRIPT_LATIN));
 
   mini_font = pango_font_map_load_font (map, context, desc);
@@ -524,6 +524,13 @@ struct _PangoHbFontClass
   PangoFontClass parent_class;
 };
 
+enum {
+  PROP_VARIATIONS = 1,
+  N_PROPERTIES
+};
+
+static GParamSpec *properties[N_PROPERTIES] = { NULL, };
+
 G_DEFINE_FINAL_TYPE (PangoHbFont, pango_hb_font, PANGO_TYPE_FONT)
 
 static void
@@ -549,6 +556,31 @@ pango_hb_font_finalize (GObject *object)
   G_OBJECT_CLASS (pango_hb_font_parent_class)->finalize (object);
 }
 
+
+static void
+pango_hb_font_get_property (GObject    *object,
+                            guint       property_id,
+                            GValue     *value,
+                            GParamSpec *pspec)
+{
+  PangoHbFont *self = PANGO_HB_FONT (object);
+
+  switch (property_id)
+    {
+    case PROP_VARIATIONS:
+      {
+        char *str = NULL;
+        if (self->variations)
+          str = variations_to_string (self->variations, self->n_variations);
+        g_value_take_string (value, str);
+      }
+      break;
+
+    default:
+      G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+    }
+}
+
 static PangoFontDescription *
 pango_hb_font_describe (PangoFont *font)
 {
@@ -643,12 +675,12 @@ pango_hb_font_get_glyph_extents (PangoFont      *font,
       r.width = extents.width;
       r.height = - extents.height;
 
-      if (face->matrix)
+      if (face->transform)
         {
-          m.xx = face->matrix->xx;
-          m.yx = - face->matrix->yx;
-          m.xy = - face->matrix->xy;
-          m.yy = face->matrix->yy;
+          m.xx = face->transform->xx;
+          m.yx = - face->transform->yx;
+          m.xy = - face->transform->xy;
+          m.yy = face->transform->yy;
         }
 
       pango_matrix_transform_rectangle (&m, &r);
@@ -815,7 +847,7 @@ pango_hb_font_create_hb_font (PangoFont *font)
   hb_font_set_ptem (hb_font, font->size / PANGO_SCALE);
 
 #if HB_VERSION_ATLEAST (3, 3, 0)
-  hb_font_set_synthetic_slant (hb_font, pango_matrix_get_slant_ratio (face->matrix));
+  hb_font_set_synthetic_slant (hb_font, pango_matrix_get_slant_ratio (face->transform));
 #endif
 
   if (face->instance_id >= 0)
@@ -847,14 +879,14 @@ pango_hb_font_create_hb_font (PangoFont *font)
 }
 
 static void
-pango_hb_font_get_matrix (PangoFont   *font,
-                          PangoMatrix *matrix)
+pango_hb_font_get_transform (PangoFont   *font,
+                               PangoMatrix *matrix)
 {
   PangoHbFace *face = PANGO_HB_FACE (font->face);
 
-  if (face->matrix)
+  if (face->transform)
     {
-      *matrix = *face->matrix;
+      *matrix = *face->transform;
       pango_matrix_scale (matrix, face->x_scale, face->y_scale);
     }
   else
@@ -880,13 +912,20 @@ pango_hb_font_class_init (PangoHbFontClass *class)
   PangoFontClass *font_class = PANGO_FONT_CLASS (class);
 
   object_class->finalize = pango_hb_font_finalize;
+  object_class->get_property = pango_hb_font_get_property;
 
   font_class->describe = pango_hb_font_describe;
   font_class->get_glyph_extents = pango_hb_font_get_glyph_extents;
   font_class->get_metrics = pango_hb_font_get_metrics;
   font_class->create_hb_font = pango_hb_font_create_hb_font;
   font_class->get_features = pango_hb_font_get_features;
-  font_class->get_matrix = pango_hb_font_get_matrix;
+  font_class->get_transform = pango_hb_font_get_transform;
+
+  properties[PROP_VARIATIONS] =
+      g_param_spec_string ("variations", NULL, NULL, NULL,
+                           G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
+
+  g_object_class_install_properties (object_class, N_PROPERTIES, properties);
 }
 
 /* }}} */
@@ -902,7 +941,7 @@ pango_hb_font_class_init (PangoHbFontClass *class)
  * @n_variations: length of @variations
  * @gravity: the gravity to use when rendering
  * @dpi: the dpi used when rendering
- * @matrix: (nullable): transformation matrix to use when rendering
+ * @ctm: (nullable): transformation matrix to use when rendering
  *
  * Creates a new `PangoHbFont`.
  *
@@ -917,7 +956,7 @@ pango_hb_font_new (PangoHbFace       *face,
                    unsigned int       n_variations,
                    PangoGravity       gravity,
                    float              dpi,
-                   const PangoMatrix *matrix)
+                   const PangoMatrix *ctm)
 {
   PangoHbFont *self;
   PangoFont *font;
@@ -934,8 +973,7 @@ pango_hb_font_new (PangoHbFace       *face,
   pango_font_set_size (font, size);
   pango_font_set_dpi (font, dpi);
   pango_font_set_gravity (font, gravity);
-  if (matrix)
-    pango_font_set_matrix (font, matrix);
+  pango_font_set_ctm (font, ctm);
 
   self->features = g_memdup2 (features, sizeof (hb_feature_t) * n_features);
   self->n_features = n_features;
@@ -950,7 +988,7 @@ pango_hb_font_new (PangoHbFace       *face,
  * @face: the `PangoHbFace` to use
  * @description: a `PangoFontDescription`
  * @dpi: the dpi used when rendering
- * @matrix: (nullable): transformation matrix to use when rendering
+ * @ctm: (nullable): transformation matrix to use when rendering
  *
  * Creates a new `PangoHbFont` with size, features, variations and
  * gravity taken from a font description.
@@ -961,7 +999,7 @@ PangoHbFont *
 pango_hb_font_new_for_description (PangoHbFace                *face,
                                    const PangoFontDescription *description,
                                    float                       dpi,
-                                   const PangoMatrix          *matrix)
+                                   const PangoMatrix          *ctm)
 {
   int size;
   hb_feature_t features[10];
@@ -1005,11 +1043,11 @@ pango_hb_font_new_for_description (PangoHbFace                *face,
   else
     gravity = PANGO_GRAVITY_AUTO;
 
-  return pango_hb_font_new (face, size, features, n_features, variations, n_variations, gravity, dpi, 
matrix);
+  return pango_hb_font_new (face, size, features, n_features, variations, n_variations, gravity, dpi, ctm);
 }
 
 /**
- * hb_font_get_variations:
+ * pango_hb_font_get_variations:
  * @self: a `PangoHbFont`
  * @n_variations: (nullable) (out caller-allocates): return location for
  *   the length of the returned array
diff --git a/pango/pango-hbfont.h b/pango/pango-hbfont.h
index 6c6fe0c09..fe7f14d9a 100644
--- a/pango/pango-hbfont.h
+++ b/pango/pango-hbfont.h
@@ -40,13 +40,13 @@ PangoHbFont *           pango_hb_font_new                       (PangoHbFace
                                                                  unsigned int                    
n_variations,
                                                                  PangoGravity                    gravity,
                                                                  float                           dpi,
-                                                                 const PangoMatrix              *matrix);
+                                                                 const PangoMatrix              *ctm);
 
 PANGO_AVAILABLE_IN_ALL
 PangoHbFont *           pango_hb_font_new_for_description       (PangoHbFace                    *face,
                                                                  const PangoFontDescription     *description,
                                                                  float                           dpi,
-                                                                 const PangoMatrix              *matrix);
+                                                                 const PangoMatrix              *ctm);
 
 
 PANGO_AVAILABLE_IN_ALL
diff --git a/pango/pango-userfont.c b/pango/pango-userfont.c
index e0ebb2873..5bbd80984 100644
--- a/pango/pango-userfont.c
+++ b/pango/pango-userfont.c
@@ -350,7 +350,7 @@ pango_user_font_class_init (PangoUserFontClass *class)
  * @size: the desired size in points, scaled by `PANGO_SCALE`
  * @gravity: the gravity to use when rendering
  * @dpi: the dpi used when rendering
- * @matrix: (nullable): transformation matrix to use when rendering
+ * @ctm: (nullable): transformation matrix to use when rendering
  *
  * Creates a new `PangoUserFont`.
  *
@@ -361,7 +361,7 @@ pango_user_font_new (PangoUserFace     *face,
                      int                size,
                      PangoGravity       gravity,
                      float              dpi,
-                     const PangoMatrix *matrix)
+                     const PangoMatrix *ctm)
 {
   PangoUserFont *self;
   PangoFont *font;
@@ -374,8 +374,7 @@ pango_user_font_new (PangoUserFace     *face,
   pango_font_set_size (font, size);
   pango_font_set_dpi (font, dpi);
   pango_font_set_gravity (font, gravity);
-  if (matrix)
-    pango_font_set_matrix (font, matrix);
+  pango_font_set_ctm (font, ctm);
 
   return self;
 }
@@ -385,7 +384,7 @@ pango_user_font_new (PangoUserFace     *face,
  * @face: the `PangoUserFace` to use
  * @description: a `PangoFontDescription`
  * @dpi: the dpi used when rendering
- * @matrix: (nullable): transformation matrix to use when rendering
+ * @ctm: (nullable): transformation matrix to use when rendering
  *
  * Creates a new `PangoUserFont` with size and gravity taken
  * from a font description.
@@ -397,7 +396,7 @@ PangoUserFont *
 pango_user_font_new_for_description (PangoUserFace              *face,
                                      const PangoFontDescription *description,
                                      float                       dpi,
-                                     const PangoMatrix          *matrix)
+                                     const PangoMatrix          *ctm)
 {
   int size;
   PangoGravity gravity;
@@ -413,7 +412,7 @@ pango_user_font_new_for_description (PangoUserFace              *face,
   else
     gravity = PANGO_GRAVITY_AUTO;
 
-  return pango_user_font_new (face, size, gravity, dpi, matrix);
+  return pango_user_font_new (face, size, gravity, dpi, ctm);
 }
 
 /* }}} */
diff --git a/pango/pango-userfont.h b/pango/pango-userfont.h
index e60cf508d..85f8723cf 100644
--- a/pango/pango-userfont.h
+++ b/pango/pango-userfont.h
@@ -35,12 +35,12 @@ PangoUserFont * pango_user_font_new                 (PangoUserFace
                                                      int                         size,
                                                      PangoGravity                gravity,
                                                      float                       dpi,
-                                                     const PangoMatrix          *matrix);
+                                                     const PangoMatrix          *ctm);
 
 PANGO_AVAILABLE_IN_ALL
 PangoUserFont * pango_user_font_new_for_description (PangoUserFace              *face,
                                                      const PangoFontDescription *description,
                                                      float                       dpi,
-                                                     const PangoMatrix          *matrix);
+                                                     const PangoMatrix          *ctm);
 
 G_END_DECLS
diff --git a/pango/pangocairo-font.c b/pango/pangocairo-font.c
index 5ca9a0474..0541c3179 100644
--- a/pango/pangocairo-font.c
+++ b/pango/pangocairo-font.c
@@ -569,12 +569,12 @@ _pango_font_get_cairo_font_private (PangoFont *font)
       if (PANGO_IS_HB_FONT (font))
         {
           PangoHbFace *face = PANGO_HB_FACE (font->face);
-          if (face->matrix)
+          if (face->transform)
             cairo_matrix_init (&font_matrix,
-                               face->matrix->xx,
-                               - face->matrix->yx,
-                               - face->matrix->xy,
-                               face->matrix->yy,
+                               face->transform->xx,
+                               - face->transform->yx,
+                               - face->transform->xy,
+                               face->transform->yy,
                                0., 0.);
 
           x_scale = face->x_scale;
@@ -602,7 +602,7 @@ _pango_font_get_cairo_font_private (PangoFont *font)
                                             font,
                                             font->gravity,
                                             font_options,
-                                            &font->matrix,
+                                            &font->ctm,
                                             &font_matrix);
 
       cairo_font_options_destroy (font_options);
diff --git a/pango/serializer.c b/pango/serializer.c
index b821904d4..154cf28d5 100644
--- a/pango/serializer.c
+++ b/pango/serializer.c
@@ -625,7 +625,7 @@ add_font (GtkJsonPrinter *printer,
       gtk_json_printer_end (printer);
     }
 
-  pango_font_get_matrix (font, &matrix);
+  pango_font_get_transform (font, &matrix);
   if (!pango_matrix_equal (&matrix, &(const PangoMatrix)PANGO_MATRIX_INIT))
     {
       gtk_json_printer_start_array (printer, "matrix");


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