提交 4e1abe2c 编写于 作者: G Garret Rieger 提交者: Behdad Esfahbod

Refactor subset glyf to remove multiple calls to glyf.fini()

上级 0a5d1440
......@@ -74,46 +74,30 @@ write_glyf_prime (const OT::glyf::accelerator_t &glyf,
return true;
}
/**
* hb_subset_glyf:
* Subsets the glyph table according to a provided plan.
*
* Return value: subsetted glyf table.
*
* Since: 1.7.5
**/
bool
hb_subset_glyf (hb_subset_plan_t *plan,
hb_face_t *face,
hb_blob_t **glyf_prime /* OUT */)
_hb_subset_glyf (const OT::glyf::accelerator_t &glyf,
const char *glyf_data,
hb_set_t *glyphs_to_retain,
hb_blob_t **glyf_prime /* OUT */)
{
// TODO(grieger): Sanity check writes to make sure they are in-bounds.
// TODO(grieger): Sanity check allocation size for the new table.
// TODO(grieger): Subset loca simultaneously.
hb_blob_t *glyf_blob = OT::Sanitizer<OT::glyf>().sanitize (face->reference_table (HB_OT_TAG_glyf));
const char *glyf_data = hb_blob_get_data(glyf_blob, nullptr);
OT::glyf::accelerator_t glyf;
glyf.init(face);
unsigned int glyf_prime_size;
if (!calculate_glyf_prime_size (glyf,
plan->glyphs_to_retain,
glyphs_to_retain,
&glyf_prime_size)) {
glyf.fini();
return false;
}
char *glyf_prime_data = (char *) calloc (glyf_prime_size, 1);
if (!write_glyf_prime (glyf, glyf_data, plan->glyphs_to_retain, glyf_prime_size,
if (!write_glyf_prime (glyf, glyf_data, glyphs_to_retain, glyf_prime_size,
glyf_prime_data)) {
glyf.fini();
free (glyf_prime_data);
return false;
}
glyf.fini();
*glyf_prime = hb_blob_create (glyf_prime_data,
glyf_prime_size,
HB_MEMORY_MODE_READONLY,
......@@ -121,3 +105,27 @@ hb_subset_glyf (hb_subset_plan_t *plan,
free);
return true;
}
/**
* hb_subset_glyf:
* Subsets the glyph table according to a provided plan.
*
* Return value: subsetted glyf table.
*
* Since: 1.7.5
**/
bool
hb_subset_glyf (hb_subset_plan_t *plan,
hb_face_t *face,
hb_blob_t **glyf_prime /* OUT */)
{
hb_blob_t *glyf_blob = OT::Sanitizer<OT::glyf>().sanitize (face->reference_table (HB_OT_TAG_glyf));
const char *glyf_data = hb_blob_get_data(glyf_blob, nullptr);
OT::glyf::accelerator_t glyf;
glyf.init(face);
bool result = _hb_subset_glyf (glyf, glyf_data, plan->glyphs_to_retain, glyf_prime);
glyf.fini();
return result;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册