summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2021-10-31 17:48:59 +0000
committerMatthias Clasen <mclasen@redhat.com>2021-10-31 17:48:59 +0000
commitd1eda3cd88e2b71558ea897f45184cd78b6035b7 (patch)
tree275cdde811a1dfad7a895f83186de80c2af6288b
parent7c710faa1edd58109c4ac1972ae5aca10f1be87f (diff)
parent04a58c3ca28732f54fe3f87aa92f61c3e40b8867 (diff)
downloadpango-d1eda3cd88e2b71558ea897f45184cd78b6035b7.tar.gz
Merge branch 'matthiasc/for-main' into 'main'
Make logical glyph extents better See merge request GNOME/pango!491
-rw-r--r--pango/pangocairo-font.c2
-rw-r--r--tests/testmisc.c39
2 files changed, 41 insertions, 0 deletions
diff --git a/pango/pangocairo-font.c b/pango/pangocairo-font.c
index 503f863b..597a320d 100644
--- a/pango/pangocairo-font.c
+++ b/pango/pangocairo-font.c
@@ -934,12 +934,14 @@ _pango_cairo_font_private_get_glyph_extents (PangoCairoFontPrivate *cf_priv,
break;
case PANGO_GRAVITY_EAST:
logical_rect->width = cf_priv->font_extents.height;
+ logical_rect->x = - logical_rect->width;
break;
case PANGO_GRAVITY_NORTH:
logical_rect->width = entry->width;
break;
case PANGO_GRAVITY_WEST:
logical_rect->width = - cf_priv->font_extents.height;
+ logical_rect->x = - logical_rect->width;
break;
case PANGO_GRAVITY_AUTO:
default:
diff --git a/tests/testmisc.c b/tests/testmisc.c
index 2e14f11e..75c40b0e 100644
--- a/tests/testmisc.c
+++ b/tests/testmisc.c
@@ -698,6 +698,44 @@ test_gravity_metrics (void)
g_object_unref (context);
}
+static void
+test_transform_rectangle (void)
+{
+ PangoMatrix matrix = PANGO_MATRIX_INIT;
+ PangoRectangle rect;
+ PangoRectangle rect2;
+
+ rect = rect2 = (PangoRectangle) { 10 * PANGO_SCALE, 20 * PANGO_SCALE, 30 * PANGO_SCALE, 40 * PANGO_SCALE };
+ pango_matrix_transform_rectangle (&matrix, &rect2);
+
+ g_assert_cmpint (rect2.x, ==, rect.x);
+ g_assert_cmpint (rect2.y, ==, rect.y);
+ g_assert_cmpint (rect2.width, ==, rect.width);
+ g_assert_cmpint (rect2.height, ==, rect.height);
+
+ matrix = (PangoMatrix) PANGO_MATRIX_INIT;
+ pango_matrix_translate (&matrix, 10, 20);
+
+ pango_matrix_transform_rectangle (&matrix, &rect2);
+
+ g_assert_cmpint (rect2.x, ==, rect.x + 10 * PANGO_SCALE);
+ g_assert_cmpint (rect2.y, ==, rect.y + 20 * PANGO_SCALE);
+ g_assert_cmpint (rect2.width, ==, rect.width);
+ g_assert_cmpint (rect2.height, ==, rect.height);
+
+ rect2 = rect;
+
+ matrix = (PangoMatrix) PANGO_MATRIX_INIT;
+ pango_matrix_rotate (&matrix, -90);
+
+ pango_matrix_transform_rectangle (&matrix, &rect2);
+
+ g_assert_cmpint (rect2.x, ==, - (rect.y + rect.height));
+ g_assert_cmpint (rect2.y, ==, rect.x);
+ g_assert_cmpint (rect2.width, ==, rect.height);
+ g_assert_cmpint (rect2.height, ==, rect.width);
+}
+
int
main (int argc, char *argv[])
{
@@ -730,6 +768,7 @@ main (int argc, char *argv[])
g_test_add_func ("/layout/extents", test_extents);
g_test_add_func ("/layout/empty-line-height", test_empty_line_height);
g_test_add_func ("/layout/gravity-metrics", test_gravity_metrics);
+ g_test_add_func ("/matrix/transform-rectangle", test_transform_rectangle);
return g_test_run ();
}