2.0_alpha
[apps/home/video-player.git] / test / test-shape.c
index ab3ddf1..5a41f0c 100644 (file)
 
 /* Unit tests for hb-shape.h */
 
+/*
+ * This test provides a framework to test aspects of hb_shape() that are
+ * font-independent.  Please add tests for any feature that fits that
+ * description.
+ */
+
+/* TODO Make this test data-driven and add some real test data */
+/* TODO Test positions too. And test non-native direction.  Test commit 2e18c6dbdfb */
+
 
 static const char test_data[] = "test\0data";
 
-static void
-glyph_advance_func (hb_font_t *font, void *font_data,
-                   hb_codepoint_t glyph,
-                   hb_position_t *x_advance, hb_position_t *y_advance,
-                   void *user_data)
+static hb_position_t
+glyph_h_advance_func (hb_font_t *font, void *font_data,
+                     hb_codepoint_t glyph,
+                     void *user_data)
 {
   switch (glyph) {
-  case 1: *x_advance = 10; return;
-  case 2: *x_advance =  6; return;
-  case 3: *x_advance =  5; return;
+  case 1: return 10;
+  case 2: return 6;
+  case 3: return 5;
   }
+  return 0;
 }
 
 static hb_bool_t
@@ -55,19 +64,18 @@ glyph_func (hb_font_t *font, void *font_data,
   case 'e': *glyph = 2; return TRUE;
   case 's': *glyph = 3; return TRUE;
   }
-
   return FALSE;
 }
 
-static void
-kerning_func (hb_font_t *font, void *font_data,
-                   hb_codepoint_t left, hb_codepoint_t right,
-                   hb_position_t *x_kern, hb_position_t *y_kern,
-                   void *user_data)
+static hb_position_t
+glyph_h_kerning_func (hb_font_t *font, void *font_data,
+                     hb_codepoint_t left, hb_codepoint_t right,
+                     void *user_data)
 {
-  if (left == 1 && right == 2) {
-    *x_kern = -2;
-  }
+  if (left == 1 && right == 2)
+    return -2;
+
+  return 0;
 }
 
 static const char TesT[] = "TesT";
@@ -92,9 +100,9 @@ test_shape (void)
   hb_font_set_scale (font, 10, 10);
 
   ffuncs = hb_font_funcs_create ();
-  hb_font_funcs_set_glyph_advance_func (ffuncs, glyph_advance_func, NULL, NULL);
+  hb_font_funcs_set_glyph_h_advance_func (ffuncs, glyph_h_advance_func, NULL, NULL);
   hb_font_funcs_set_glyph_func (ffuncs, glyph_func, NULL, NULL);
-  hb_font_funcs_set_kerning_func (ffuncs, kerning_func, NULL, NULL);
+  hb_font_funcs_set_glyph_h_kerning_func (ffuncs, glyph_h_kerning_func, NULL, NULL);
   hb_font_set_funcs (font, ffuncs, NULL, NULL);
   hb_font_funcs_destroy (ffuncs);