[pango/glyph-extents: 2/2] Add a test for extents
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/glyph-extents: 2/2] Add a test for extents
- Date: Tue, 13 Aug 2019 03:45:58 +0000 (UTC)
commit 090120b42847373d6cdd2198c6195b95e56c802f
Author: Matthias Clasen <mclasen redhat com>
Date: Mon Aug 12 23:45:05 2019 -0400
Add a test for extents
We want to make sure that the ink rectangles
we return have positive size.
tests/test-font.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
---
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 ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]