[afshaper] Delay creating `hb_set' objects until needed.

In runs on Noto Naskh Arabic, this results in 89 sets created
instead of 340 before.  Makes auto-hinter setup with HarfBuzz
enabled 20% to 30% faster.

* src/autofit/afshaper.c (af_shaper_get_coverage): Implement it.
This commit is contained in:
Behdad Esfahbod 2017-10-14 08:42:07 +02:00 committed by Werner Lemberg
parent d2b3b9e682
commit 90461c0137
2 changed files with 25 additions and 16 deletions

View File

@ -1,3 +1,13 @@
2017-10-14 Behdad Esfahbod <behdad@behdad.org>
[afshaper] Delay creating `hb_set' objects until needed.
In runs on Noto Naskh Arabic, this results in 89 sets created
instead of 340 before. Makes auto-hinter setup with HarfBuzz
enabled 20% to 30% faster.
* src/autofit/afshaper.c (af_shaper_get_coverage): Implement it.
2017-10-12 Ewald Hew <ewaldhew@gmail.com>
[type1, cid] Add hinting engine switch.

View File

@ -104,10 +104,10 @@
{
hb_face_t* face;
hb_set_t* gsub_lookups; /* GSUB lookups for a given script */
hb_set_t* gsub_glyphs; /* glyphs covered by GSUB lookups */
hb_set_t* gpos_lookups; /* GPOS lookups for a given script */
hb_set_t* gpos_glyphs; /* glyphs covered by GPOS lookups */
hb_set_t* gsub_lookups = NULL; /* GSUB lookups for a given script */
hb_set_t* gsub_glyphs = NULL; /* glyphs covered by GSUB lookups */
hb_set_t* gpos_lookups = NULL; /* GPOS lookups for a given script */
hb_set_t* gpos_glyphs = NULL; /* glyphs covered by GPOS lookups */
hb_script_t script;
const hb_tag_t* coverage_tags;
@ -127,11 +127,6 @@
face = hb_font_get_face( globals->hb_font );
gsub_lookups = hb_set_create();
gsub_glyphs = hb_set_create();
gpos_lookups = hb_set_create();
gpos_glyphs = hb_set_create();
coverage_tags = coverages[style_class->coverage];
script = scripts[style_class->script];
@ -168,6 +163,7 @@
script_tags[1] = HB_TAG_NONE;
}
gsub_lookups = hb_set_create();
hb_ot_layout_collect_lookups( face,
HB_OT_TAG_GSUB,
script_tags,
@ -178,13 +174,6 @@
if ( hb_set_is_empty( gsub_lookups ) )
goto Exit; /* nothing to do */
hb_ot_layout_collect_lookups( face,
HB_OT_TAG_GPOS,
script_tags,
NULL,
coverage_tags,
gpos_lookups );
FT_TRACE4(( "GSUB lookups (style `%s'):\n"
" ",
af_style_names[style_class->style] ));
@ -193,6 +182,7 @@
count = 0;
#endif
gsub_glyphs = hb_set_create();
for ( idx = HB_SET_VALUE_INVALID; hb_set_next( gsub_lookups, &idx ); )
{
#ifdef FT_DEBUG_LEVEL_TRACE
@ -220,10 +210,19 @@
" ",
af_style_names[style_class->style] ));
gpos_lookups = hb_set_create();
hb_ot_layout_collect_lookups( face,
HB_OT_TAG_GPOS,
script_tags,
NULL,
coverage_tags,
gpos_lookups );
#ifdef FT_DEBUG_LEVEL_TRACE
count = 0;
#endif
gpos_glyphs = hb_set_create();
for ( idx = HB_SET_VALUE_INVALID; hb_set_next( gpos_lookups, &idx ); )
{
#ifdef FT_DEBUG_LEVEL_TRACE