[HarfBuzz] collect_glyphs() API

Behdad Esfahbod behdad at behdad.org
Tue Dec 4 14:21:43 PST 2012


Hi Werner and Jonathan,

Just wanted to follow up and bring the new
hb_ot_layout_lookup_collect_glyphs() to your attention.

The implementation of this API is complete as far as I'm concerned.  HOWEVER,
I've done absolutely zero testing.  That has to wait until I have time to do a
cmdline tool for all the introspection APIs.  As such, thought I give you a
heads up so you can go ahead and test, err, use it.

Jonathan, I believe you know how to use the API.

Werner, here's how you use the API:

  1. Create a new set, call lookups (hb_set_create ()).

  2. Collect the index of the lookups you want to process into the set.

  3. Create sets for "backtrack", "input", "lookahead", and "output" glyph
sets.  They can point to the same object, or some can be NULL.

  4. Iterate over the lookup indices, and call collect_glyphs() for each.

Note that if you reuse a set, you are responsible for emptying it first.

Here is how one iterates over the set:

  hb_codepoint_t lookup_index;
  for (lookup_index = -1; hb_set_next (lookups, &lookup_index);)
      hb_ot_layout_lookup_collect_glyphs (face, HB_OT_TAG_GSUB, lookup_index,
...);

I probably should change the set API to use unsigned int instead of
hb_codepoint_t, but I'm not going to worry about it that much right now.

As for step 2, collecting lookup indices, there are different things you can
do.  Based on what you described to me before, I think using
hb_ot_layout_collect_lookups() makes most sense for you.  Say, if you want the
'scmp' feature for all scripts and languages, you call:

  hb_tag_t features[] = {HB_TAG ('s','c','m','p'), HB_TAG_NONE};
  hb_ot_layout_collect_lookups (face, HB_OT_TAG_GSUB, NULL, NULL, features,
lookups);

This will collect all the lookup indices for all scmp features in all scripts
/ language systems into the lookups set.  You can of course limit this to
specific scripts, etc.

Hope that helps,
-- 
behdad
http://behdad.org/



More information about the HarfBuzz mailing list