[pango/simple-fontmap: 33/35] Add a matrix




commit 33ee3a3ef66cbbf2245555acb9ccc730b1f640f6
Author: Matthias Clasen <mclasen redhat com>
Date:   Thu Oct 21 11:35:57 2021 -0700

    Add a matrix
    
    This is an attempt to make rotation work right.
    It isn't yet.

 pango/pango-hbfont-private.h | 1 +
 pango/pango-hbfont.c         | 5 +++++
 pango/pango-hbfont.h         | 1 +
 pango/pango-simplefontmap.c  | 6 +++++-
 pango/pangocairo-fcfont.c    | 9 +++++++--
 5 files changed, 19 insertions(+), 3 deletions(-)
---
diff --git a/pango/pango-hbfont-private.h b/pango/pango-hbfont-private.h
index 3e1c98d1..278d224f 100644
--- a/pango/pango-hbfont-private.h
+++ b/pango/pango-hbfont-private.h
@@ -11,5 +11,6 @@ struct _PangoHbFont
   PangoHbFace *face;
   PangoFontDescription *description;
   PangoGravity gravity;
+  PangoMatrix matrix;
   double dpi;
 };
diff --git a/pango/pango-hbfont.c b/pango/pango-hbfont.c
index 3864e14b..2e4da212 100644
--- a/pango/pango-hbfont.c
+++ b/pango/pango-hbfont.c
@@ -40,6 +40,7 @@ static void
 pango_hb_font_init (PangoHbFont *self)
 {
   self->gravity = PANGO_GRAVITY_SOUTH;
+  self->matrix = (PangoMatrix) PANGO_MATRIX_INIT;
   self->dpi = 96.;
 }
 
@@ -232,6 +233,7 @@ pango_hb_font_get_glyph_extents (PangoFont      *font,
       logical_rect->y = - font_extents.ascender;
       logical_rect->height = font_extents.ascender - font_extents.descender;
     }
+
 }
 
 static PangoFontMetrics *
@@ -395,6 +397,7 @@ PangoHbFont *
 pango_hb_font_new (PangoHbFace                *face,
                    const PangoFontDescription *description,
                    PangoGravity                gravity,
+                   const PangoMatrix          *matrix,
                    double                      dpi)
 {
   PangoHbFont *font;
@@ -404,6 +407,8 @@ pango_hb_font_new (PangoHbFace                *face,
   font->face = g_object_ref (face);
   font->description = pango_font_description_copy (description);
   font->gravity = gravity;
+  if (matrix)
+    font->matrix = *matrix;
   font->dpi = dpi;
 
   return font;
diff --git a/pango/pango-hbfont.h b/pango/pango-hbfont.h
index 3d388701..b65e0b1e 100644
--- a/pango/pango-hbfont.h
+++ b/pango/pango-hbfont.h
@@ -36,6 +36,7 @@ PANGO_AVAILABLE_IN_1_50
 PangoHbFont *           pango_hb_font_new               (PangoHbFace                 *face,
                                                          const PangoFontDescription  *description,
                                                          PangoGravity                 gravity,
+                                                         const PangoMatrix           *matrix,
                                                          double                       dpi);
 
 G_END_DECLS
diff --git a/pango/pango-simplefontmap.c b/pango/pango-simplefontmap.c
index 4dc0a885..44cbcc67 100644
--- a/pango/pango-simplefontmap.c
+++ b/pango/pango-simplefontmap.c
@@ -206,6 +206,8 @@ pango_simple_font_map_load_font (PangoFontMap               *map,
   PangoFontDescription *best = NULL;
   PangoHbFace *face = NULL;
   PangoHbFont *font;
+  PangoGravity gravity;
+  const PangoMatrix *matrix;
 
   for (int i = 0; i < self->faces->len; i++)
     {
@@ -220,7 +222,9 @@ pango_simple_font_map_load_font (PangoFontMap               *map,
   if (face == NULL)
     face = g_ptr_array_index (self->faces, 0);
 
-  font = pango_hb_font_new (face, desc, pango_context_get_gravity (context), self->dpi);
+  gravity = pango_context_get_gravity (context);
+  matrix = pango_context_get_matrix (context);
+  font = pango_hb_font_new (face, desc, gravity, matrix, self->dpi);
 
   return PANGO_FONT (font);
 }
diff --git a/pango/pangocairo-fcfont.c b/pango/pangocairo-fcfont.c
index 1545509e..1c149213 100644
--- a/pango/pangocairo-fcfont.c
+++ b/pango/pangocairo-fcfont.c
@@ -323,10 +323,15 @@ create_scaled_font (PangoHbFont *font)
 
   size = pango_font_description_get_size (font->description);
 
+  cairo_matrix_init (&ctm,
+                     font->matrix.xx,
+                     font->matrix.yx,
+                     font->matrix.xy,
+                     font->matrix.yy,
+                     0., 0.);
+
   cairo_matrix_init_rotate (&gravity_matrix,
                             pango_gravity_to_rotation (font->gravity));
-
-  cairo_matrix_init_identity (&ctm);
   cairo_matrix_init_scale (&font_matrix,
                            size * (font->dpi / 72.) / PANGO_SCALE,
                            size * (font->dpi / 72.) / PANGO_SCALE);


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