[pango/simple-fontmap: 3/9] Add a test for PangoHbFont glyph extents
- From: Matthias Clasen <matthiasc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [pango/simple-fontmap: 3/9] Add a test for PangoHbFont glyph extents
- Date: Mon, 1 Nov 2021 00:26:58 +0000 (UTC)
commit 970efe7a2cdb193de80bb20f4fe1322207ba89ed
Author: Matthias Clasen <mclasen redhat com>
Date: Sat Oct 30 23:14:25 2021 -0400
Add a test for PangoHbFont glyph extents
tests/testmisc.c | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 48 insertions(+)
---
diff --git a/tests/testmisc.c b/tests/testmisc.c
index a8f14445..10205232 100644
--- a/tests/testmisc.c
+++ b/tests/testmisc.c
@@ -698,6 +698,53 @@ 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);
+
+ /* Seems that harfbuzz has some off-by-one differences in advance width
+ * when fonts differ by a scale of -1.
+ */
+ g_assert_cmpint (log[PANGO_GRAVITY_SOUTH].width + log[PANGO_GRAVITY_NORTH].width, <=, 1);
+ 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)
{
@@ -800,6 +847,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);
g_test_add_func ("/hbfont/monospace", test_hbfont_monospace);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]