Imported Upstream version 2.3.1
[platform/upstream/harfbuzz.git] / test / api / hb-test.h
index 307845f..872f45c 100644 (file)
@@ -42,6 +42,7 @@ HB_BEGIN_DECLS
 /* Just in case */
 #undef G_DISABLE_ASSERT
 
+#define HB_UNUSED      G_GNUC_UNUSED
 
 /* Misc */
 
@@ -276,6 +277,28 @@ G_STMT_START { \
 } G_STMT_END
 
 
+static inline hb_face_t *
+hb_test_open_font_file (const char *font_path)
+{
+#if GLIB_CHECK_VERSION(2,37,2)
+  char *path = g_test_build_filename (G_TEST_DIST, font_path, NULL);
+#else
+  char *path = g_strdup (font_path);
+#endif
+
+  hb_blob_t *blob = hb_blob_create_from_file (path);
+  hb_face_t *face;
+  if (hb_blob_get_length (blob) == 0)
+    g_error ("Font %s not found.", path);
+
+  face = hb_face_create (blob, 0);
+  hb_blob_destroy (blob);
+
+  g_free (path);
+
+  return face;
+}
+
 HB_END_DECLS
 
 #endif /* HB_TEST_H */