mirror of
https://github.com/harfbuzz/harfbuzz.git
synced 2025-04-13 00:32:59 +00:00
[subset/cff1] Use cached subset-accel for seac calculations
Before we were creating a new (non-subset) accel each time.
This commit is contained in:
parent
5f39913918
commit
c4b2950deb
4 changed files with 13 additions and 8 deletions
|
@ -574,11 +574,11 @@ bool OT::cff1::accelerator_t::get_path (hb_font_t *font, hb_codepoint_t glyph, h
|
|||
|
||||
struct get_seac_param_t
|
||||
{
|
||||
get_seac_param_t (const OT::cff1::accelerator_t *_cff) : cff (_cff) {}
|
||||
get_seac_param_t (const OT::cff1::accelerator_subset_t *_cff) : cff (_cff) {}
|
||||
|
||||
bool has_seac () const { return base && accent; }
|
||||
|
||||
const OT::cff1::accelerator_t *cff;
|
||||
const OT::cff1::accelerator_subset_t *cff;
|
||||
hb_codepoint_t base = 0;
|
||||
hb_codepoint_t accent = 0;
|
||||
};
|
||||
|
@ -596,7 +596,7 @@ struct cff1_cs_opset_seac_t : cff1_cs_opset_t<cff1_cs_opset_seac_t, get_seac_par
|
|||
}
|
||||
};
|
||||
|
||||
bool OT::cff1::accelerator_t::get_seac_components (hb_codepoint_t glyph, hb_codepoint_t *base, hb_codepoint_t *accent) const
|
||||
bool OT::cff1::accelerator_subset_t::get_seac_components (hb_codepoint_t glyph, hb_codepoint_t *base, hb_codepoint_t *accent) const
|
||||
{
|
||||
if (unlikely (!is_valid () || (glyph >= num_glyphs))) return false;
|
||||
|
||||
|
|
|
@ -1060,6 +1060,8 @@ struct cff1
|
|||
{
|
||||
accelerator_templ_t (hb_face_t *face)
|
||||
{
|
||||
if (!face) return;
|
||||
|
||||
topDict.init ();
|
||||
fontDicts.init ();
|
||||
privateDicts.init ();
|
||||
|
@ -1460,7 +1462,6 @@ struct cff1
|
|||
|
||||
HB_INTERNAL bool get_extents (hb_font_t *font, hb_codepoint_t glyph, hb_glyph_extents_t *extents) const;
|
||||
HB_INTERNAL bool paint_glyph (hb_font_t *font, hb_codepoint_t glyph, hb_paint_funcs_t *funcs, void *data, hb_color_t foreground) const;
|
||||
HB_INTERNAL bool get_seac_components (hb_codepoint_t glyph, hb_codepoint_t *base, hb_codepoint_t *accent) const;
|
||||
HB_INTERNAL bool get_path (hb_font_t *font, hb_codepoint_t glyph, hb_draw_session_t &draw_session) const;
|
||||
|
||||
private:
|
||||
|
@ -1499,6 +1500,7 @@ struct cff1
|
|||
HB_INTERNAL bool subset (hb_subset_context_t *c) const;
|
||||
HB_INTERNAL bool serialize (hb_serialize_context_t *c,
|
||||
struct cff1_subset_plan &plan) const;
|
||||
HB_INTERNAL bool get_seac_components (hb_codepoint_t glyph, hb_codepoint_t *base, hb_codepoint_t *accent) const;
|
||||
|
||||
mutable CFF::cff_subset_accelerator_t* cff_accelerator = nullptr;
|
||||
|
||||
|
|
|
@ -392,6 +392,8 @@ struct cff2
|
|||
{
|
||||
accelerator_templ_t (hb_face_t *face)
|
||||
{
|
||||
if (!face) return;
|
||||
|
||||
topDict.init ();
|
||||
fontDicts.init ();
|
||||
privateDicts.init ();
|
||||
|
|
|
@ -65,7 +65,7 @@ hb_subset_accelerator_t::~hb_subset_accelerator_t ()
|
|||
typedef hb_hashmap_t<unsigned, hb::unique_ptr<hb_set_t>> script_langsys_map;
|
||||
#ifndef HB_NO_SUBSET_CFF
|
||||
static inline bool
|
||||
_add_cff_seac_components (const OT::cff1::accelerator_t &cff,
|
||||
_add_cff_seac_components (const OT::cff1::accelerator_subset_t &cff,
|
||||
hb_codepoint_t gid,
|
||||
hb_set_t *gids_to_retain)
|
||||
{
|
||||
|
@ -703,7 +703,8 @@ _populate_gids_to_retain (hb_subset_plan_t* plan,
|
|||
{
|
||||
OT::glyf_accelerator_t glyf (plan->source);
|
||||
#ifndef HB_NO_SUBSET_CFF
|
||||
OT::cff1::accelerator_t cff (plan->source);
|
||||
OT::cff1::accelerator_subset_t stack_cff (plan->accelerator ? nullptr : plan->source);
|
||||
const OT::cff1::accelerator_subset_t *cff (plan->accelerator ? plan->accelerator->cff1_accel.get () : &stack_cff);
|
||||
#endif
|
||||
|
||||
plan->_glyphset_gsub.add (0); // Not-def
|
||||
|
@ -765,9 +766,9 @@ _populate_gids_to_retain (hb_subset_plan_t* plan,
|
|||
if (!plan->accelerator || plan->accelerator->has_seac)
|
||||
{
|
||||
bool has_seac = false;
|
||||
if (cff.is_valid ())
|
||||
if (cff->is_valid ())
|
||||
for (hb_codepoint_t gid : cur_glyphset)
|
||||
if (_add_cff_seac_components (cff, gid, &plan->_glyphset))
|
||||
if (_add_cff_seac_components (*cff, gid, &plan->_glyphset))
|
||||
has_seac = true;
|
||||
plan->has_seac = has_seac;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue