[pango/simple-fontmap: 16/18] testspew




commit 76ab380055de3a0df403af5a196f9443894ca6e0
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Oct 26 23:44:51 2021 -0400

    testspew

 tests/testmisc.c | 43 +++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 43 insertions(+)
---
diff --git a/tests/testmisc.c b/tests/testmisc.c
index 85a3b0b5..97992e95 100644
--- a/tests/testmisc.c
+++ b/tests/testmisc.c
@@ -661,6 +661,48 @@ test_empty_line_height (void)
   g_object_unref (context);
 }
 
+static void
+test_gravity_metrics (void)
+{
+  PangoContext *context;
+  PangoGravity gravity;
+  PangoFontDescription *desc;
+  PangoFont *font;
+  PangoFontMetrics *metrics;
+
+  context = pango_font_map_create_context (pango_cairo_font_map_get_default ());
+
+  desc = pango_font_description_from_string ("Cantarell 64");
+
+  for (gravity = PANGO_GRAVITY_SOUTH; gravity <= PANGO_GRAVITY_WEST; gravity++)
+    {
+      PangoRectangle ink, log;
+
+      pango_font_description_set_gravity (desc, gravity);
+
+      font = pango_context_load_font (context, desc);
+
+      pango_font_get_glyph_extents (font, 1, &ink, &log);
+
+      g_print ("gravity %d: ink % 6.2f % 6.2f % 6.2f % 6.2f logical % 6.2f % 6.2f % 6.2f % 6.2f\n",
+               gravity,
+               ink.x / (double)PANGO_SCALE,
+               ink.y / (double)PANGO_SCALE,
+               ink.width / (double)PANGO_SCALE,
+               ink.height / (double)PANGO_SCALE,
+               log.x / (double)PANGO_SCALE,
+               log.y / (double)PANGO_SCALE,
+               log.width / (double)PANGO_SCALE,
+               log.height / (double)PANGO_SCALE);
+
+      pango_font_metrics_unref (metrics);
+
+      g_object_unref (font);
+    }
+
+  g_object_unref (context);
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -692,6 +734,7 @@ main (int argc, char *argv[])
   g_test_add_func ("/layout/index-to-x", test_index_to_x);
   g_test_add_func ("/layout/extents", test_extents);
   g_test_add_func ("/layout/empty-line-height", test_empty_line_height);
+  g_test_add_func ("/misc/gravity-metrics", test_gravity_metrics);
 
   return g_test_run ();
 }


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]