[subset] Clean up hb_subset_input_t API

This commit is contained in:
Behdad Esfahbod 2018-08-29 18:24:03 -07:00
parent d237ce7181
commit 93fe0faaee
9 changed files with 52 additions and 49 deletions

View File

@ -44,7 +44,7 @@ hb_subset_input_create_or_fail (void)
input->unicodes = hb_set_create (); input->unicodes = hb_set_create ();
input->glyphs = hb_set_create (); input->glyphs = hb_set_create ();
input->drop_ot_layout = true; input->drop_layout = true;
return input; return input;
} }
@ -106,30 +106,28 @@ hb_subset_input_glyph_set (hb_subset_input_t *subset_input)
return subset_input->glyphs; return subset_input->glyphs;
} }
/** HB_EXTERN void
* hb_subset_input_drop_hints: hb_subset_input_set_drop_hints (hb_subset_input_t *subset_input,
* @subset_input: a subset_input. hb_bool_t drop_hints)
*
* Since: 1.8.0
**/
HB_EXTERN hb_bool_t *
hb_subset_input_drop_hints (hb_subset_input_t *subset_input)
{ {
return &subset_input->drop_hints; subset_input->drop_hints = drop_hints;
} }
/** HB_EXTERN hb_bool_t
* hb_subset_input_drop_ot_layout: hb_subset_input_get_drop_hints (hb_subset_input_t *subset_input)
* @subset_input: a subset_input.
*
* If enabled ot layout tables will be dropped as part of
* the subsetting operation. Currently this defaults to
* true.
*
* Since: REPLACEME
**/
HB_EXTERN hb_bool_t *
hb_subset_input_drop_ot_layout (hb_subset_input_t *subset_input)
{ {
return &subset_input->drop_ot_layout; return subset_input->drop_hints;
}
HB_EXTERN void
hb_subset_input_set_drop_layout (hb_subset_input_t *subset_input,
hb_bool_t drop_layout)
{
subset_input->drop_layout = drop_layout;
}
HB_EXTERN hb_bool_t
hb_subset_input_get_drop_layout (hb_subset_input_t *subset_input)
{
return subset_input->drop_layout;
} }

View File

