[subset] add option to have the subsetter set the mac overlaps flag on each glyph.
This commit is contained in:
parent
f739e1dc6a
commit
73ff04a324
|
@ -281,6 +281,11 @@ struct glyf
|
|||
hb_codepoint_t get_glyph_index () const { return glyphIndex; }
|
||||
|
||||
void drop_instructions_flag () { flags = (uint16_t) flags & ~WE_HAVE_INSTRUCTIONS; }
|
||||
void set_overlaps_flag ()
|
||||
{
|
||||
flags = (uint16_t) flags | OVERLAP_COMPOUND;
|
||||
}
|
||||
|
||||
bool has_instructions () const { return flags & WE_HAVE_INSTRUCTIONS; }
|
||||
|
||||
bool has_more () const { return flags & MORE_COMPONENTS; }
|
||||
|
@ -427,14 +432,14 @@ struct glyf
|
|||
{
|
||||
enum simple_glyph_flag_t
|
||||
{
|
||||
FLAG_ON_CURVE = 0x01,
|
||||
FLAG_X_SHORT = 0x02,
|
||||
FLAG_Y_SHORT = 0x04,
|
||||
FLAG_REPEAT = 0x08,
|
||||
FLAG_X_SAME = 0x10,
|
||||
FLAG_Y_SAME = 0x20,
|
||||
FLAG_RESERVED1 = 0x40,
|
||||
FLAG_RESERVED2 = 0x80
|
||||
FLAG_ON_CURVE = 0x01,
|
||||
FLAG_X_SHORT = 0x02,
|
||||
FLAG_Y_SHORT = 0x04,
|
||||
FLAG_REPEAT = 0x08,
|
||||
FLAG_X_SAME = 0x10,
|
||||
FLAG_Y_SAME = 0x20,
|
||||
FLAG_OVERLAP_SIMPLE = 0x40,
|
||||
FLAG_RESERVED2 = 0x80
|
||||
};
|
||||
|
||||
private:
|
||||
|
@ -553,6 +558,17 @@ struct glyf
|
|||
dest_end = bytes.sub_array (glyph_length, bytes.length - glyph_length);
|
||||
}
|
||||
|
||||
void set_overlaps_flag ()
|
||||
{
|
||||
if (unlikely (!header.numberOfContours)) return;
|
||||
|
||||
unsigned flags_offset = length (instructions_length ());
|
||||
if (unlikely (length (flags_offset + 1) > bytes.length)) return;
|
||||
|
||||
HBUINT8 &first_flag = (HBUINT8 &) StructAtOffset<HBUINT16> (&bytes, flags_offset);
|
||||
first_flag = (uint8_t) first_flag | FLAG_OVERLAP_SIMPLE;
|
||||
}
|
||||
|
||||
static bool read_points (const HBUINT8 *&p /* IN/OUT */,
|
||||
contour_point_vector_t &points_ /* IN/OUT */,
|
||||
const hb_bytes_t &bytes,
|
||||
|
@ -666,6 +682,12 @@ struct glyf
|
|||
/* Chop instructions off the end */
|
||||
void drop_hints_bytes (hb_bytes_t &dest_start) const
|
||||
{ dest_start = bytes.sub_array (0, bytes.length - instructions_length (bytes)); }
|
||||
|
||||
void set_overlaps_flag ()
|
||||
{
|
||||
const_cast<CompositeGlyphChain &> (StructAfter<CompositeGlyphChain, GlyphHeader> (header))
|
||||
.set_overlaps_flag ();
|
||||
}
|
||||
};
|
||||
|
||||
enum glyph_type_t { EMPTY, SIMPLE, COMPOSITE };
|
||||
|
@ -695,6 +717,15 @@ struct glyf
|
|||
}
|
||||
}
|
||||
|
||||
void set_overlaps_flag ()
|
||||
{
|
||||
switch (type) {
|
||||
case COMPOSITE: CompositeGlyph (*header, bytes).set_overlaps_flag (); return;
|
||||
case SIMPLE: SimpleGlyph (*header, bytes).set_overlaps_flag (); return;
|
||||
default: return;
|
||||
}
|
||||
}
|
||||
|
||||
void drop_hints_bytes (hb_bytes_t &dest_start, hb_bytes_t &dest_end) const
|
||||
{
|
||||
switch (type) {
|
||||
|
@ -1232,6 +1263,9 @@ struct glyf
|
|||
|
||||
if (plan->drop_hints) Glyph (dest_glyph).drop_hints ();
|
||||
|
||||
if (plan->overlaps_flag)
|
||||
Glyph (dest_glyph).set_overlaps_flag ();
|
||||
|
||||
return_trace (true);
|
||||
}
|
||||
|
||||
|
|
|
@ -53,6 +53,7 @@ hb_subset_input_create_or_fail ()
|
|||
input->desubroutinize = false;
|
||||
input->retain_gids = false;
|
||||
input->name_legacy = false;
|
||||
input->overlaps_flag = false;
|
||||
|
||||
hb_tag_t default_drop_tables[] = {
|
||||
// Layout disabled by default
|
||||
|
@ -224,3 +225,16 @@ hb_subset_input_get_name_legacy (hb_subset_input_t *subset_input)
|
|||
{
|
||||
return subset_input->name_legacy;
|
||||
}
|
||||
|
||||
HB_EXTERN void
|
||||
hb_subset_input_set_overlaps_flag (hb_subset_input_t *subset_input,
|
||||
hb_bool_t overlaps_flag)
|
||||
{
|
||||
subset_input->overlaps_flag = overlaps_flag;
|
||||
}
|
||||
|
||||
HB_EXTERN hb_bool_t
|
||||
hb_subset_input_get_overlaps_flag (hb_subset_input_t *subset_input)
|
||||
{
|
||||
return subset_input->overlaps_flag;
|
||||
}
|
||||
|
|
|
@ -48,6 +48,7 @@ struct hb_subset_input_t
|
|||
bool desubroutinize;
|
||||
bool retain_gids;
|
||||
bool name_legacy;
|
||||
bool overlaps_flag;
|
||||
/* TODO
|
||||
*
|
||||
* features
|
||||
|
|
|
@ -392,6 +392,7 @@ hb_subset_plan_create (hb_face_t *face,
|
|||
plan->desubroutinize = input->desubroutinize;
|
||||
plan->retain_gids = input->retain_gids;
|
||||
plan->name_legacy = input->name_legacy;
|
||||
plan->overlaps_flag = input->overlaps_flag;
|
||||
plan->unicodes = hb_set_create ();
|
||||
plan->name_ids = hb_set_reference (input->name_ids);
|
||||
_nameid_closure (face, plan->name_ids);
|
||||
|
|
|
@ -44,6 +44,7 @@ struct hb_subset_plan_t
|
|||
bool desubroutinize : 1;
|
||||
bool retain_gids : 1;
|
||||
bool name_legacy : 1;
|
||||
bool overlaps_flag : 1;
|
||||
|
||||
// For each cp that we'd like to retain maps to the corresponding gid.
|
||||
hb_set_t *unicodes;
|
||||
|
|
|
@ -87,6 +87,13 @@ hb_subset_input_set_name_legacy (hb_subset_input_t *subset_input,
|
|||
HB_EXTERN hb_bool_t
|
||||
hb_subset_input_get_name_legacy (hb_subset_input_t *subset_input);
|
||||
|
||||
HB_EXTERN void
|
||||
hb_subset_input_set_overlaps_flag (hb_subset_input_t *subset_input,
|
||||
hb_bool_t overlaps_flag);
|
||||
|
||||
HB_EXTERN hb_bool_t
|
||||
hb_subset_input_get_overlaps_flag (hb_subset_input_t *subset_input);
|
||||
|
||||
/* hb_subset () */
|
||||
HB_EXTERN hb_face_t *
|
||||
hb_subset (hb_face_t *source, hb_subset_input_t *input);
|
||||
|
|
|
@ -255,7 +255,8 @@ subset_options_t::add_options (option_parser_t *parser)
|
|||
{"num-iterations", 'n', 0, G_OPTION_ARG_INT,
|
||||
&this->num_iterations,
|
||||
"Run subsetter N times (default: 1)", "N"},
|
||||
|
||||
{"set-overlaps-flag", 0, 0, G_OPTION_ARG_NONE, &this->input->overlaps_flag,
|
||||
"Set the overlaps flag on each glyph.", nullptr},
|
||||
{nullptr}
|
||||
};
|
||||
parser->add_group (entries,
|
||||
|
|
Loading…
Reference in New Issue