Imported Upstream version 3.4.0
[platform/upstream/harfbuzz.git] / test / api / test-ot-face.c
index 0e86123..e5c9b86 100644 (file)
 
 /* Unit tests for hb-ot-*.h */
 
-
-static void
+/* Return some dummy result so that compiler won't just optimize things */
+static long long
 test_font (hb_font_t *font, hb_codepoint_t cp)
 {
+  long long result = 0;
+
   hb_face_t *face = hb_font_get_face (font);
   hb_set_t *set;
-  hb_codepoint_t g;
-  hb_position_t x, y;
+  hb_codepoint_t g = 0;
+  hb_position_t x = 0, y = 0;
   char buf[5] = {0};
-  unsigned int len;
-  hb_glyph_extents_t extents;
+  unsigned int len = 0;
+  hb_glyph_extents_t extents = {0};
   hb_ot_font_set_funcs (font);
 
   set = hb_set_create ();
@@ -74,27 +76,24 @@ test_font (hb_font_t *font, hb_codepoint_t cp)
   hb_ot_color_has_png (face);
   hb_blob_destroy (hb_ot_color_glyph_reference_png (font, cp));
 
-  hb_aat_layout_feature_type_t feature;
-  unsigned count = 1;
-  hb_aat_layout_get_feature_types (face, 0, &count, &feature);
-  hb_aat_layout_feature_type_get_name_id (face, HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE);
-  hb_aat_layout_feature_selector_info_t setting = {0};
-  unsigned default_index;
-  count = 1;
-  hb_aat_layout_feature_type_get_selector_infos (face, HB_AAT_LAYOUT_FEATURE_TYPE_DESIGN_COMPLEXITY_TYPE, 0, &count, &setting, &default_index);
+  {
+    hb_aat_layout_feature_type_t feature = HB_AAT_LAYOUT_FEATURE_TYPE_ALL_TYPOGRAPHIC;
+    unsigned count = 1;
+    hb_aat_layout_get_feature_types (face, 0, &count, &feature);
+    hb_aat_layout_feature_type_get_name_id (face, HB_AAT_LAYOUT_FEATURE_TYPE_CHARACTER_SHAPE);
+    hb_aat_layout_feature_selector_info_t setting = {0};
+    unsigned default_index;
+    count = 1;
+    hb_aat_layout_feature_type_get_selector_infos (face, HB_AAT_LAYOUT_FEATURE_TYPE_DESIGN_COMPLEXITY_TYPE, 0, &count, &setting, &default_index);
+    result += count + feature + setting.disable + setting.disable + setting.name_id + setting.reserved + default_index;
+  }
 
   hb_set_t *lookup_indexes = hb_set_create ();
   hb_set_add (lookup_indexes, 0);
-#ifdef HB_EXPERIMENTAL_API
-  hb_ot_layout_closure_lookups (face, HB_OT_TAG_GSUB, set, lookup_indexes);
-#endif
 
   hb_map_t *lookup_mapping = hb_map_create ();
   hb_map_set (lookup_mapping, 0, 0);
   hb_set_t *feature_indices = hb_set_create ();
-#ifdef HB_EXPERIMENTAL_API
-  hb_ot_layout_closure_features (face, HB_OT_TAG_GSUB, lookup_mapping, feature_indices);
-#endif
   hb_set_destroy (lookup_indexes);
   hb_set_destroy (feature_indices);
   hb_map_destroy (lookup_mapping);
@@ -107,12 +106,32 @@ test_font (hb_font_t *font, hb_codepoint_t cp)
 
   hb_ot_layout_get_ligature_carets (font, HB_DIRECTION_LTR, cp, 0, NULL, NULL);
 
+  {
+    unsigned temp = 0, temp2 = 0;
+    hb_ot_name_id_t name = HB_OT_NAME_ID_FULL_NAME;
+    hb_ot_layout_get_size_params (face, &temp, &temp, &name, &temp, &temp);
+    hb_tag_t cv01 = HB_TAG ('c','v','0','1');
+    unsigned feature_index = 0;
+    hb_ot_layout_language_find_feature (face, HB_OT_TAG_GSUB, 0,
+                                       HB_OT_LAYOUT_DEFAULT_LANGUAGE_INDEX,
+                                       cv01, &feature_index);
+    hb_ot_layout_feature_get_name_ids (face, HB_OT_TAG_GSUB, feature_index,
+                                      &name, &name, &name, &temp, &name);
+    temp = 1;
+    hb_ot_layout_feature_get_characters (face, HB_OT_TAG_GSUB, feature_index, 0, &temp, &g);
+    temp = 1;
+    hb_ot_layout_language_get_feature_indexes (face, HB_OT_TAG_GSUB, 0, 0, 0, &temp, &temp2);
+
+    result += temp + name + feature_index + temp2;
+  }
+
   hb_ot_math_has_data (face);
   hb_ot_math_get_constant (font, HB_OT_MATH_CONSTANT_MATH_LEADING);
   hb_ot_math_get_glyph_italics_correction (font, cp);
   hb_ot_math_get_glyph_top_accent_attachment (font, cp);
   hb_ot_math_is_glyph_extended_shape (face, cp);
   hb_ot_math_get_glyph_kerning (font, cp, HB_OT_MATH_KERN_BOTTOM_RIGHT, 0);
+  hb_ot_math_get_glyph_kernings (font, cp, HB_OT_MATH_KERN_BOTTOM_RIGHT, 0, NULL, NULL);
   hb_ot_math_get_glyph_variants (font, cp, HB_DIRECTION_TTB, 0, NULL, NULL);
   hb_ot_math_get_min_connector_overlap (font, HB_DIRECTION_RTL);
   hb_ot_math_get_glyph_assembly (font, cp, HB_DIRECTION_BTT, 0, NULL, NULL, NULL);
@@ -131,6 +150,14 @@ test_font (hb_font_t *font, hb_codepoint_t cp)
   hb_ot_name_get_utf16 (face, cp, NULL, NULL, NULL);
   hb_ot_name_get_utf32 (face, cp, NULL, NULL, NULL);
 
+#if 0
+  hb_style_get_value (font, HB_STYLE_TAG_ITALIC);
+  hb_style_get_value (font, HB_STYLE_TAG_OPTICAL_SIZE);
+  hb_style_get_value (font, HB_STYLE_TAG_SLANT);
+  hb_style_get_value (font, HB_STYLE_TAG_WIDTH);
+  hb_style_get_value (font, HB_STYLE_TAG_WEIGHT);
+#endif
+
   hb_ot_var_get_axis_count (face);
   hb_ot_var_get_axis_infos (face, 0, NULL, NULL);
   hb_ot_var_normalize_variations (face, NULL, 0, NULL, 0);
@@ -143,6 +170,9 @@ test_font (hb_font_t *font, hb_codepoint_t cp)
 #endif
 
   hb_set_destroy (set);
+
+  return result + g + x + y + buf[0] + buf[1] + buf[2] + buf[3] + buf[4] + len +
+        extents.height + extents.width + extents.x_bearing + extents.y_bearing;
 }
 
 #ifndef TEST_OT_FACE_NO_MAIN