@ -149,7 +149,7 @@ hb_subset_plan_create (hb_face_t *face,
hb_subset_plan_t *plan = hb_object_create<hb_subset_plan_t> (); hb_subset_plan_t *plan = hb_object_create<hb_subset_plan_t> ();
plan->drop_hints = input->drop_hints; plan->drop_hints = input->drop_hints;
plan->drop_ot_layout = input->drop_ot_layout; plan->drop_layout = input->drop_layout;
plan->unicodes = hb_set_create(); plan->unicodes = hb_set_create();
plan->glyphs.init(); plan->glyphs.init();
plan->source = hb_face_reference (face); plan->source = hb_face_reference (face);
@ -159,7 +159,7 @@ hb_subset_plan_create (hb_face_t *face,
_populate_gids_to_retain (face, _populate_gids_to_retain (face,
input->unicodes, input->unicodes,
!plan->drop_ot_layout, !plan->drop_layout,
plan->unicodes, plan->unicodes,
plan->codepoint_to_glyph, plan->codepoint_to_glyph,
&plan->glyphs); &plan->glyphs);

View File

@ -39,8 +39,8 @@ struct hb_subset_plan_t
hb_object_header_t header; hb_object_header_t header;
ASSERT_POD (); ASSERT_POD ();
hb_bool_t drop_hints; bool drop_hints : 1;
hb_bool_t drop_ot_layout; bool drop_layout : 1;
// For each cp that we'd like to retain maps to the corresponding gid. // For each cp that we'd like to retain maps to the corresponding gid.
hb_set_t *unicodes; hb_set_t *unicodes;
@ -56,7 +56,7 @@ struct hb_subset_plan_t
hb_face_t *source; hb_face_t *source;
hb_face_t *dest; hb_face_t *dest;
inline hb_bool_t inline bool
new_gid_for_codepoint (hb_codepoint_t codepoint, new_gid_for_codepoint (hb_codepoint_t codepoint,
hb_codepoint_t *new_gid) const hb_codepoint_t *new_gid) const
{ {
@ -67,7 +67,7 @@ struct hb_subset_plan_t
return new_gid_for_old_gid (old_gid, new_gid); return new_gid_for_old_gid (old_gid, new_gid);
} }
inline hb_bool_t inline bool
new_gid_for_old_gid (hb_codepoint_t old_gid, new_gid_for_old_gid (hb_codepoint_t old_gid,
hb_codepoint_t *new_gid) const hb_codepoint_t *new_gid) const
{ {
@ -79,7 +79,7 @@ struct hb_subset_plan_t
return true; return true;
} }
inline hb_bool_t inline bool
add_table (hb_tag_t tag, add_table (hb_tag_t tag,
hb_blob_t *contents) hb_blob_t *contents)
{ {

View File

@ -136,7 +136,7 @@ _should_drop_table(hb_subset_plan_t *plan, hb_tag_t tag)
case HB_TAG ('G', 'D', 'E', 'F'): /* temporary */ case HB_TAG ('G', 'D', 'E', 'F'): /* temporary */
case HB_TAG ('G', 'P', 'O', 'S'): /* temporary */ case HB_TAG ('G', 'P', 'O', 'S'): /* temporary */
case HB_TAG ('G', 'S', 'U', 'B'): /* temporary */ case HB_TAG ('G', 'S', 'U', 'B'): /* temporary */
return plan->drop_ot_layout; return plan->drop_layout;
// Drop these tables below by default, list pulled // Drop these tables below by default, list pulled
// from fontTools: // from fontTools:
case HB_TAG ('B', 'A', 'S', 'E'): case HB_TAG ('B', 'A', 'S', 'E'):

View File

@ -54,11 +54,17 @@ hb_subset_input_unicode_set (hb_subset_input_t *subset_input);
HB_EXTERN hb_set_t * HB_EXTERN hb_set_t *
hb_subset_input_glyph_set (hb_subset_input_t *subset_input); hb_subset_input_glyph_set (hb_subset_input_t *subset_input);
HB_EXTERN hb_bool_t * HB_EXTERN void
hb_subset_input_drop_hints (hb_subset_input_t *subset_input); hb_subset_input_set_drop_hints (hb_subset_input_t *subset_input,
hb_bool_t drop_hints);
HB_EXTERN hb_bool_t
hb_subset_input_get_drop_hints (hb_subset_input_t *subset_input);
HB_EXTERN hb_bool_t * HB_EXTERN void
hb_subset_input_drop_ot_layout (hb_subset_input_t *subset_input); hb_subset_input_set_drop_layout (hb_subset_input_t *subset_input,
hb_bool_t drop_layout);
HB_EXTERN hb_bool_t
hb_subset_input_get_drop_layout (hb_subset_input_t *subset_input);
/* hb_subset() */ /* hb_subset() */

View File

@ -42,8 +42,8 @@ struct hb_subset_input_t
hb_set_t *unicodes; hb_set_t *unicodes;
hb_set_t *glyphs; hb_set_t *glyphs;
hb_bool_t drop_hints; bool drop_hints : 1;
hb_bool_t drop_ot_layout; bool drop_layout : 1;
/* TODO /* TODO
* *
* features * features

View File

@ -112,7 +112,7 @@ test_subset_glyf_with_gsub (void)
hb_subset_input_t *input = hb_subset_test_create_input (codepoints); hb_subset_input_t *input = hb_subset_test_create_input (codepoints);
hb_set_destroy (codepoints); hb_set_destroy (codepoints);
*hb_subset_input_drop_ot_layout (input) = false; hb_subset_input_set_drop_layout (input, false);
hb_face_t *face_subset = hb_subset_test_create_subset (face_fil, input); hb_face_t *face_subset = hb_subset_test_create_subset (face_fil, input);
@ -137,7 +137,7 @@ test_subset_glyf_without_gsub (void)
hb_subset_input_t *input = hb_subset_test_create_input (codepoints); hb_subset_input_t *input = hb_subset_test_create_input (codepoints);
hb_set_destroy (codepoints); hb_set_destroy (codepoints);
*hb_subset_input_drop_ot_layout (input) = true; hb_subset_input_set_drop_layout (input, true);
hb_face_t *face_subset = hb_subset_test_create_subset (face_fil, input); hb_face_t *face_subset = hb_subset_test_create_subset (face_fil, input);
@ -183,7 +183,7 @@ test_subset_glyf_strip_hints_simple (void)
hb_set_add (codepoints, 'a'); hb_set_add (codepoints, 'a');
hb_set_add (codepoints, 'c'); hb_set_add (codepoints, 'c');
input = hb_subset_test_create_input (codepoints); input = hb_subset_test_create_input (codepoints);
*hb_subset_input_drop_hints(input) = true; hb_subset_input_set_drop_hints (input, true);
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_set_destroy (codepoints);
@ -207,7 +207,7 @@ test_subset_glyf_strip_hints_composite (void)
hb_face_t *face_generated_subset; hb_face_t *face_generated_subset;
hb_set_add (codepoints, 0x1fc); hb_set_add (codepoints, 0x1fc);
input = hb_subset_test_create_input (codepoints); input = hb_subset_test_create_input (codepoints);
*hb_subset_input_drop_hints(input) = true; hb_subset_input_set_drop_hints (input, true);
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_set_destroy (codepoints);
@ -239,7 +239,7 @@ test_subset_glyf_strip_hints_invalid (void)
} }
hb_subset_input_t *input = hb_subset_test_create_input (codepoints); hb_subset_input_t *input = hb_subset_test_create_input (codepoints);
*hb_subset_input_drop_hints(input) = true; hb_subset_input_set_drop_hints (input, true);
hb_set_destroy (codepoints); hb_set_destroy (codepoints);
hb_face_t *face_subset = hb_subset_test_create_subset (face, input); hb_face_t *face_subset = hb_subset_test_create_subset (face, input);

View File

@ -10,11 +10,11 @@ void trySubset (hb_face_t *face,
const hb_codepoint_t text[], const hb_codepoint_t text[],
int text_length, int text_length,
bool drop_hints, bool drop_hints,
bool drop_ot_layout) bool drop_layout)
{ {
hb_subset_input_t *input = hb_subset_input_create_or_fail (); hb_subset_input_t *input = hb_subset_input_create_or_fail ();
*hb_subset_input_drop_hints (input) = drop_hints; hb_subset_input_set_drop_hints (input, drop_hints);
*hb_subset_input_drop_ot_layout (input) = drop_ot_layout; hb_subset_input_set_drop_layout (input, drop_layout);
hb_set_t *codepoints = hb_subset_input_unicode_set (input); hb_set_t *codepoints = hb_subset_input_unicode_set (input);
for (int i = 0; i < text_length; i++) for (int i = 0; i < text_length; i++)
@ -34,10 +34,10 @@ void trySubset (hb_face_t *face,
{ {
for (unsigned int drop_hints = 0; drop_hints < 2; drop_hints++) for (unsigned int drop_hints = 0; drop_hints < 2; drop_hints++)
{ {
for (unsigned int drop_ot_layout = 0; drop_ot_layout < 2; drop_ot_layout++) for (unsigned int drop_layout = 0; drop_layout < 2; drop_layout++)
{ {
trySubset (face, text, text_length, trySubset (face, text, text_length,
(bool) drop_hints, (bool) drop_ot_layout); (bool) drop_hints, (bool) drop_layout);
} }
} }
} }

View File

@ -29,7 +29,6 @@
#include "main-font-text.hh" #include "main-font-text.hh"
#include "hb-subset.h" #include "hb-subset.h"
#include "hb-subset.hh" /* XXX */
/* /*
* Command line interface to the harfbuzz font subsetter. * Command line interface to the harfbuzz font subsetter.
@ -90,7 +89,7 @@ struct subset_consumer_t
void finish (const font_options_t *font_opts) void finish (const font_options_t *font_opts)
{ {
input->drop_hints = subset_options.drop_hints; hb_subset_input_set_drop_hints (input, subset_options.drop_hints);
hb_face_t *face = hb_font_get_face (font); hb_face_t *face = hb_font_get_face (font);