[pango/simple-fontmap: 23/23] Add metrics tests for PangoHbFont




commit ce9e93a81106821a3e52ed23a8f1793773846b77
Author: Matthias Clasen <mclasen redhat com>
Date:   Sat Oct 30 23:14:25 2021 -0400

    Add metrics tests for PangoHbFont

 tests/testmisc.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 45 insertions(+)
---
diff --git a/tests/testmisc.c b/tests/testmisc.c
index 75c40b0e..30ea1f7f 100644
--- a/tests/testmisc.c
+++ b/tests/testmisc.c
@@ -698,6 +698,50 @@ test_gravity_metrics (void)
   g_object_unref (context);
 }
 
+static void
+test_gravity_metrics2 (void)
+{
+  PangoSimpleFontMap *map;
+  PangoContext *context;
+  PangoFontDescription *desc;
+  PangoFont *font;
+  PangoGlyph glyph;
+  PangoGravity gravity;
+  PangoRectangle ink[4];
+  PangoRectangle log[4];
+
+  map = pango_simple_font_map_new ();
+  pango_simple_font_map_add_file (map, "/usr/share/fonts/cantarell/Cantarell-VF.otf", 0);
+
+  context = pango_font_map_create_context (PANGO_FONT_MAP (map));
+
+  desc = pango_font_description_from_string ("Cantarell 64");
+
+  glyph = 1; /* A */
+
+  for (gravity = PANGO_GRAVITY_SOUTH; gravity <= PANGO_GRAVITY_WEST; gravity++)
+    {
+      pango_font_description_set_gravity (desc, gravity);
+      font = pango_font_map_load_font (PANGO_FONT_MAP (map), context, desc);
+      pango_font_get_glyph_extents (font, glyph, &ink[gravity], &log[gravity]);
+      g_object_unref (font);
+    }
+
+  g_assert_cmpint (ink[PANGO_GRAVITY_EAST].width, ==, ink[PANGO_GRAVITY_SOUTH].height);
+  g_assert_cmpint (ink[PANGO_GRAVITY_EAST].height, ==, ink[PANGO_GRAVITY_SOUTH].width);
+  g_assert_cmpint (ink[PANGO_GRAVITY_NORTH].width, ==, ink[PANGO_GRAVITY_SOUTH].width);
+  g_assert_cmpint (ink[PANGO_GRAVITY_NORTH].height, ==, ink[PANGO_GRAVITY_SOUTH].height);
+  g_assert_cmpint (ink[PANGO_GRAVITY_WEST].width, ==, ink[PANGO_GRAVITY_SOUTH].height);
+  g_assert_cmpint (ink[PANGO_GRAVITY_WEST].height, ==, ink[PANGO_GRAVITY_SOUTH].width);
+
+  g_assert_cmpint (log[PANGO_GRAVITY_SOUTH].width, ==, - log[PANGO_GRAVITY_NORTH].width);
+  g_assert_cmpint (log[PANGO_GRAVITY_EAST].width, ==, - log[PANGO_GRAVITY_WEST].width);
+
+  pango_font_description_free (desc);
+  g_object_unref (context);
+  g_object_unref (map);
+}
+
 static void
 test_transform_rectangle (void)
 {
@@ -768,6 +812,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 ("/layout/gravity-metrics2", test_gravity_metrics2);
   g_test_add_func ("/matrix/transform-rectangle", test_transform_rectangle);
 
   return g_test_run ();


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