summaryrefslogtreecommitdiff
path: root/pango/pango-matrix.c
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2022-01-02 18:49:34 +0000
committerMatthias Clasen <mclasen@redhat.com>2022-01-02 18:49:34 +0000
commite7147f503495aa88299ca597382c4a4584ea268e (patch)
tree01af735f9e717c0184e180da59e9c66c8f493f2b /pango/pango-matrix.c
parentfc46f12754e9035c71da2747be55361ddfcf7635 (diff)
parent1a553ba64c43c13e37d54f1fb20a656ffb2ef067 (diff)
downloadpango-e7147f503495aa88299ca597382c4a4584ea268e.tar.gz
Merge branch 'synthetic-slant' into 'main'
Pass synthetic slant to harfbuzz See merge request GNOME/pango!474
Diffstat (limited to 'pango/pango-matrix.c')
-rw-r--r--pango/pango-matrix.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/pango/pango-matrix.c b/pango/pango-matrix.c
index a066eb57..3bc0ff16 100644
--- a/pango/pango-matrix.c
+++ b/pango/pango-matrix.c
@@ -263,6 +263,40 @@ pango_matrix_get_font_scale_factors (const PangoMatrix *matrix,
}
/**
+ * pango_matrix_get_slant_ratio:
+ * @matrix: a `PangoMatrix`
+ *
+ * Gets the slant ratio of a matrix.
+ *
+ * For a simple shear matrix in the form:
+ *
+ * 1 λ
+ * 0 1
+ *
+ * this is simply λ.
+ *
+ * Returns: the slant ratio of @matrix
+ *
+ * Since: 1.50
+ */
+double
+pango_matrix_get_slant_ratio (const PangoMatrix *matrix)
+{
+ double x0, y0;
+ double x1, y1;
+
+ x0 = 0;
+ y0 = 1;
+ pango_matrix_transform_distance (matrix, &x0, &y0);
+
+ x1 = 1;
+ y1 = 0;
+ pango_matrix_transform_distance (matrix, &x1, &y1);
+
+ return (x0 * x1 + y0 * y1) / (x0 * x0 + y0 * y0);
+}
+
+/**
* pango_matrix_transform_distance:
* @matrix: (nullable): a `PangoMatrix`
* @dx: (inout): in/out X component of a distance vector