Merge pull request #3381 from harfbuzz/clean-vector-use
Clean vector use
This commit is contained in:
commit
10a20be397
|
@ -33,20 +33,6 @@
|
||||||
/* Bi-directional map */
|
/* Bi-directional map */
|
||||||
struct hb_bimap_t
|
struct hb_bimap_t
|
||||||
{
|
{
|
||||||
/* XXX(remove) */
|
|
||||||
void init ()
|
|
||||||
{
|
|
||||||
forw_map.init ();
|
|
||||||
back_map.init ();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* XXX(remove) */
|
|
||||||
void fini ()
|
|
||||||
{
|
|
||||||
forw_map.fini ();
|
|
||||||
back_map.fini ();
|
|
||||||
}
|
|
||||||
|
|
||||||
void reset ()
|
void reset ()
|
||||||
{
|
{
|
||||||
forw_map.reset ();
|
forw_map.reset ();
|
||||||
|
|
|
@ -217,9 +217,6 @@ inline unsigned int OpCode_Size (op_code_t op) { return Is_OpCode_ESC (op) ? 2:
|
||||||
|
|
||||||
struct number_t
|
struct number_t
|
||||||
{
|
{
|
||||||
void init () { set_real (0.0); }
|
|
||||||
void fini () {}
|
|
||||||
|
|
||||||
void set_int (int v) { value = v; }
|
void set_int (int v) { value = v; }
|
||||||
int to_int () const { return value; }
|
int to_int () const { return value; }
|
||||||
|
|
||||||
|
@ -245,7 +242,7 @@ struct number_t
|
||||||
}
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
double value;
|
double value = 0.;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* byte string */
|
/* byte string */
|
||||||
|
@ -380,10 +377,8 @@ struct cff_stack_t
|
||||||
count = 0;
|
count = 0;
|
||||||
elements.init ();
|
elements.init ();
|
||||||
elements.resize (kSizeLimit);
|
elements.resize (kSizeLimit);
|
||||||
for (unsigned int i = 0; i < elements.length; i++)
|
|
||||||
elements[i].init ();
|
|
||||||
}
|
}
|
||||||
void fini () { elements.fini_deep (); }
|
void fini () { elements.fini (); }
|
||||||
|
|
||||||
ELEM& operator [] (unsigned int i)
|
ELEM& operator [] (unsigned int i)
|
||||||
{
|
{
|
||||||
|
@ -523,9 +518,6 @@ struct arg_stack_t : cff_stack_t<ARG, 513>
|
||||||
/* an operator prefixed by its operands in a byte string */
|
/* an operator prefixed by its operands in a byte string */
|
||||||
struct op_str_t
|
struct op_str_t
|
||||||
{
|
{
|
||||||
void init () {}
|
|
||||||
void fini () {}
|
|
||||||
|
|
||||||
op_code_t op;
|
op_code_t op;
|
||||||
byte_str_t str;
|
byte_str_t str;
|
||||||
};
|
};
|
||||||
|
@ -553,7 +545,7 @@ struct parsed_values_t
|
||||||
opStart = 0;
|
opStart = 0;
|
||||||
values.init ();
|
values.init ();
|
||||||
}
|
}
|
||||||
void fini () { values.fini_deep (); }
|
void fini () { values.fini (); }
|
||||||
|
|
||||||
void add_op (op_code_t op, const byte_str_ref_t& str_ref = byte_str_ref_t ())
|
void add_op (op_code_t op, const byte_str_ref_t& str_ref = byte_str_ref_t ())
|
||||||
{
|
{
|
||||||
|
|
|
@ -94,12 +94,6 @@ struct biased_subrs_t
|
||||||
|
|
||||||
struct point_t
|
struct point_t
|
||||||
{
|
{
|
||||||
void init ()
|
|
||||||
{
|
|
||||||
x.init ();
|
|
||||||
y.init ();
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_int (int _x, int _y)
|
void set_int (int _x, int _y)
|
||||||
{
|
{
|
||||||
x.set_int (_x);
|
x.set_int (_x);
|
||||||
|
@ -128,7 +122,7 @@ struct cs_interp_env_t : interp_env_t<ARG>
|
||||||
hstem_count = 0;
|
hstem_count = 0;
|
||||||
vstem_count = 0;
|
vstem_count = 0;
|
||||||
hintmask_size = 0;
|
hintmask_size = 0;
|
||||||
pt.init ();
|
pt.set_int (0, 0);
|
||||||
callStack.init ();
|
callStack.init ();
|
||||||
globalSubrs.init (globalSubrs_);
|
globalSubrs.init (globalSubrs_);
|
||||||
localSubrs.init (localSubrs_);
|
localSubrs.init (localSubrs_);
|
||||||
|
@ -841,7 +835,6 @@ struct path_procs_t
|
||||||
if (likely (env.argStack.get_count () == 11))
|
if (likely (env.argStack.get_count () == 11))
|
||||||
{
|
{
|
||||||
point_t d;
|
point_t d;
|
||||||
d.init ();
|
|
||||||
for (unsigned int i = 0; i < 10; i += 2)
|
for (unsigned int i = 0; i < 10; i += 2)
|
||||||
d.move (env.eval_arg (i), env.eval_arg (i+1));
|
d.move (env.eval_arg (i), env.eval_arg (i+1));
|
||||||
|
|
||||||
|
|
|
@ -35,18 +35,6 @@ using namespace OT;
|
||||||
|
|
||||||
struct blend_arg_t : number_t
|
struct blend_arg_t : number_t
|
||||||
{
|
{
|
||||||
void init ()
|
|
||||||
{
|
|
||||||
number_t::init ();
|
|
||||||
deltas.init ();
|
|
||||||
}
|
|
||||||
|
|
||||||
void fini ()
|
|
||||||
{
|
|
||||||
number_t::fini ();
|
|
||||||
deltas.fini_deep ();
|
|
||||||
}
|
|
||||||
|
|
||||||
void set_int (int v) { reset_blends (); number_t::set_int (v); }
|
void set_int (int v) { reset_blends (); number_t::set_int (v); }
|
||||||
void set_fixed (int32_t v) { reset_blends (); number_t::set_fixed (v); }
|
void set_fixed (int32_t v) { reset_blends (); number_t::set_fixed (v); }
|
||||||
void set_real (double v) { reset_blends (); number_t::set_real (v); }
|
void set_real (double v) { reset_blends (); number_t::set_real (v); }
|
||||||
|
|
|
@ -68,8 +68,6 @@ struct code_pair_t
|
||||||
typedef hb_vector_t<unsigned char> str_buff_t;
|
typedef hb_vector_t<unsigned char> str_buff_t;
|
||||||
struct str_buff_vec_t : hb_vector_t<str_buff_t>
|
struct str_buff_vec_t : hb_vector_t<str_buff_t>
|
||||||
{
|
{
|
||||||
void fini () { SUPER::fini_deep (); }
|
|
||||||
|
|
||||||
unsigned int total_size () const
|
unsigned int total_size () const
|
||||||
{
|
{
|
||||||
unsigned int size = 0;
|
unsigned int size = 0;
|
||||||
|
|
|
@ -1144,8 +1144,8 @@ struct cff1
|
||||||
{
|
{
|
||||||
sc.end_processing ();
|
sc.end_processing ();
|
||||||
topDict.fini ();
|
topDict.fini ();
|
||||||
fontDicts.fini_deep ();
|
fontDicts.fini ();
|
||||||
privateDicts.fini_deep ();
|
privateDicts.fini ();
|
||||||
hb_blob_destroy (blob);
|
hb_blob_destroy (blob);
|
||||||
blob = nullptr;
|
blob = nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -475,8 +475,8 @@ struct cff2
|
||||||
{
|
{
|
||||||
sc.end_processing ();
|
sc.end_processing ();
|
||||||
topDict.fini ();
|
topDict.fini ();
|
||||||
fontDicts.fini_deep ();
|
fontDicts.fini ();
|
||||||
privateDicts.fini_deep ();
|
privateDicts.fini ();
|
||||||
hb_blob_destroy (blob);
|
hb_blob_destroy (blob);
|
||||||
blob = nullptr;
|
blob = nullptr;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2930,8 +2930,6 @@ struct VariationStore
|
||||||
|
|
||||||
hb_vector_t<hb_inc_bimap_t> inner_maps;
|
hb_vector_t<hb_inc_bimap_t> inner_maps;
|
||||||
inner_maps.resize ((unsigned) dataSets.len);
|
inner_maps.resize ((unsigned) dataSets.len);
|
||||||
for (unsigned i = 0; i < inner_maps.length; i++)
|
|
||||||
inner_maps[i].init ();
|
|
||||||
|
|
||||||
for (unsigned idx : c->plan->layout_variation_indices->iter ())
|
for (unsigned idx : c->plan->layout_variation_indices->iter ())
|
||||||
{
|
{
|
||||||
|
@ -2939,18 +2937,11 @@ struct VariationStore
|
||||||
uint16_t minor = idx & 0xFFFF;
|
uint16_t minor = idx & 0xFFFF;
|
||||||
|
|
||||||
if (major >= inner_maps.length)
|
if (major >= inner_maps.length)
|
||||||
{
|
|
||||||
for (unsigned i = 0; i < inner_maps.length; i++)
|
|
||||||
inner_maps[i].fini ();
|
|
||||||
return_trace (false);
|
return_trace (false);
|
||||||
}
|
|
||||||
inner_maps[major].add (minor);
|
inner_maps[major].add (minor);
|
||||||
}
|
}
|
||||||
varstore_prime->serialize (c->serializer, this, inner_maps.as_array ());
|
varstore_prime->serialize (c->serializer, this, inner_maps.as_array ());
|
||||||
|
|
||||||
for (unsigned i = 0; i < inner_maps.length; i++)
|
|
||||||
inner_maps[i].fini ();
|
|
||||||
|
|
||||||
return_trace (
|
return_trace (
|
||||||
!c->serializer->in_error()
|
!c->serializer->in_error()
|
||||||
&& varstore_prime->dataSets);
|
&& varstore_prime->dataSets);
|
||||||
|
|
|
@ -177,9 +177,6 @@ struct hvarvvar_subset_plan_t
|
||||||
|
|
||||||
inner_maps.resize (var_store->get_sub_table_count ());
|
inner_maps.resize (var_store->get_sub_table_count ());
|
||||||
|
|
||||||
for (unsigned int i = 0; i < inner_maps.length; i++)
|
|
||||||
inner_maps[i].init ();
|
|
||||||
|
|
||||||
if (unlikely (!index_map_plans.length || !inner_sets.length || !inner_maps.length)) return;
|
if (unlikely (!index_map_plans.length || !inner_sets.length || !inner_maps.length)) return;
|
||||||
|
|
||||||
bool retain_adv_map = false;
|
bool retain_adv_map = false;
|
||||||
|
@ -229,8 +226,8 @@ struct hvarvvar_subset_plan_t
|
||||||
for (unsigned int i = 0; i < inner_sets.length; i++)
|
for (unsigned int i = 0; i < inner_sets.length; i++)
|
||||||
hb_set_destroy (inner_sets[i]);
|
hb_set_destroy (inner_sets[i]);
|
||||||
hb_set_destroy (adv_set);
|
hb_set_destroy (adv_set);
|
||||||
inner_maps.fini_deep ();
|
inner_maps.fini ();
|
||||||
index_map_plans.fini_deep ();
|
index_map_plans.fini ();
|
||||||
}
|
}
|
||||||
|
|
||||||
hb_inc_bimap_t outer_map;
|
hb_inc_bimap_t outer_map;
|
||||||
|
|
|
@ -275,60 +275,36 @@ struct subr_flattener_t
|
||||||
|
|
||||||
struct subr_closures_t
|
struct subr_closures_t
|
||||||
{
|
{
|
||||||
subr_closures_t () : valid (false), global_closure (nullptr)
|
subr_closures_t (unsigned int fd_count) : valid (false), global_closure (), local_closures ()
|
||||||
{ local_closures.init (); }
|
|
||||||
|
|
||||||
void init (unsigned int fd_count)
|
|
||||||
{
|
{
|
||||||
valid = true;
|
valid = true;
|
||||||
global_closure = hb_set_create ();
|
|
||||||
if (global_closure == hb_set_get_empty ())
|
|
||||||
valid = false;
|
|
||||||
if (!local_closures.resize (fd_count))
|
if (!local_closures.resize (fd_count))
|
||||||
valid = false;
|
valid = false;
|
||||||
|
|
||||||
for (unsigned int i = 0; i < local_closures.length; i++)
|
|
||||||
{
|
|
||||||
local_closures[i] = hb_set_create ();
|
|
||||||
if (local_closures[i] == hb_set_get_empty ())
|
|
||||||
valid = false;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void fini ()
|
|
||||||
{
|
|
||||||
hb_set_destroy (global_closure);
|
|
||||||
for (unsigned int i = 0; i < local_closures.length; i++)
|
|
||||||
hb_set_destroy (local_closures[i]);
|
|
||||||
local_closures.fini ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void reset ()
|
void reset ()
|
||||||
{
|
{
|
||||||
hb_set_clear (global_closure);
|
global_closure.clear();
|
||||||
for (unsigned int i = 0; i < local_closures.length; i++)
|
for (unsigned int i = 0; i < local_closures.length; i++)
|
||||||
hb_set_clear (local_closures[i]);
|
local_closures[i].clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool is_valid () const { return valid; }
|
bool is_valid () const { return valid; }
|
||||||
bool valid;
|
bool valid;
|
||||||
hb_set_t *global_closure;
|
hb_set_t global_closure;
|
||||||
hb_vector_t<hb_set_t *> local_closures;
|
hb_vector_t<hb_set_t> local_closures;
|
||||||
};
|
};
|
||||||
|
|
||||||
struct parsed_cs_op_t : op_str_t
|
struct parsed_cs_op_t : op_str_t
|
||||||
{
|
{
|
||||||
void init (unsigned int subr_num_ = 0)
|
void init (unsigned int subr_num_ = 0)
|
||||||
{
|
{
|
||||||
op_str_t::init ();
|
|
||||||
subr_num = subr_num_;
|
subr_num = subr_num_;
|
||||||
drop_flag = false;
|
drop_flag = false;
|
||||||
keep_flag = false;
|
keep_flag = false;
|
||||||
skip_flag = false;
|
skip_flag = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void fini () { op_str_t::fini (); }
|
|
||||||
|
|
||||||
bool for_drop () const { return drop_flag; }
|
bool for_drop () const { return drop_flag; }
|
||||||
void set_drop () { if (!for_keep ()) drop_flag = true; }
|
void set_drop () { if (!for_keep ()) drop_flag = true; }
|
||||||
|
|
||||||
|
@ -416,16 +392,6 @@ struct parsed_cs_str_t : parsed_values_t<parsed_cs_op_t>
|
||||||
|
|
||||||
struct parsed_cs_str_vec_t : hb_vector_t<parsed_cs_str_t>
|
struct parsed_cs_str_vec_t : hb_vector_t<parsed_cs_str_t>
|
||||||
{
|
{
|
||||||
void init (unsigned int len_ = 0)
|
|
||||||
{
|
|
||||||
SUPER::init ();
|
|
||||||
if (unlikely (!resize (len_)))
|
|
||||||
return;
|
|
||||||
for (unsigned int i = 0; i < length; i++)
|
|
||||||
(*this)[i].init ();
|
|
||||||
}
|
|
||||||
void fini () { SUPER::fini_deep (); }
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
typedef hb_vector_t<parsed_cs_str_t> SUPER;
|
typedef hb_vector_t<parsed_cs_str_t> SUPER;
|
||||||
};
|
};
|
||||||
|
@ -496,7 +462,7 @@ struct subr_subset_param_t
|
||||||
|
|
||||||
struct subr_remap_t : hb_inc_bimap_t
|
struct subr_remap_t : hb_inc_bimap_t
|
||||||
{
|
{
|
||||||
void create (hb_set_t *closure)
|
void create (const hb_set_t *closure)
|
||||||
{
|
{
|
||||||
/* create a remapping of subroutine numbers from old to new.
|
/* create a remapping of subroutine numbers from old to new.
|
||||||
* no optimization based on usage counts. fonttools doesn't appear doing that either.
|
* no optimization based on usage counts. fonttools doesn't appear doing that either.
|
||||||
|
@ -526,19 +492,9 @@ struct subr_remap_t : hb_inc_bimap_t
|
||||||
|
|
||||||
struct subr_remaps_t
|
struct subr_remaps_t
|
||||||
{
|
{
|
||||||
subr_remaps_t ()
|
subr_remaps_t (unsigned int fdCount)
|
||||||
{
|
{
|
||||||
global_remap.init ();
|
local_remaps.resize (fdCount);
|
||||||
local_remaps.init ();
|
|
||||||
}
|
|
||||||
|
|
||||||
~subr_remaps_t () { fini (); }
|
|
||||||
|
|
||||||
void init (unsigned int fdCount)
|
|
||||||
{
|
|
||||||
if (unlikely (!local_remaps.resize (fdCount))) return;
|
|
||||||
for (unsigned int i = 0; i < fdCount; i++)
|
|
||||||
local_remaps[i].init ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool in_error()
|
bool in_error()
|
||||||
|
@ -548,15 +504,9 @@ struct subr_remaps_t
|
||||||
|
|
||||||
void create (subr_closures_t& closures)
|
void create (subr_closures_t& closures)
|
||||||
{
|
{
|
||||||
global_remap.create (closures.global_closure);
|
global_remap.create (&closures.global_closure);
|
||||||
for (unsigned int i = 0; i < local_remaps.length; i++)
|
for (unsigned int i = 0; i < local_remaps.length; i++)
|
||||||
local_remaps[i].create (closures.local_closures[i]);
|
local_remaps[i].create (&closures.local_closures[i]);
|
||||||
}
|
|
||||||
|
|
||||||
void fini ()
|
|
||||||
{
|
|
||||||
global_remap.fini ();
|
|
||||||
local_remaps.fini_deep ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
subr_remap_t global_remap;
|
subr_remap_t global_remap;
|
||||||
|
@ -567,21 +517,8 @@ template <typename SUBSETTER, typename SUBRS, typename ACC, typename ENV, typena
|
||||||
struct subr_subsetter_t
|
struct subr_subsetter_t
|
||||||
{
|
{
|
||||||
subr_subsetter_t (ACC &acc_, const hb_subset_plan_t *plan_)
|
subr_subsetter_t (ACC &acc_, const hb_subset_plan_t *plan_)
|
||||||
: acc (acc_), plan (plan_)
|
: acc (acc_), plan (plan_), closures(acc_.fdCount), remaps(acc_.fdCount)
|
||||||
{
|
{}
|
||||||
parsed_charstrings.init ();
|
|
||||||
parsed_global_subrs.init ();
|
|
||||||
parsed_local_subrs.init ();
|
|
||||||
}
|
|
||||||
|
|
||||||
~subr_subsetter_t ()
|
|
||||||
{
|
|
||||||
closures.fini ();
|
|
||||||
remaps.fini ();
|
|
||||||
parsed_charstrings.fini_deep ();
|
|
||||||
parsed_global_subrs.fini_deep ();
|
|
||||||
parsed_local_subrs.fini_deep ();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Subroutine subsetting with --no-desubroutinize runs in phases:
|
/* Subroutine subsetting with --no-desubroutinize runs in phases:
|
||||||
*
|
*
|
||||||
|
@ -599,11 +536,8 @@ struct subr_subsetter_t
|
||||||
*/
|
*/
|
||||||
bool subset (void)
|
bool subset (void)
|
||||||
{
|
{
|
||||||
closures.init (acc.fdCount);
|
parsed_charstrings.resize (plan->num_output_glyphs ());
|
||||||
remaps.init (acc.fdCount);
|
parsed_global_subrs.resize (acc.globalSubrs->count);
|
||||||
|
|
||||||
parsed_charstrings.init (plan->num_output_glyphs ());
|
|
||||||
parsed_global_subrs.init (acc.globalSubrs->count);
|
|
||||||
|
|
||||||
if (unlikely (remaps.in_error()
|
if (unlikely (remaps.in_error()
|
||||||
|| parsed_charstrings.in_error ()
|
|| parsed_charstrings.in_error ()
|
||||||
|
@ -615,7 +549,7 @@ struct subr_subsetter_t
|
||||||
|
|
||||||
for (unsigned int i = 0; i < acc.fdCount; i++)
|
for (unsigned int i = 0; i < acc.fdCount; i++)
|
||||||
{
|
{
|
||||||
parsed_local_subrs[i].init (acc.privateDicts[i].localSubrs->count);
|
parsed_local_subrs[i].resize (acc.privateDicts[i].localSubrs->count);
|
||||||
if (unlikely (parsed_local_subrs[i].in_error ())) return false;
|
if (unlikely (parsed_local_subrs[i].in_error ())) return false;
|
||||||
}
|
}
|
||||||
if (unlikely (!closures.valid))
|
if (unlikely (!closures.valid))
|
||||||
|
@ -638,7 +572,7 @@ struct subr_subsetter_t
|
||||||
subr_subset_param_t param;
|
subr_subset_param_t param;
|
||||||
param.init (&parsed_charstrings[i],
|
param.init (&parsed_charstrings[i],
|
||||||
&parsed_global_subrs, &parsed_local_subrs[fd],
|
&parsed_global_subrs, &parsed_local_subrs[fd],
|
||||||
closures.global_closure, closures.local_closures[fd],
|
&closures.global_closure, &closures.local_closures[fd],
|
||||||
plan->flags & HB_SUBSET_FLAGS_NO_HINTING);
|
plan->flags & HB_SUBSET_FLAGS_NO_HINTING);
|
||||||
|
|
||||||
if (unlikely (!interp.interpret (param)))
|
if (unlikely (!interp.interpret (param)))
|
||||||
|
@ -662,7 +596,7 @@ struct subr_subsetter_t
|
||||||
subr_subset_param_t param;
|
subr_subset_param_t param;
|
||||||
param.init (&parsed_charstrings[i],
|
param.init (&parsed_charstrings[i],
|
||||||
&parsed_global_subrs, &parsed_local_subrs[fd],
|
&parsed_global_subrs, &parsed_local_subrs[fd],
|
||||||
closures.global_closure, closures.local_closures[fd],
|
&closures.global_closure, &closures.local_closures[fd],
|
||||||
plan->flags & HB_SUBSET_FLAGS_NO_HINTING);
|
plan->flags & HB_SUBSET_FLAGS_NO_HINTING);
|
||||||
|
|
||||||
drop_hints_param_t drop;
|
drop_hints_param_t drop;
|
||||||
|
@ -687,7 +621,7 @@ struct subr_subsetter_t
|
||||||
subr_subset_param_t param;
|
subr_subset_param_t param;
|
||||||
param.init (&parsed_charstrings[i],
|
param.init (&parsed_charstrings[i],
|
||||||
&parsed_global_subrs, &parsed_local_subrs[fd],
|
&parsed_global_subrs, &parsed_local_subrs[fd],
|
||||||
closures.global_closure, closures.local_closures[fd],
|
&closures.global_closure, &closures.local_closures[fd],
|
||||||
plan->flags & HB_SUBSET_FLAGS_NO_HINTING);
|
plan->flags & HB_SUBSET_FLAGS_NO_HINTING);
|
||||||
collect_subr_refs_in_str (parsed_charstrings[i], param);
|
collect_subr_refs_in_str (parsed_charstrings[i], param);
|
||||||
}
|
}
|
||||||
|
|
|
@ -362,43 +362,11 @@ struct cff1_subr_subsetter_t : subr_subsetter_t<cff1_subr_subsetter_t, CFF1Subrs
|
||||||
|
|
||||||
struct cff_subset_plan {
|
struct cff_subset_plan {
|
||||||
cff_subset_plan ()
|
cff_subset_plan ()
|
||||||
: info (),
|
|
||||||
orig_fdcount (0),
|
|
||||||
subset_fdcount (1),
|
|
||||||
subset_fdselect_format (0),
|
|
||||||
drop_hints (false),
|
|
||||||
desubroutinize(false)
|
|
||||||
{
|
{
|
||||||
topdict_mod.init ();
|
|
||||||
subset_fdselect_ranges.init ();
|
|
||||||
fdmap.init ();
|
|
||||||
subset_charstrings.init ();
|
|
||||||
subset_globalsubrs.init ();
|
|
||||||
subset_localsubrs.init ();
|
|
||||||
fontdicts_mod.init ();
|
|
||||||
subset_enc_code_ranges.init ();
|
|
||||||
subset_enc_supp_codes.init ();
|
|
||||||
subset_charset_ranges.init ();
|
|
||||||
sidmap.init ();
|
|
||||||
for (unsigned int i = 0; i < name_dict_values_t::ValCount; i++)
|
for (unsigned int i = 0; i < name_dict_values_t::ValCount; i++)
|
||||||
topDictModSIDs[i] = CFF_UNDEF_SID;
|
topDictModSIDs[i] = CFF_UNDEF_SID;
|
||||||
}
|
}
|
||||||
|
|
||||||
~cff_subset_plan ()
|
|
||||||
{
|
|
||||||
topdict_mod.fini ();
|
|
||||||
subset_fdselect_ranges.fini ();
|
|
||||||
fdmap.fini ();
|
|
||||||
subset_charstrings.fini_deep ();
|
|
||||||
subset_globalsubrs.fini_deep ();
|
|
||||||
subset_localsubrs.fini_deep ();
|
|
||||||
fontdicts_mod.fini ();
|
|
||||||
subset_enc_code_ranges.fini ();
|
|
||||||
subset_enc_supp_codes.fini ();
|
|
||||||
subset_charset_ranges.fini ();
|
|
||||||
sidmap.fini ();
|
|
||||||
}
|
|
||||||
|
|
||||||
void plan_subset_encoding (const OT::cff1::accelerator_subset_t &acc, hb_subset_plan_t *plan)
|
void plan_subset_encoding (const OT::cff1::accelerator_subset_t &acc, hb_subset_plan_t *plan)
|
||||||
{
|
{
|
||||||
const Encoding *encoding = acc.encoding;
|
const Encoding *encoding = acc.encoding;
|
||||||
|
@ -672,9 +640,9 @@ struct cff_subset_plan {
|
||||||
cff1_sub_table_info_t info;
|
cff1_sub_table_info_t info;
|
||||||
|
|
||||||
unsigned int num_glyphs;
|
unsigned int num_glyphs;
|
||||||
unsigned int orig_fdcount;
|
unsigned int orig_fdcount = 0;
|
||||||
unsigned int subset_fdcount;
|
unsigned int subset_fdcount = 1;
|
||||||
unsigned int subset_fdselect_format;
|
unsigned int subset_fdselect_format = 0;
|
||||||
hb_vector_t<code_pair_t> subset_fdselect_ranges;
|
hb_vector_t<code_pair_t> subset_fdselect_ranges;
|
||||||
|
|
||||||
/* font dict index remap table from fullset FDArray to subset FDArray.
|
/* font dict index remap table from fullset FDArray to subset FDArray.
|
||||||
|
@ -686,7 +654,7 @@ struct cff_subset_plan {
|
||||||
hb_vector_t<str_buff_vec_t> subset_localsubrs;
|
hb_vector_t<str_buff_vec_t> subset_localsubrs;
|
||||||
hb_vector_t<cff1_font_dict_values_mod_t> fontdicts_mod;
|
hb_vector_t<cff1_font_dict_values_mod_t> fontdicts_mod;
|
||||||
|
|
||||||
bool drop_hints;
|
bool drop_hints = false;
|
||||||
|
|
||||||
bool gid_renum;
|
bool gid_renum;
|
||||||
bool subset_encoding;
|
bool subset_encoding;
|
||||||
|
@ -702,7 +670,7 @@ struct cff_subset_plan {
|
||||||
remap_sid_t sidmap;
|
remap_sid_t sidmap;
|
||||||
unsigned int topDictModSIDs[name_dict_values_t::ValCount];
|
unsigned int topDictModSIDs[name_dict_values_t::ValCount];
|
||||||
|
|
||||||
bool desubroutinize;
|
bool desubroutinize = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool _serialize_cff1 (hb_serialize_context_t *c,
|
static bool _serialize_cff1 (hb_serialize_context_t *c,
|
||||||
|
|
|
@ -233,29 +233,6 @@ struct cff2_subr_subsetter_t : subr_subsetter_t<cff2_subr_subsetter_t, CFF2Subrs
|
||||||
};
|
};
|
||||||
|
|
||||||
struct cff2_subset_plan {
|
struct cff2_subset_plan {
|
||||||
cff2_subset_plan ()
|
|
||||||
: orig_fdcount (0),
|
|
||||||
subset_fdcount(1),
|
|
||||||
subset_fdselect_size (0),
|
|
||||||
subset_fdselect_format (0),
|
|
||||||
drop_hints (false),
|
|
||||||
desubroutinize (false)
|
|
||||||
{
|
|
||||||
subset_fdselect_ranges.init ();
|
|
||||||
fdmap.init ();
|
|
||||||
subset_charstrings.init ();
|
|
||||||
subset_globalsubrs.init ();
|
|
||||||
subset_localsubrs.init ();
|
|
||||||
}
|
|
||||||
|
|
||||||
~cff2_subset_plan ()
|
|
||||||
{
|
|
||||||
subset_fdselect_ranges.fini ();
|
|
||||||
fdmap.fini ();
|
|
||||||
subset_charstrings.fini_deep ();
|
|
||||||
subset_globalsubrs.fini_deep ();
|
|
||||||
subset_localsubrs.fini_deep ();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool create (const OT::cff2::accelerator_subset_t &acc,
|
bool create (const OT::cff2::accelerator_subset_t &acc,
|
||||||
hb_subset_plan_t *plan)
|
hb_subset_plan_t *plan)
|
||||||
|
@ -320,10 +297,10 @@ struct cff2_subset_plan {
|
||||||
|
|
||||||
cff2_sub_table_info_t info;
|
cff2_sub_table_info_t info;
|
||||||
|
|
||||||
unsigned int orig_fdcount;
|
unsigned int orig_fdcount = 0;
|
||||||
unsigned int subset_fdcount;
|
unsigned int subset_fdcount = 1;
|
||||||
unsigned int subset_fdselect_size;
|
unsigned int subset_fdselect_size = 0;
|
||||||
unsigned int subset_fdselect_format;
|
unsigned int subset_fdselect_format = 0;
|
||||||
hb_vector_t<code_pair_t> subset_fdselect_ranges;
|
hb_vector_t<code_pair_t> subset_fdselect_ranges;
|
||||||
|
|
||||||
hb_inc_bimap_t fdmap;
|
hb_inc_bimap_t fdmap;
|
||||||
|
@ -332,8 +309,8 @@ struct cff2_subset_plan {
|
||||||
str_buff_vec_t subset_globalsubrs;
|
str_buff_vec_t subset_globalsubrs;
|
||||||
hb_vector_t<str_buff_vec_t> subset_localsubrs;
|
hb_vector_t<str_buff_vec_t> subset_localsubrs;
|
||||||
|
|
||||||
bool drop_hints;
|
bool drop_hints = false;
|
||||||
bool desubroutinize;
|
bool desubroutinize = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
static bool _serialize_cff2 (hb_serialize_context_t *c,
|
static bool _serialize_cff2 (hb_serialize_context_t *c,
|
||||||
|
|
|
@ -86,13 +86,6 @@ struct hb_vector_t
|
||||||
hb_free (arrayZ);
|
hb_free (arrayZ);
|
||||||
init ();
|
init ();
|
||||||
}
|
}
|
||||||
void fini_deep ()
|
|
||||||
{
|
|
||||||
unsigned int count = length;
|
|
||||||
for (unsigned int i = 0; i < count; i++)
|
|
||||||
arrayZ[i].fini ();
|
|
||||||
fini ();
|
|
||||||
}
|
|
||||||
|
|
||||||
void reset ()
|
void reset ()
|
||||||
{
|
{
|
||||||
|
@ -193,6 +186,7 @@ struct hb_vector_t
|
||||||
template <typename T>
|
template <typename T>
|
||||||
Type *push (T&& v)
|
Type *push (T&& v)
|
||||||
{
|
{
|
||||||
|
/* TODO Emplace? */
|
||||||
Type *p = push ();
|
Type *p = push ();
|
||||||
if (p == &Crap (Type))
|
if (p == &Crap (Type))
|
||||||
// If push failed to allocate then don't copy v, since this may cause
|
// If push failed to allocate then don't copy v, since this may cause
|
||||||
|
|
Loading…
Reference in New Issue