2.0_alpha
[apps/home/video-player.git] / test / test-shape.c
index 531f721..5a41f0c 100644 (file)
  * 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 hb_bool_t
-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 TRUE;
-  case 2: *x_advance =  6; return TRUE;
-  case 3: *x_advance =  5; return TRUE;
+  case 1: return 10;
+  case 2: return 6;
+  case 3: return 5;
   }
-  return FALSE;
+  return 0;
 }
 
 static hb_bool_t
@@ -62,21 +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 hb_bool_t
-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;
-    return TRUE;
-  }
-  return FALSE;
+  if (left == 1 && right == 2)
+    return -2;
+
+  return 0;
 }
 
 static const char TesT[] = "TesT";
@@ -101,9 +100,9 @@ test_shape (void)
   hb_font_set_scale (font, 10, 10);
 
   ffuncs = hb_font_funcs_create ();
-  hb_font_funcs_set_glyph_h_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_h_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);