[pango/baseline-shift] Add a font scaling test



commit b23f334c37b4986b18ced94e3bde1ba85b65db2a
Author: Matthias Clasen <mclasen redhat com>
Date:   Mon Aug 30 17:48:00 2021 -0400

    Add a font scaling test
    
    This tests the behavior we rely on for super- and
    subscripts.

 tests/test-font.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)
---
diff --git a/tests/test-font.c b/tests/test-font.c
index 1d3290c7..05af6526 100644
--- a/tests/test-font.c
+++ b/tests/test-font.c
@@ -460,6 +460,35 @@ test_match (void)
   pango_font_description_free (desc2);
 }
 
+/* This is how we scale fonts for super- and subscripts.
+ * Test that it works.
+ */
+static void
+test_font_scale (void)
+{
+  PangoFontMap *fontmap;
+  PangoContext *context;
+  PangoFontDescription *desc, *desc2;
+  PangoFont *font;
+
+  fontmap = pango_cairo_font_map_get_default ();
+  context = pango_font_map_create_context (fontmap);
+
+  desc = pango_font_description_from_string ("Sans 11");
+
+  font = pango_context_load_font (context, desc);
+  desc2 = pango_font_describe (font);
+
+  pango_font_description_set_size (desc2, 2 * pango_font_description_get_size (desc2));
+
+  g_assert_cmpint (pango_font_description_get_size (desc2)/PANGO_SCALE, ==, 22);
+
+  pango_font_description_free (desc2);
+  g_object_unref (font);
+  pango_font_description_free (desc);
+  g_object_unref (context);
+}
+
 int
 main (int argc, char *argv[])
 {
@@ -483,6 +512,7 @@ main (int argc, char *argv[])
   g_test_add_func ("/pango/font/models", test_font_models);
   g_test_add_func ("/pango/font/glyph-extents", test_glyph_extents);
   g_test_add_func ("/pango/font/font-metrics", test_font_metrics);
+  g_test_add_func ("/pango/font/font-scale", test_font_scale);
 
   return g_test_run ();
 }


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