back_map.fini ();
}
- /* returns HB_MAP_VALUE_INVALID if unmapped */
- hb_codepoint_t forward (hb_codepoint_t lhs) const { return forw_map[lhs]; }
- hb_codepoint_t backward (hb_codepoint_t rhs) const { return back_map[rhs]; }
+ void reset ()
+ {
+ forw_map.reset ();
+ back_map.reset ();
+ }
+
+ bool in_error () const { return forw_map.in_error () || back_map.in_error (); }
void set (hb_codepoint_t lhs, hb_codepoint_t rhs)
{
back_map.set (rhs, lhs);
}
- /* Create an identity map. */
- bool identity (unsigned int size)
+ hb_codepoint_t get (hb_codepoint_t lhs) const { return forw_map.get (lhs); }
+ hb_codepoint_t backward (hb_codepoint_t rhs) const { return back_map[rhs]; }
+
+ hb_codepoint_t operator [] (hb_codepoint_t lhs) const { return get (lhs); }
+ bool has (hb_codepoint_t lhs, hb_codepoint_t *vp = nullptr) const { return forw_map.has (lhs, vp); }
+
+ void del (hb_codepoint_t lhs)
{
- clear ();
- for (hb_codepoint_t i = 0; i < size; i++) set (i, i);
- return forw_map.successful && back_map.successful;
+ back_map.del (get (lhs));
+ forw_map.del (lhs);
}
void clear ()
back_map.clear ();
}
- void reset ()
- {
- forw_map.reset ();
- back_map.reset ();
- }
+ bool is_empty () const { return get_population () == 0; }
unsigned int get_population () const { return forw_map.get_population (); }
return rhs;
}
- bool has (hb_codepoint_t lhs) const { return forw_map.has (lhs); }
+ /* Create an identity map. */
+ bool identity (unsigned int size)
+ {
+ clear ();
+ for (hb_codepoint_t i = 0; i < size; i++) set (i, i);
+ return !in_error ();
+ }
protected:
static int cmp_id (const void* a, const void* b)
if (fdmap.has (i))
{
FontDict *dict = c->start_embed<FontDict> ();
- if (unlikely (!dict->serialize (c, fontDicts[i], opszr, privateInfos[fdmap.forward (i)])))
+ if (unlikely (!dict->serialize (c, fontDicts[i], opszr, privateInfos[fdmap[i]])))
return_trace (false);
}
return_trace (true);
return_trace (false);
for (unsigned int i = 0; i < strings.count; i++)
{
- hb_codepoint_t j = sidmap.forward (i);
+ hb_codepoint_t j = sidmap[i];
if (j != CFF_UNDEF_CODE)
bytesArray[j] = strings[i];
}
unsigned int dataSize = 0;
for (unsigned int i = 0; i < count; i++)
- if (sidmap.forward (i) != CFF_UNDEF_CODE)
+ if (sidmap[i] != CFF_UNDEF_CODE)
dataSize += length_at (i);
offSize_ = calcOffSize(dataSize);
/* update each font dict index stored as "code" in fdselect_ranges */
for (unsigned int i = 0; i < fdselect_ranges.length; i++)
- fdselect_ranges[i].code = fdmap.forward (fdselect_ranges[i].code);
+ fdselect_ranges[i].code = fdmap[fdselect_ranges[i].code];
}
/* determine which FDSelect format is most compact */
int biased_num (unsigned int old_num) const
{
- hb_codepoint_t new_num = forward (old_num);
+ hb_codepoint_t new_num = get (old_num);
return (int)new_num - bias;
}
return false;
for (unsigned int old_num = 0; old_num < subrs.length; old_num++)
{
- hb_codepoint_t new_num = remap.forward (old_num);
+ hb_codepoint_t new_num = remap[old_num];
if (new_num != CFF_UNDEF_CODE)
{
if (unlikely (!encode_str (subrs[old_num], fd, buffArray[new_num])))
if (is_std_std (sid) || (sid == CFF_UNDEF_SID))
return sid;
else
- return offset_sid (forward (unoffset_sid (sid)));
+ return offset_sid (get (unoffset_sid (sid)));
}
static const unsigned int num_std_strings = 391;
{
PrivateDict *pd = c.start_embed<PrivateDict> ();
if (unlikely (pd == nullptr)) return false;
- unsigned int priv_size = plan.fontdicts_mod[plan.fdmap.forward (i)].privateDictInfo.size;
+ unsigned int priv_size = plan.fontdicts_mod[plan.fdmap[i]].privateDictInfo.size;
bool result;
cff_private_dict_op_serializer_t privSzr (plan.desubroutinize, plan.drop_hints);
/* N.B. local subrs immediately follows its corresponding private dict. i.e., subr offset == private dict size */
{
PrivateDict *pd = c.start_embed<PrivateDict> ();
if (unlikely (pd == nullptr)) return false;
- unsigned int priv_size = plan.privateDictInfos[plan.fdmap.forward (i)].size;
+ unsigned int priv_size = plan.privateDictInfos[plan.fdmap[i]].size;
bool result;
cff_private_dict_op_serializer_t privSzr (plan.desubroutinize, plan.drop_hints);
/* N.B. local subrs immediately follows its corresponding private dict. i.e., subr offset == private dict size */