test/api: Fix building subset tests
Include stdbool.h in hb-setset-test.h instead of in the individual sources, if it is found; otherwise use a simplistic fallback for it if it is not found. Also declare variables at the top of the block, to build on pre-C99 compiliers.
This commit is contained in:
parent
eda6a5ea80
commit
831d4a2dab
@ -32,6 +32,18 @@
|
||||
#include "hb-test.h"
|
||||
#include "hb-subset.h"
|
||||
|
||||
#ifdef HAVE_STDBOOL_H
|
||||
# include <stdbool.h>
|
||||
#else
|
||||
typedef short bool;
|
||||
# ifndef true
|
||||
# define true 1
|
||||
# endif
|
||||
# ifndef false
|
||||
# define false 0
|
||||
# endif
|
||||
#endif
|
||||
|
||||
|
||||
HB_BEGIN_DECLS
|
||||
|
||||
@ -122,9 +134,10 @@ hb_subset_test_check (hb_face_t *expected,
|
||||
hb_face_t *actual,
|
||||
hb_tag_t table)
|
||||
{
|
||||
hb_blob_t *expected_blob, *actual_blob;
|
||||
fprintf(stderr, "compare %c%c%c%c\n", HB_UNTAG(table));
|
||||
hb_blob_t *expected_blob = hb_face_reference_table (expected, table);
|
||||
hb_blob_t *actual_blob = hb_face_reference_table (actual, table);
|
||||
expected_blob = hb_face_reference_table (expected, table);
|
||||
actual_blob = hb_face_reference_table (actual, table);
|
||||
hb_test_assert_blobs_equal (expected_blob, actual_blob);
|
||||
hb_blob_destroy (expected_blob);
|
||||
hb_blob_destroy (actual_blob);
|
||||
|
@ -24,8 +24,6 @@
|
||||
* Google Author(s): Roderick Sheeter
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "hb-test.h"
|
||||
#include "hb-subset-test.h"
|
||||
|
||||
@ -38,9 +36,10 @@ test_subset_cmap (void)
|
||||
hb_face_t *face_ac = hb_subset_test_open_font ("fonts/Roboto-Regular.ac.cmap-format12-only.ttf");
|
||||
|
||||
hb_set_t *codepoints = hb_set_create ();
|
||||
hb_face_t *face_abc_subset;
|
||||
hb_set_add (codepoints, 97);
|
||||
hb_set_add (codepoints, 99);
|
||||
hb_face_t *face_abc_subset = hb_subset_test_create_subset (face_abc, hb_subset_test_create_input (codepoints));
|
||||
face_abc_subset = hb_subset_test_create_subset (face_abc, hb_subset_test_create_input (codepoints));
|
||||
hb_set_destroy (codepoints);
|
||||
|
||||
hb_subset_test_check (face_ac, face_abc_subset, HB_TAG ('c','m','a','p'));
|
||||
@ -56,10 +55,11 @@ test_subset_cmap_noop (void)
|
||||
hb_face_t *face_abc = hb_subset_test_open_font("fonts/Roboto-Regular.abc.cmap-format12-only.ttf");
|
||||
|
||||
hb_set_t *codepoints = hb_set_create();
|
||||
hb_face_t *face_abc_subset;
|
||||
hb_set_add (codepoints, 97);
|
||||
hb_set_add (codepoints, 98);
|
||||
hb_set_add (codepoints, 99);
|
||||
hb_face_t *face_abc_subset = hb_subset_test_create_subset (face_abc, hb_subset_test_create_input (codepoints));
|
||||
face_abc_subset = hb_subset_test_create_subset (face_abc, hb_subset_test_create_input (codepoints));
|
||||
hb_set_destroy (codepoints);
|
||||
|
||||
hb_subset_test_check (face_abc, face_abc_subset, HB_TAG ('c','m','a','p'));
|
||||
|
@ -24,8 +24,6 @@
|
||||
* Google Author(s): Garret Rieger
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "hb-test.h"
|
||||
#include "hb-subset-test.h"
|
||||
|
||||
@ -66,9 +64,10 @@ test_subset_glyf (void)
|
||||
hb_face_t *face_ac = hb_subset_test_open_font ("fonts/Roboto-Regular.ac.ttf");
|
||||
|
||||
hb_set_t *codepoints = hb_set_create();
|
||||
hb_face_t *face_abc_subset;
|
||||
hb_set_add (codepoints, 97);
|
||||
hb_set_add (codepoints, 99);
|
||||
hb_face_t *face_abc_subset = hb_subset_test_create_subset (face_abc, hb_subset_test_create_input (codepoints));
|
||||
face_abc_subset = hb_subset_test_create_subset (face_abc, hb_subset_test_create_input (codepoints));
|
||||
hb_set_destroy (codepoints);
|
||||
|
||||
hb_subset_test_check (face_ac, face_abc_subset, HB_TAG ('g','l','y','f'));
|
||||
@ -87,8 +86,9 @@ test_subset_glyf_with_components (void)
|
||||
hb_face_t *face_subset = hb_subset_test_open_font ("fonts/Roboto-Regular.components.subset.ttf");
|
||||
|
||||
hb_set_t *codepoints = hb_set_create();
|
||||
hb_face_t *face_generated_subset;
|
||||
hb_set_add (codepoints, 0x1fc);
|
||||
hb_face_t *face_generated_subset = hb_subset_test_create_subset (face_components, hb_subset_test_create_input (codepoints));
|
||||
face_generated_subset = hb_subset_test_create_subset (face_components, hb_subset_test_create_input (codepoints));
|
||||
hb_set_destroy (codepoints);
|
||||
|
||||
hb_subset_test_check (face_subset, face_generated_subset, HB_TAG ('g','l','y','f'));
|
||||
@ -106,10 +106,11 @@ test_subset_glyf_noop (void)
|
||||
hb_face_t *face_abc = hb_subset_test_open_font("fonts/Roboto-Regular.abc.ttf");
|
||||
|
||||
hb_set_t *codepoints = hb_set_create();
|
||||
hb_face_t *face_abc_subset;
|
||||
hb_set_add (codepoints, 97);
|
||||
hb_set_add (codepoints, 98);
|
||||
hb_set_add (codepoints, 99);
|
||||
hb_face_t *face_abc_subset = hb_subset_test_create_subset (face_abc, hb_subset_test_create_input (codepoints));
|
||||
face_abc_subset = hb_subset_test_create_subset (face_abc, hb_subset_test_create_input (codepoints));
|
||||
hb_set_destroy (codepoints);
|
||||
|
||||
hb_subset_test_check (face_abc, face_abc_subset, HB_TAG ('g','l','y','f'));
|
||||
@ -127,11 +128,13 @@ test_subset_glyf_strip_hints_simple (void)
|
||||
hb_face_t *face_ac = hb_subset_test_open_font ("fonts/Roboto-Regular.ac.nohints.ttf");
|
||||
|
||||
hb_set_t *codepoints = hb_set_create();
|
||||
hb_subset_input_t *input;
|
||||
hb_face_t *face_abc_subset;
|
||||
hb_set_add (codepoints, 'a');
|
||||
hb_set_add (codepoints, 'c');
|
||||
hb_subset_input_t *input = hb_subset_test_create_input (codepoints);
|
||||
input = hb_subset_test_create_input (codepoints);
|
||||
*hb_subset_input_drop_hints(input) = true;
|
||||
hb_face_t *face_abc_subset = hb_subset_test_create_subset (face_abc, input);
|
||||
face_abc_subset = hb_subset_test_create_subset (face_abc, input);
|
||||
hb_set_destroy (codepoints);
|
||||
|
||||
hb_subset_test_check (face_ac, face_abc_subset, HB_TAG ('l','o','c', 'a'));
|
||||
@ -150,11 +153,13 @@ test_subset_glyf_strip_hints_composite (void)
|
||||
hb_face_t *face_subset = hb_subset_test_open_font ("fonts/Roboto-Regular.components.1fc.nohints.ttf");
|
||||
|
||||
hb_set_t *codepoints = hb_set_create();
|
||||
hb_subset_input_t *input;
|
||||
hb_face_t *face_generated_subset;
|
||||
hb_set_add (codepoints, 0x1fc);
|
||||
hb_subset_input_t *input = hb_subset_test_create_input (codepoints);
|
||||
input = hb_subset_test_create_input (codepoints);
|
||||
*hb_subset_input_drop_hints(input) = true;
|
||||
|
||||
hb_face_t *face_generated_subset = hb_subset_test_create_subset (face_components, input);
|
||||
face_generated_subset = hb_subset_test_create_subset (face_components, input);
|
||||
hb_set_destroy (codepoints);
|
||||
|
||||
hb_subset_test_check (face_subset, face_generated_subset, HB_TAG ('g','l','y','f'));
|
||||
|
@ -24,8 +24,6 @@
|
||||
* Google Author(s): Garret Rieger
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "hb-test.h"
|
||||
#include "hb-subset-test.h"
|
||||
|
||||
@ -39,9 +37,10 @@ test_subset_hdmx_simple_subset (void)
|
||||
hb_face_t *face_ac = hb_subset_test_open_font ("fonts/Roboto-Regular.ac.ttf");
|
||||
|
||||
hb_set_t *codepoints = hb_set_create ();
|
||||
hb_face_t *face_abc_subset;
|
||||
hb_set_add (codepoints, 'a');
|
||||
hb_set_add (codepoints, 'c');
|
||||
hb_face_t *face_abc_subset = hb_subset_test_create_subset (face_abc, hb_subset_test_create_input (codepoints));
|
||||
face_abc_subset = hb_subset_test_create_subset (face_abc, hb_subset_test_create_input (codepoints));
|
||||
hb_set_destroy (codepoints);
|
||||
|
||||
hb_subset_test_check (face_ac, face_abc_subset, HB_TAG ('h','d','m','x'));
|
||||
@ -57,10 +56,11 @@ test_subset_hdmx_noop (void)
|
||||
hb_face_t *face_abc = hb_subset_test_open_font("fonts/Roboto-Regular.abc.ttf");
|
||||
|
||||
hb_set_t *codepoints = hb_set_create();
|
||||
hb_face_t *face_abc_subset;
|
||||
hb_set_add (codepoints, 'a');
|
||||
hb_set_add (codepoints, 'b');
|
||||
hb_set_add (codepoints, 'c');
|
||||
hb_face_t *face_abc_subset = hb_subset_test_create_subset (face_abc, hb_subset_test_create_input (codepoints));
|
||||
face_abc_subset = hb_subset_test_create_subset (face_abc, hb_subset_test_create_input (codepoints));
|
||||
hb_set_destroy (codepoints);
|
||||
|
||||
hb_subset_test_check (face_abc, face_abc_subset, HB_TAG ('h','d','m','x'));
|
||||
|
@ -24,8 +24,6 @@
|
||||
* Google Author(s): Roderick Sheeter
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "hb-test.h"
|
||||
#include "hb-subset-test.h"
|
||||
|
||||
@ -53,9 +51,10 @@ test_subset_hmtx_simple_subset (void)
|
||||
hb_face_t *face_ac = hb_subset_test_open_font ("fonts/Roboto-Regular.ac.ttf");
|
||||
|
||||
hb_set_t *codepoints = hb_set_create ();
|
||||
hb_face_t *face_abc_subset;
|
||||
hb_set_add (codepoints, 'a');
|
||||
hb_set_add (codepoints, 'c');
|
||||
hb_face_t *face_abc_subset = hb_subset_test_create_subset (face_abc, hb_subset_test_create_input (codepoints));
|
||||
face_abc_subset = hb_subset_test_create_subset (face_abc, hb_subset_test_create_input (codepoints));
|
||||
hb_set_destroy (codepoints);
|
||||
|
||||
check_num_hmetrics(face_abc_subset, 3); /* nothing has same width */
|
||||
@ -74,9 +73,10 @@ test_subset_hmtx_monospace (void)
|
||||
hb_face_t *face_ac = hb_subset_test_open_font ("fonts/Inconsolata-Regular.ac.ttf");
|
||||
|
||||
hb_set_t *codepoints = hb_set_create ();
|
||||
hb_face_t *face_abc_subset;
|
||||
hb_set_add (codepoints, 'a');
|
||||
hb_set_add (codepoints, 'c');
|
||||
hb_face_t *face_abc_subset = hb_subset_test_create_subset (face_abc, hb_subset_test_create_input (codepoints));
|
||||
face_abc_subset = hb_subset_test_create_subset (face_abc, hb_subset_test_create_input (codepoints));
|
||||
hb_set_destroy (codepoints);
|
||||
|
||||
check_num_hmetrics(face_abc_subset, 1); /* everything has same width */
|
||||
@ -95,9 +95,10 @@ test_subset_hmtx_keep_num_metrics (void)
|
||||
hb_face_t *face_ac = hb_subset_test_open_font ("fonts/Inconsolata-Regular.ac.widerc.ttf");
|
||||
|
||||
hb_set_t *codepoints = hb_set_create ();
|
||||
hb_face_t *face_abc_subset;
|
||||
hb_set_add (codepoints, 'a');
|
||||
hb_set_add (codepoints, 'c');
|
||||
hb_face_t *face_abc_subset = hb_subset_test_create_subset (face_abc, hb_subset_test_create_input (codepoints));
|
||||
face_abc_subset = hb_subset_test_create_subset (face_abc, hb_subset_test_create_input (codepoints));
|
||||
hb_set_destroy (codepoints);
|
||||
|
||||
check_num_hmetrics(face_abc_subset, 3); /* c is wider */
|
||||
@ -115,9 +116,10 @@ test_subset_hmtx_decrease_num_metrics (void)
|
||||
hb_face_t *face_ab = hb_subset_test_open_font ("fonts/Inconsolata-Regular.ab.ttf");
|
||||
|
||||
hb_set_t *codepoints = hb_set_create ();
|
||||
hb_face_t *face_abc_subset;
|
||||
hb_set_add (codepoints, 'a');
|
||||
hb_set_add (codepoints, 'b');
|
||||
hb_face_t *face_abc_subset = hb_subset_test_create_subset (face_abc, hb_subset_test_create_input (codepoints));
|
||||
face_abc_subset = hb_subset_test_create_subset (face_abc, hb_subset_test_create_input (codepoints));
|
||||
hb_set_destroy (codepoints);
|
||||
|
||||
check_num_hmetrics(face_abc_subset, 1); /* everything left has same width */
|
||||
@ -134,10 +136,11 @@ test_subset_hmtx_noop (void)
|
||||
hb_face_t *face_abc = hb_subset_test_open_font("fonts/Roboto-Regular.abc.ttf");
|
||||
|
||||
hb_set_t *codepoints = hb_set_create();
|
||||
hb_face_t *face_abc_subset;
|
||||
hb_set_add (codepoints, 'a');
|
||||
hb_set_add (codepoints, 'b');
|
||||
hb_set_add (codepoints, 'c');
|
||||
hb_face_t *face_abc_subset = hb_subset_test_create_subset (face_abc, hb_subset_test_create_input (codepoints));
|
||||
face_abc_subset = hb_subset_test_create_subset (face_abc, hb_subset_test_create_input (codepoints));
|
||||
hb_set_destroy (codepoints);
|
||||
|
||||
check_num_hmetrics(face_abc_subset, 4); /* nothing has same width */
|
||||
|
@ -24,7 +24,6 @@
|
||||
* Google Author(s): Garret Rieger
|
||||
*/
|
||||
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "hb-test.h"
|
||||
#include "hb-subset-test.h"
|
||||
@ -36,8 +35,9 @@ test_subset_os2 (void)
|
||||
hb_face_t *face_b = hb_subset_test_open_font("fonts/Roboto-Regular.b.ttf");
|
||||
|
||||
hb_set_t *codepoints = hb_set_create();
|
||||
hb_face_t *face_abc_subset;
|
||||
hb_set_add (codepoints, 98);
|
||||
hb_face_t *face_abc_subset = hb_subset_test_create_subset (face_abc, hb_subset_test_create_input (codepoints));
|
||||
face_abc_subset = hb_subset_test_create_subset (face_abc, hb_subset_test_create_input (codepoints));
|
||||
hb_set_destroy (codepoints);
|
||||
|
||||
hb_subset_test_check (face_b, face_abc_subset, HB_TAG ('O','S','/','2'));
|
||||
|
Loading…
Reference in New Issue
Block a user