Merge branch 'cff-subset' of https://github.com/harfbuzz/harfbuzz into cff-subset

This commit is contained in:
Michiharu Ariza committed 2018-11-02 15:28:09 -07:00
commit 481fdfdc23
151 files changed
+5255 -1874

No files matched your search

+1 -1
View File
@@ -172,7 +172,7 @@ symbols-tested.txt: $(TEST_PROGS)
$(AM_V_GEN)$(top_builddir)/libtool --mode=execute nm $^ \
| grep ' U hb_' | sed 's/.* U hb_/hb_/' \
| sort | uniq > $@.tmp && mv $@.tmp $@
symbols-tested-or-deprecated.txt: symbols-tested.txt $(top_builddir)/src/harfbuzz-deprecated.def
symbols-tested-or-deprecated.txt: symbols-tested.txt $(top_builddir)/src/harfbuzz-deprecated-symbols.txt
$(AM_V_GEN)cat $^ | sort | uniq > $@.tmp; mv $@.tmp $@
symbols-exported.txt: $(top_builddir)/src/.libs/libharfbuzz.so
$(AM_V_GEN)$(top_builddir)/libtool --mode=execute nm $^ \
+106 -22
View File
@@ -28,8 +28,6 @@
#include "hb-test.h"
#include <hb-ot.h>
#include <stdlib.h>
#include <stdio.h>
/* Unit tests for hb-ot-color.h */
@@ -103,6 +101,7 @@ static hb_face_t *cpal = NULL;
static hb_face_t *cbdt = NULL;
static hb_face_t *sbix = NULL;
static hb_face_t *svg = NULL;
static hb_face_t *empty = NULL;
#define assert_color_rgba(colors, i, r, g, b, a) G_STMT_START { \
const hb_color_t *_colors = (colors); \
@@ -140,19 +139,19 @@ static void
test_hb_ot_color_palette_get_name_id_empty (void)
{
/* numPalettes=0, so all calls are for out-of-bounds palette indices */
g_assert_cmpint (hb_ot_color_palette_get_name_id (hb_face_get_empty(), 0), ==, HB_NAME_ID_INVALID);
g_assert_cmpint (hb_ot_color_palette_get_name_id (hb_face_get_empty(), 1), ==, HB_NAME_ID_INVALID);
g_assert_cmpint (hb_ot_color_palette_get_name_id (hb_face_get_empty(), 0), ==, HB_OT_NAME_ID_INVALID);
g_assert_cmpint (hb_ot_color_palette_get_name_id (hb_face_get_empty(), 1), ==, HB_OT_NAME_ID_INVALID);
}
static void
test_hb_ot_color_palette_get_name_id_v0 (void)
{
g_assert_cmpint (hb_ot_color_palette_get_name_id (cpal_v0, 0), ==, HB_NAME_ID_INVALID);
g_assert_cmpint (hb_ot_color_palette_get_name_id (cpal_v0, 1), ==, HB_NAME_ID_INVALID);
g_assert_cmpint (hb_ot_color_palette_get_name_id (cpal_v0, 0), ==, HB_OT_NAME_ID_INVALID);
g_assert_cmpint (hb_ot_color_palette_get_name_id (cpal_v0, 1), ==, HB_OT_NAME_ID_INVALID);
/* numPalettes=2, so palette #2 is out of bounds */
g_assert_cmpint (hb_ot_color_palette_get_name_id (cpal_v0, 2), ==, HB_NAME_ID_INVALID);
g_assert_cmpint (hb_ot_color_palette_get_name_id (cpal_v0, 2), ==, HB_OT_NAME_ID_INVALID);
}
@@ -160,11 +159,11 @@ static void
test_hb_ot_color_palette_get_name_id_v1 (void)
{
g_assert_cmpint (hb_ot_color_palette_get_name_id (cpal_v1, 0), ==, 257);
g_assert_cmpint (hb_ot_color_palette_get_name_id (cpal_v1, 1), ==, HB_NAME_ID_INVALID);
g_assert_cmpint (hb_ot_color_palette_get_name_id (cpal_v1, 1), ==, HB_OT_NAME_ID_INVALID);
g_assert_cmpint (hb_ot_color_palette_get_name_id (cpal_v1, 2), ==, 258);
/* numPalettes=3, so palette #3 is out of bounds */
g_assert_cmpint (hb_ot_color_palette_get_name_id (cpal_v1, 3), ==, HB_NAME_ID_INVALID);
g_assert_cmpint (hb_ot_color_palette_get_name_id (cpal_v1, 3), ==, HB_OT_NAME_ID_INVALID);
}
@@ -203,7 +202,6 @@ test_hb_ot_color_palette_get_flags_v1 (void)
static void
test_hb_ot_color_palette_get_colors_empty (void)
{
hb_face_t *empty = hb_face_get_empty ();
g_assert_cmpint (hb_ot_color_palette_get_colors (empty, 0, 0, NULL, NULL), ==, 0);
}
@@ -302,17 +300,15 @@ test_hb_ot_color_palette_get_colors_v1 (void)
static void
test_hb_ot_color_palette_color_get_name_id (void)
{
hb_face_t *empty = hb_face_get_empty ();
g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (empty, 0), ==, HB_NAME_ID_INVALID);
g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (empty, 1), ==, HB_NAME_ID_INVALID);
g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (empty, 2), ==, HB_NAME_ID_INVALID);
g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (cpal_v0, 0), ==, HB_NAME_ID_INVALID);
g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (cpal_v0, 1), ==, HB_NAME_ID_INVALID);
g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (cpal_v0, 2), ==, HB_NAME_ID_INVALID);
g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (cpal_v1, 0), ==, HB_NAME_ID_INVALID);
g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (empty, 0), ==, HB_OT_NAME_ID_INVALID);
g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (empty, 1), ==, HB_OT_NAME_ID_INVALID);
g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (empty, 2), ==, HB_OT_NAME_ID_INVALID);
g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (cpal_v0, 0), ==, HB_OT_NAME_ID_INVALID);
g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (cpal_v0, 1), ==, HB_OT_NAME_ID_INVALID);
g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (cpal_v0, 2), ==, HB_OT_NAME_ID_INVALID);
g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (cpal_v1, 0), ==, HB_OT_NAME_ID_INVALID);
g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (cpal_v1, 1), ==, 256);
g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (cpal_v1, 2), ==, HB_NAME_ID_INVALID);
g_assert_cmpuint (hb_ot_color_palette_color_get_name_id (cpal_v1, 2), ==, HB_OT_NAME_ID_INVALID);
}
@@ -349,8 +345,6 @@ test_hb_ot_color_glyph_get_layers (void)
static void
test_hb_ot_color_has_data (void)
{
hb_face_t *empty = hb_face_get_empty ();
g_assert (hb_ot_color_has_layers (empty) == FALSE);
g_assert (hb_ot_color_has_layers (cpal_v0) == TRUE);
g_assert (hb_ot_color_has_layers (cpal_v1) == TRUE);
@@ -366,6 +360,93 @@ test_hb_ot_color_has_data (void)
g_assert (hb_ot_color_has_palettes (cbdt) == FALSE);
g_assert (hb_ot_color_has_palettes (sbix) == FALSE);
g_assert (hb_ot_color_has_palettes (svg) == FALSE);
g_assert (hb_ot_color_has_svg (empty) == FALSE);
g_assert (hb_ot_color_has_svg (cpal_v0) == FALSE);
g_assert (hb_ot_color_has_svg (cpal_v1) == FALSE);
g_assert (hb_ot_color_has_svg (cpal) == FALSE);
g_assert (hb_ot_color_has_svg (cbdt) == FALSE);
g_assert (hb_ot_color_has_svg (sbix) == FALSE);
g_assert (hb_ot_color_has_svg (svg) == TRUE);
g_assert (hb_ot_color_has_png (empty) == FALSE);
g_assert (hb_ot_color_has_png (cpal_v0) == FALSE);
g_assert (hb_ot_color_has_png (cpal_v1) == FALSE);
g_assert (hb_ot_color_has_png (cpal) == FALSE);
g_assert (hb_ot_color_has_png (cbdt) == TRUE);
g_assert (hb_ot_color_has_png (sbix) == TRUE);
g_assert (hb_ot_color_has_png (svg) == FALSE);
}
static void
test_hb_ot_color_svg (void)
{
hb_blob_t *blob;
blob = hb_ot_color_glyph_reference_svg (svg, 0);
g_assert (hb_blob_get_length (blob) == 0);
blob = hb_ot_color_glyph_reference_svg (svg, 1);
unsigned int length;
const char *data = hb_blob_get_data (blob, &length);
g_assert_cmpuint (length, ==, 146);
g_assert (strncmp (data, "<?xml", 4) == 0);
g_assert (strncmp (data + 140, "</svg>", 5) == 0);
hb_blob_destroy (blob);
blob = hb_ot_color_glyph_reference_svg (empty, 0);
g_assert (hb_blob_get_length (blob) == 0);
}
static void
test_hb_ot_color_png (void)
{
hb_blob_t *blob;
unsigned int length;
const char *data;
hb_glyph_extents_t extents;
/* sbix */
hb_font_t *sbix_font;
sbix_font = hb_font_create (sbix);
blob = hb_ot_color_glyph_reference_png (sbix_font, 0);
hb_font_get_glyph_extents (sbix_font, 0, &extents);
g_assert_cmpint (extents.x_bearing, ==, 0);
g_assert_cmpint (extents.y_bearing, ==, 0);
g_assert_cmpint (extents.width, ==, 0);
g_assert_cmpint (extents.height, ==, 0);
g_assert (hb_blob_get_length (blob) == 0);
blob = hb_ot_color_glyph_reference_png (sbix_font, 1);
data = hb_blob_get_data (blob, &length);
g_assert_cmpuint (length, ==, 224);
g_assert (strncmp (data + 1, "PNG", 3) == 0);
hb_font_get_glyph_extents (sbix_font, 1, &extents);
g_assert_cmpint (extents.x_bearing, ==, 0);
g_assert_cmpint (extents.y_bearing, ==, 0);
g_assert_cmpint (extents.width, ==, 800);
g_assert_cmpint (extents.height, ==, 800);
hb_blob_destroy (blob);
hb_font_destroy (sbix_font);
/* cbdt */
hb_font_t *cbdt_font;
cbdt_font = hb_font_create (cbdt);
blob = hb_ot_color_glyph_reference_png (cbdt_font, 0);
g_assert (hb_blob_get_length (blob) == 0);
blob = hb_ot_color_glyph_reference_png (cbdt_font, 1);
data = hb_blob_get_data (blob, &length);
g_assert_cmpuint (length, ==, 88);
g_assert (strncmp (data + 1, "PNG", 3) == 0);
hb_font_get_glyph_extents (cbdt_font, 1, &extents);
g_assert_cmpint (extents.x_bearing, ==, 0);
g_assert_cmpint (extents.y_bearing, ==, 1024);
g_assert_cmpint (extents.width, ==, 1024);
g_assert_cmpint (extents.height, ==, -1024);
hb_blob_destroy (blob);
hb_font_destroy (cbdt_font);
}
int
@@ -380,6 +461,7 @@ main (int argc, char **argv)
cbdt = hb_test_open_font_file ("fonts/chromacheck-cbdt.ttf");
sbix = hb_test_open_font_file ("fonts/chromacheck-sbix.ttf");
svg = hb_test_open_font_file ("fonts/chromacheck-svg.ttf");
empty = hb_face_get_empty ();
hb_test_add (test_hb_ot_color_palette_get_count);
hb_test_add (test_hb_ot_color_palette_get_name_id_empty);
hb_test_add (test_hb_ot_color_palette_get_name_id_v0);
@@ -393,6 +475,8 @@ main (int argc, char **argv)
hb_test_add (test_hb_ot_color_palette_color_get_name_id);
hb_test_add (test_hb_ot_color_glyph_get_layers);
hb_test_add (test_hb_ot_color_has_data);
hb_test_add (test_hb_ot_color_png);
hb_test_add (test_hb_ot_color_svg);
status = hb_test_run();
hb_face_destroy (cpal_v0);
hb_face_destroy (cpal_v1);
+4 -4
View File
@@ -41,11 +41,11 @@ test_ot_layout_feature_get_name_ids_and_characters (void)
&feature_index))
g_error ("Failed to find feature index");
hb_name_id_t label_id;
hb_name_id_t tooltip_id;
hb_name_id_t sample_id;
hb_ot_name_id_t label_id;
hb_ot_name_id_t tooltip_id;
hb_ot_name_id_t sample_id;
unsigned int num_named_parameters;
hb_name_id_t first_param_id;
hb_ot_name_id_t first_param_id;
if (!hb_ot_layout_feature_get_name_ids (face, HB_OT_TAG_GSUB, feature_index,
&label_id, &tooltip_id, &sample_id,
&num_named_parameters, &first_param_id))
+3 -3
View File
@@ -60,7 +60,7 @@ test_script_tags_from_language (const char *s, const char *lang_s, hb_script_t s
{
hb_script_t tag;
unsigned int count = 1;
hb_script_t t;
hb_tag_t t;
g_test_message ("Testing script %c%c%c%c: script tag %s, language tag %s", HB_UNTAG (hb_script_to_iso15924_tag (script)), s, lang_s);
tag = hb_tag_from_string (s, -1);
@@ -78,7 +78,7 @@ static void
test_indic_tags (const char *s1, const char *s2, const char *s3, hb_script_t script)
{
hb_script_t tag1, tag2, tag3;
hb_script_t t[3];
hb_tag_t t[3];
unsigned int count = 3;
g_test_message ("Testing script %c%c%c%c: USE tag %s, new tag %s, old tag %s", HB_UNTAG (hb_script_to_iso15924_tag (script)), s1, s2, s3);
@@ -103,7 +103,7 @@ test_indic_tags (const char *s1, const char *s2, const char *s3, hb_script_t scr
static void
test_ot_tag_script_degenerate (void)
{
hb_script_t t[2];
hb_tag_t t[2];
unsigned int count = 2;
g_assert_cmphex (HB_TAG_CHAR4 ("DFLT"), ==, HB_OT_TAG_DEFAULT_SCRIPT);