mirror of
https://github.com/harfbuzz/harfbuzz.git
synced 2025-04-15 01:18:13 +00:00
[instancer] change optimize() to as_item_varstore()
which allows another option to skip optimization
This commit is contained in:
parent
97d0e7a19f
commit
e81ad14dba
3 changed files with 23 additions and 4 deletions
|
@ -1922,8 +1922,9 @@ struct item_variations_t
|
|||
return (!region_list.in_error ()) && (!region_map.in_error ());
|
||||
}
|
||||
|
||||
/* main algorithm ported from fonttools VarStore_optimize() method */
|
||||
bool optimize (bool use_no_variation_idx=true)
|
||||
/* main algorithm ported from fonttools VarStore_optimize() method, optimize
|
||||
* varstore by default */
|
||||
bool as_item_varstore (bool optimize=true, bool use_no_variation_idx=true)
|
||||
{
|
||||
unsigned num_cols = region_list.length;
|
||||
/* pre-alloc a 2D vector for all sub_table's VarData rows */
|
||||
|
@ -1973,6 +1974,19 @@ struct item_variations_t
|
|||
}
|
||||
}
|
||||
|
||||
if (!optimize)
|
||||
{
|
||||
/* assemble a delta_row_encoding_t for this subtable, skip optimization so
|
||||
* chars is not initialized, we only need delta rows for serialization */
|
||||
delta_row_encoding_t obj;
|
||||
for (unsigned r = start_row; r < start_row + num_rows; r++)
|
||||
obj.add_row (&(delta_rows.arrayZ[r]));
|
||||
|
||||
encodings.push (std::move (obj));
|
||||
start_row += num_rows;
|
||||
continue;
|
||||
}
|
||||
|
||||
for (unsigned minor = 0; minor < num_rows; minor++)
|
||||
{
|
||||
const hb_vector_t<int>& row = delta_rows[start_row + minor];
|
||||
|
@ -2019,6 +2033,11 @@ struct item_variations_t
|
|||
|
||||
start_row += num_rows;
|
||||
}
|
||||
|
||||
/* return directly if no optimization, maintain original VariationIndex so
|
||||
* varidx_map would be empty */
|
||||
if (!optimize) return encodings.in_error ();
|
||||
|
||||
/* sort encoding_objs */
|
||||
encoding_objs.qsort ();
|
||||
|
||||
|
|
|
@ -111,7 +111,7 @@ struct MVAR
|
|||
if (!item_vars.instantiate (c->plan->axes_location, c->plan->axes_triple_distances))
|
||||
return_trace (false);
|
||||
|
||||
if (!item_vars.optimize ())
|
||||
if (!item_vars.as_item_varstore ())
|
||||
return_trace (false);
|
||||
|
||||
/* serialize varstore */
|
||||
|
|
|
@ -54,7 +54,7 @@ test_item_variations ()
|
|||
|
||||
result = item_vars.instantiate (normalized_axes_location, axes_triple_distances);
|
||||
assert (result);
|
||||
result = item_vars.optimize ();
|
||||
result = item_vars.as_item_varstore (false);
|
||||
assert (result);
|
||||
assert (item_vars.get_region_list().length == 8);
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue