summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Clasen <mclasen@redhat.com>2019-08-13 03:50:22 +0000
committerMatthias Clasen <mclasen@redhat.com>2019-08-13 03:50:22 +0000
commit0f44a2b18d29022a5de9613feaf8cce4c6795aa3 (patch)
tree159185cbefabc29fba95a814c7cde1923c88f46c
parent8b82959e0ea68e4b8421cd2ee99cb8c725f31fc0 (diff)
parent090120b42847373d6cdd2198c6195b95e56c802f (diff)
downloadpango-0f44a2b18d29022a5de9613feaf8cce4c6795aa3.tar.gz
Merge branch 'glyph-extents' into 'master'
Fix glyph extents Closes #406 See merge request GNOME/pango!134
-rw-r--r--pango/pangofc-font.c2
-rw-r--r--tests/test-font.c30
2 files changed, 31 insertions, 1 deletions
diff --git a/pango/pangofc-font.c b/pango/pangofc-font.c
index 21644b57..72b9931d 100644
--- a/pango/pangofc-font.c
+++ b/pango/pangofc-font.c
@@ -810,7 +810,7 @@ pango_fc_font_get_raw_extents (PangoFcFont *fcfont,
ink_rect->x = extents.x_bearing;
ink_rect->width = extents.width;
ink_rect->y = -extents.y_bearing;
- ink_rect->height = extents.height;
+ ink_rect->height = -extents.height;
}
if (logical_rect)
diff --git a/tests/test-font.c b/tests/test-font.c
index cea7356c..6b8f45be 100644
--- a/tests/test-font.c
+++ b/tests/test-font.c
@@ -159,6 +159,35 @@ test_metrics (void)
pango_font_description_free (desc);
}
+static void
+test_extents (void)
+{
+ char *str = "Composer";
+ GList *items;
+ PangoItem *item;
+ PangoGlyphString *glyphs;
+ PangoRectangle ink, log;
+ PangoContext *context;
+
+ context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+ pango_context_set_font_description (context, pango_font_description_from_string ("Cantarell 11"));
+
+ items = pango_itemize (context, str, 0, strlen (str), NULL, NULL);
+ glyphs = pango_glyph_string_new ();
+ item = items->data;
+ pango_shape (str, strlen (str), &item->analysis, glyphs);
+ pango_glyph_string_extents (glyphs, item->analysis.font, &ink, &log);
+
+ g_assert_cmpint (ink.width, >=, 0);
+ g_assert_cmpint (ink.height, >=, 0);
+ g_assert_cmpint (log.width, >=, 0);
+ g_assert_cmpint (log.height, >=, 0);
+
+ pango_glyph_string_free (glyphs);
+ g_list_free_full (items, (GDestroyNotify)pango_item_free);
+ g_object_unref (context);
+}
+
int
main (int argc, char *argv[])
{
@@ -173,6 +202,7 @@ main (int argc, char *argv[])
g_test_add_func ("/pango/fontdescription/parse", test_parse);
g_test_add_func ("/pango/fontdescription/roundtrip", test_roundtrip);
g_test_add_func ("/pango/fontdescription/variation", test_variation);
+ g_test_add_func ("/pango/font/extents", test_extents);
return g_test_run ();
}