changeset 423:3ba48126c49c

Check bearing and advance of text_extents.
author Thinker K.F. Li <thinker@branda.to>
date Tue, 28 Jul 2009 15:11:42 +0800
parents c6c0d017dc8e
children 585baa462778
files src/shape_stext.c
diffstat 1 files changed, 18 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/shape_stext.c	Tue Jul 28 15:11:42 2009 +0800
+++ b/src/shape_stext.c	Tue Jul 28 15:11:42 2009 +0800
@@ -597,6 +597,8 @@
 static
 void test_compute_text_extents(void) {
     co_aix matrix[6] = {10, 0, 0, 0, 10, 0};
+    co_aix x_adv1, x_adv2;
+    co_aix x_bearing1, x_bearing2;
     mb_font_face_t *face;
     mb_scaled_font_t *scaled;
     mb_text_extents_t ext;
@@ -609,8 +611,24 @@
     compute_text_extents(scaled, "test", &ext);
     CU_ASSERT(MBE_GET_HEIGHT(&ext) >= 5 && MBE_GET_HEIGHT(&ext) <= 12);
     CU_ASSERT(MBE_GET_WIDTH(&ext) >= 16 && MBE_GET_WIDTH(&ext) <= 48);
+    x_adv1 = MBE_GET_X_ADV(&ext);
+    x_bearing1 = MBE_GET_X_BEARING(&ext);
+    scaled_font_free(scaled);
 
+    matrix[2] = 5;
+    scaled = make_scaled_font_face_matrix(face, matrix);
+    CU_ASSERT(scaled != NULL);
+
+    compute_text_extents(scaled, "test", &ext);
+    CU_ASSERT(MBE_GET_HEIGHT(&ext) >= 5 && MBE_GET_HEIGHT(&ext) <= 12);
+    CU_ASSERT(MBE_GET_WIDTH(&ext) >= 16 && MBE_GET_WIDTH(&ext) <= 48);
+    x_adv2 = MBE_GET_X_ADV(&ext);
+    x_bearing2 = MBE_GET_X_BEARING(&ext);
     scaled_font_free(scaled);
+
+    CU_ASSERT(x_adv1 == x_adv2);
+    CU_ASSERT((x_bearing1 + 5) == x_bearing2);
+
     free_font_face(face);
 }