Cleanups in hb-subset-glyf and hb-subset-plan.
This commit is contained in:
parent
13193a9b97
commit
217ed5e3c8
|
@ -30,15 +30,15 @@
|
||||||
#include "hb-subset-glyf.hh"
|
#include "hb-subset-glyf.hh"
|
||||||
|
|
||||||
bool
|
bool
|
||||||
calculate_glyf_prime_size (const OT::glyf::accelerator_t &glyf,
|
_calculate_glyf_prime_size (const OT::glyf::accelerator_t &glyf,
|
||||||
hb_set_t *glyph_ids,
|
hb_set_t *glyph_ids,
|
||||||
unsigned int *size /* OUT */)
|
unsigned int *size /* OUT */)
|
||||||
{
|
{
|
||||||
unsigned int total = 0;
|
unsigned int total = 0;
|
||||||
hb_codepoint_t next_glyph = -1;
|
hb_codepoint_t next_glyph = -1;
|
||||||
while (hb_set_next(glyph_ids, &next_glyph)) {
|
while (hb_set_next(glyph_ids, &next_glyph)) {
|
||||||
unsigned int start_offset, end_offset;
|
unsigned int start_offset, end_offset;
|
||||||
if (!glyf.get_offsets (next_glyph, &start_offset, &end_offset)) {
|
if (unlikely (!glyf.get_offsets (next_glyph, &start_offset, &end_offset))) {
|
||||||
*size = 0;
|
*size = 0;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -51,18 +51,18 @@ calculate_glyf_prime_size (const OT::glyf::accelerator_t &glyf,
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
bool
|
||||||
write_glyf_prime (const OT::glyf::accelerator_t &glyf,
|
_write_glyf_prime (const OT::glyf::accelerator_t &glyf,
|
||||||
const char *glyf_data,
|
const char *glyf_data,
|
||||||
hb_set_t *glyph_ids,
|
hb_set_t *glyph_ids,
|
||||||
int glyf_prime_size,
|
int glyf_prime_size,
|
||||||
char *glyf_prime_data /* OUT */)
|
char *glyf_prime_data /* OUT */)
|
||||||
{
|
{
|
||||||
char *glyf_prime_data_next = glyf_prime_data;
|
char *glyf_prime_data_next = glyf_prime_data;
|
||||||
|
|
||||||
hb_codepoint_t next_glyph = -1;
|
hb_codepoint_t next_glyph = -1;
|
||||||
while (hb_set_next(glyph_ids, &next_glyph)) {
|
while (hb_set_next(glyph_ids, &next_glyph)) {
|
||||||
unsigned int start_offset, end_offset;
|
unsigned int start_offset, end_offset;
|
||||||
if (!glyf.get_offsets (next_glyph, &start_offset, &end_offset)) {
|
if (unlikely (!glyf.get_offsets (next_glyph, &start_offset, &end_offset))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,15 +85,15 @@ _hb_subset_glyf (const OT::glyf::accelerator_t &glyf,
|
||||||
// TODO(grieger): Subset loca simultaneously.
|
// TODO(grieger): Subset loca simultaneously.
|
||||||
|
|
||||||
unsigned int glyf_prime_size;
|
unsigned int glyf_prime_size;
|
||||||
if (!calculate_glyf_prime_size (glyf,
|
if (unlikely (!_calculate_glyf_prime_size (glyf,
|
||||||
glyphs_to_retain,
|
glyphs_to_retain,
|
||||||
&glyf_prime_size)) {
|
&glyf_prime_size))) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
char *glyf_prime_data = (char *) calloc (glyf_prime_size, 1);
|
char *glyf_prime_data = (char *) calloc (glyf_prime_size, 1);
|
||||||
if (!write_glyf_prime (glyf, glyf_data, glyphs_to_retain, glyf_prime_size,
|
if (unlikely (!_write_glyf_prime (glyf, glyf_data, glyphs_to_retain, glyf_prime_size,
|
||||||
glyf_prime_data)) {
|
glyf_prime_data))) {
|
||||||
free (glyf_prime_data);
|
free (glyf_prime_data);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,4 +55,4 @@ hb_subset_plan_get_empty ();
|
||||||
void
|
void
|
||||||
hb_subset_plan_destroy (hb_subset_plan_t *plan);
|
hb_subset_plan_destroy (hb_subset_plan_t *plan);
|
||||||
|
|
||||||
#endif /* HB_SUBSET_PLAN_PRIVATE_HH */
|
#endif /* HB_SUBSET_PLAN_HH */
|
||||||
|
|
Loading…
Reference in New Issue