[cff] minor format (#1774)
This commit is contained in:
parent
4f37c0db9b
commit
6bcbe495bf
|
@ -44,18 +44,18 @@ using namespace CFF;
|
|||
|
||||
bool
|
||||
hb_plan_subset_cff_fdselect (const hb_subset_plan_t *plan,
|
||||
unsigned int fdCount,
|
||||
const FDSelect &src, /* IN */
|
||||
unsigned int &subset_fd_count /* OUT */,
|
||||
unsigned int &subset_fdselect_size /* OUT */,
|
||||
unsigned int &subset_fdselect_format /* OUT */,
|
||||
hb_vector_t<code_pair_t> &fdselect_ranges /* OUT */,
|
||||
remap_t &fdmap /* OUT */)
|
||||
unsigned int fdCount,
|
||||
const FDSelect &src, /* IN */
|
||||
unsigned int &subset_fd_count /* OUT */,
|
||||
unsigned int &subset_fdselect_size /* OUT */,
|
||||
unsigned int &subset_fdselect_format /* OUT */,
|
||||
hb_vector_t<code_pair_t> &fdselect_ranges /* OUT */,
|
||||
remap_t &fdmap /* OUT */)
|
||||
{
|
||||
subset_fd_count = 0;
|
||||
subset_fdselect_size = 0;
|
||||
subset_fdselect_format = 0;
|
||||
unsigned int num_ranges = 0;
|
||||
unsigned int num_ranges = 0;
|
||||
|
||||
unsigned int subset_num_glyphs = plan->num_output_glyphs ();
|
||||
if (subset_num_glyphs == 0)
|
||||
|
@ -63,14 +63,14 @@ hb_plan_subset_cff_fdselect (const hb_subset_plan_t *plan,
|
|||
|
||||
{
|
||||
/* use hb_set to determine the subset of font dicts */
|
||||
hb_set_t *set = hb_set_create ();
|
||||
hb_set_t *set = hb_set_create ();
|
||||
if (set == &Null (hb_set_t))
|
||||
return false;
|
||||
hb_codepoint_t prev_fd = CFF_UNDEF_CODE;
|
||||
hb_codepoint_t prev_fd = CFF_UNDEF_CODE;
|
||||
for (hb_codepoint_t i = 0; i < subset_num_glyphs; i++)
|
||||
{
|
||||
hb_codepoint_t glyph;
|
||||
hb_codepoint_t fd;
|
||||
hb_codepoint_t glyph;
|
||||
hb_codepoint_t fd;
|
||||
if (!plan->old_gid_for_new_gid (i, &glyph))
|
||||
{
|
||||
/* fonttools retains FDSelect & font dicts for missing glyphs. do the same */
|
||||
|
@ -104,7 +104,7 @@ hb_plan_subset_cff_fdselect (const hb_subset_plan_t *plan,
|
|||
return false;
|
||||
}
|
||||
|
||||
hb_codepoint_t fd = CFF_UNDEF_CODE;
|
||||
hb_codepoint_t fd = CFF_UNDEF_CODE;
|
||||
while (set->next (&fd))
|
||||
fdmap.add (fd);
|
||||
hb_set_destroy (set);
|
||||
|
@ -152,10 +152,10 @@ hb_plan_subset_cff_fdselect (const hb_subset_plan_t *plan,
|
|||
template <typename FDSELECT3_4>
|
||||
static inline bool
|
||||
serialize_fdselect_3_4 (hb_serialize_context_t *c,
|
||||
const unsigned int num_glyphs,
|
||||
const FDSelect &src,
|
||||
unsigned int size,
|
||||
const hb_vector_t<code_pair_t> &fdselect_ranges)
|
||||
const unsigned int num_glyphs,
|
||||
const FDSelect &src,
|
||||
unsigned int size,
|
||||
const hb_vector_t<code_pair_t> &fdselect_ranges)
|
||||
{
|
||||
TRACE_SERIALIZE (this);
|
||||
FDSELECT3_4 *p = c->allocate_size<FDSELECT3_4> (size);
|
||||
|
@ -166,7 +166,7 @@ serialize_fdselect_3_4 (hb_serialize_context_t *c,
|
|||
p->ranges[i].first = fdselect_ranges[i].glyph;
|
||||
p->ranges[i].fd = fdselect_ranges[i].code;
|
||||
}
|
||||
p->sentinel() = num_glyphs;
|
||||
p->sentinel () = num_glyphs;
|
||||
return_trace (true);
|
||||
}
|
||||
|
||||
|
@ -176,15 +176,15 @@ serialize_fdselect_3_4 (hb_serialize_context_t *c,
|
|||
**/
|
||||
bool
|
||||
hb_serialize_cff_fdselect (hb_serialize_context_t *c,
|
||||
const unsigned int num_glyphs,
|
||||
const FDSelect &src,
|
||||
unsigned int fd_count,
|
||||
unsigned int fdselect_format,
|
||||
unsigned int size,
|
||||
const hb_vector_t<code_pair_t> &fdselect_ranges)
|
||||
const unsigned int num_glyphs,
|
||||
const FDSelect &src,
|
||||
unsigned int fd_count,
|
||||
unsigned int fdselect_format,
|
||||
unsigned int size,
|
||||
const hb_vector_t<code_pair_t> &fdselect_ranges)
|
||||
{
|
||||
TRACE_SERIALIZE (this);
|
||||
FDSelect *p = c->allocate_min<FDSelect> ();
|
||||
FDSelect *p = c->allocate_min<FDSelect> ();
|
||||
if (unlikely (p == nullptr)) return_trace (false);
|
||||
p->format = fdselect_format;
|
||||
size -= FDSelect::min_size;
|
||||
|
@ -192,42 +192,34 @@ hb_serialize_cff_fdselect (hb_serialize_context_t *c,
|
|||
switch (fdselect_format)
|
||||
{
|
||||
#if CFF_SERIALIZE_FDSELECT_0
|
||||
case 0:
|
||||
case 0:
|
||||
{
|
||||
FDSelect0 *p = c->allocate_size<FDSelect0> (size);
|
||||
if (unlikely (p == nullptr)) return_trace (false);
|
||||
unsigned int range_index = 0;
|
||||
unsigned int fd = fdselect_ranges[range_index++].code;
|
||||
for (unsigned int i = 0; i < num_glyphs; i++)
|
||||
{
|
||||
FDSelect0 *p = c->allocate_size<FDSelect0> (size);
|
||||
if (unlikely (p == nullptr)) return_trace (false);
|
||||
unsigned int range_index = 0;
|
||||
unsigned int fd = fdselect_ranges[range_index++].code;
|
||||
for (unsigned int i = 0; i < num_glyphs; i++)
|
||||
if ((range_index < fdselect_ranges.len) &&
|
||||
(i >= fdselect_ranges[range_index].glyph))
|
||||
{
|
||||
if ((range_index < fdselect_ranges.len) &&
|
||||
(i >= fdselect_ranges[range_index].glyph))
|
||||
{
|
||||
fd = fdselect_ranges[range_index++].code;
|
||||
}
|
||||
p->fds[i] = fd;
|
||||
fd = fdselect_ranges[range_index++].code;
|
||||
}
|
||||
break;
|
||||
p->fds[i] = fd;
|
||||
}
|
||||
return_trace (true);
|
||||
}
|
||||
#endif /* CFF_SERIALIZE_FDSELECT_0 */
|
||||
|
||||
case 3:
|
||||
return serialize_fdselect_3_4<FDSelect3> (c,
|
||||
num_glyphs,
|
||||
src,
|
||||
size,
|
||||
fdselect_ranges);
|
||||
case 3:
|
||||
return serialize_fdselect_3_4<FDSelect3> (c, num_glyphs, src,
|
||||
size, fdselect_ranges);
|
||||
|
||||
case 4:
|
||||
return serialize_fdselect_3_4<FDSelect4> (c,
|
||||
num_glyphs,
|
||||
src,
|
||||
size,
|
||||
fdselect_ranges);
|
||||
case 4:
|
||||
return serialize_fdselect_3_4<FDSelect4> (c, num_glyphs, src,
|
||||
size, fdselect_ranges);
|
||||
|
||||
default:
|
||||
return_trace (false);
|
||||
default:
|
||||
return_trace (false);
|
||||
}
|
||||
|
||||
return_trace (true);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue