diff options
author | Matthias Clasen <mclasen@redhat.com> | 2019-08-12 23:45:05 -0400 |
---|---|---|
committer | Matthias Clasen <mclasen@redhat.com> | 2019-08-12 23:45:05 -0400 |
commit | 090120b42847373d6cdd2198c6195b95e56c802f (patch) | |
tree | 159185cbefabc29fba95a814c7cde1923c88f46c /tests | |
parent | 2ce058cdadb320f97b424f5db6b34d0565951578 (diff) | |
download | pango-090120b42847373d6cdd2198c6195b95e56c802f.tar.gz |
Add a test for extents
We want to make sure that the ink rectangles
we return have positive size.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/test-font.c | 30 |
1 files changed, 30 insertions, 0 deletions
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 (); } |