[pango/synthetic-slant: 310/311] Add pango_matrix_get_slant_ratio




commit d869ec5d07d6376c1d15748e6efbbf1a507410d7
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Sep 11 12:30:46 2021 -0400

    Add pango_matrix_get_slant_ratio

 pango/pango-matrix.c | 29 +++++++++++++++++++++++++++++
 pango/pango-matrix.h |  2 ++
 2 files changed, 31 insertions(+)
---
diff --git a/pango/pango-matrix.c b/pango/pango-matrix.c
index a066eb57..12feb721 100644
--- a/pango/pango-matrix.c
+++ b/pango/pango-matrix.c
@@ -262,6 +262,35 @@ pango_matrix_get_font_scale_factors (const PangoMatrix *matrix,
     *yscale = minor;
 }
 
+/**
+ * pango_matrix_get_slant_ratio:
+ * @matrix: a `PangoMatrix`
+ *
+ * Gets the slant ratio of a matrix.
+ *
+ * This function assumes that the matrix does not have scale or
+ * rotation components, and is in the form of a shear matrix:
+ *
+ *     1 λ
+ *     0 1
+ *
+ * Returns: the slant ratio of @matrix
+ *
+ * Since: 1.50
+ */
+double
+pango_matrix_get_slant_ratio (const PangoMatrix *matrix)
+{
+  double x, y;
+
+  x = 0;
+  y = 1;
+
+  pango_matrix_transform_distance (matrix, &x, &y);
+
+  return  - x / y;
+}
+
 /**
  * pango_matrix_transform_distance:
  * @matrix: (nullable): a `PangoMatrix`
diff --git a/pango/pango-matrix.h b/pango/pango-matrix.h
index d4277401..cb53a422 100644
--- a/pango/pango-matrix.h
+++ b/pango/pango-matrix.h
@@ -121,6 +121,8 @@ double pango_matrix_get_font_scale_factor (const PangoMatrix *matrix) G_GNUC_PUR
 PANGO_AVAILABLE_IN_1_38
 void pango_matrix_get_font_scale_factors (const PangoMatrix *matrix,
                                          double *xscale, double *yscale);
+PANGO_AVAILABLE_IN_1_50
+double pango_matrix_get_slant_ratio (const PangoMatrix *matrix) G_GNUC_PURE;
 
 
 G_END_DECLS


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