fix CFF2 local subr subsetting

bug exposed by impl change of fdmap
also fixed name of subr_remap_ts as subr_remaps_t
This commit is contained in:
Michiharu Ariza 2019-02-21 16:34:49 -08:00
parent a190140fa4
commit a7b801f6d1
2 changed files with 13 additions and 15 deletions

View File

@ -572,15 +572,15 @@ struct subr_remap_t : hb_map2_t
int bias; int bias;
}; };
struct subr_remap_ts struct subr_remaps_t
{ {
subr_remap_ts () subr_remaps_t ()
{ {
global_remap.init (); global_remap.init ();
local_remaps.init (); local_remaps.init ();
} }
~subr_remap_ts () { fini (); } ~subr_remaps_t () { fini (); }
void init (unsigned int fdCount) void init (unsigned int fdCount)
{ {
@ -996,7 +996,7 @@ struct subr_subsetter_t
parsed_cs_str_vec_t parsed_global_subrs; parsed_cs_str_vec_t parsed_global_subrs;
hb_vector_t<parsed_cs_str_vec_t> parsed_local_subrs; hb_vector_t<parsed_cs_str_vec_t> parsed_local_subrs;
subr_remap_ts remaps; subr_remaps_t remaps;
private: private:
typedef typename SUBRS::count_type subr_count_type; typedef typename SUBRS::count_type subr_count_type;

View File

@ -326,18 +326,16 @@ struct cff2_subset_plan {
{ {
subset_localsubrs[fd].init (); subset_localsubrs[fd].init ();
offsets.localSubrsInfos[fd].init (); offsets.localSubrsInfos[fd].init ();
if (fdmap.has (fd))
{
if (!subr_subsetter.encode_localsubrs (fd, subset_localsubrs[fd]))
return false;
unsigned int dataSize = subset_localsubrs[fd].total_size (); if (!subr_subsetter.encode_localsubrs (fd, subset_localsubrs[fd]))
if (dataSize > 0) return false;
{
offsets.localSubrsInfos[fd].offset = final_size; unsigned int dataSize = subset_localsubrs[fd].total_size ();
offsets.localSubrsInfos[fd].offSize = calcOffSize (dataSize); if (dataSize > 0)
offsets.localSubrsInfos[fd].size = CFF2Subrs::calculate_serialized_size (offsets.localSubrsInfos[fd].offSize, subset_localsubrs[fd].length, dataSize); {
} offsets.localSubrsInfos[fd].offset = final_size;
offsets.localSubrsInfos[fd].offSize = calcOffSize (dataSize);
offsets.localSubrsInfos[fd].size = CFF2Subrs::calculate_serialized_size (offsets.localSubrsInfos[fd].offSize, subset_localsubrs[fd].length, dataSize);
} }
} }
} }