[HarfBuzz] Some optimizations

Behdad Esfahbod behdad at behdad.org
Wed Oct 10 17:33:28 PDT 2007


For Boston Summit this year I sat down optimizing harfbuzz buffer a bit
to avoid unnecessary copy/swap'ing when glyphs do not change.  The idea
is to use the same string for in and out, essentially working in-place,
until a change that doesn't fit in-place is needed at which point we
lazily create a separate out buffer and copy over.

Unfortunately I didn't start this in a git-svn pango checkout and ended
up piling changes on top of each other.

Around the final round it was about 1700 lines worth of diff, but to
find why a particular Invalid_SubTable error was being hit I needed to
see where the error is originating from, so I renamed remaining FT_Err
instances to HB_Err and made the entire code call _hb_err() when
returning an original error, so you can set a breakpoint on it.  It
helped debugging the bug in a minute, but also means that the patch is
over 7000 lines now :(.  Sorry Simon :(.

Anyway, it's here:


Quick summary:

2007-10-10  Behdad Esfahbod  <behdad at gnome.org>

        Bug 485559 – Boston Summit HarfBuzz optimizations

        * pango/opentype/*: HarfBuzz hacking to:

          - Rename last remaining FT_Err stuff to HB_Err.

          - Fix a couple invalid table paths to be permissive so
            fonts work better.  Particularly GDEF table for Nafees
            Nastaliq is loaded and works great now.

          - Optimize harfbuzz buffer to not copy/swap for simple
          one-to-one and "copy" GSUB operations.

        * pango/pango-ot*: Update to FT_Err to HB_Err renaming.

I think the easiest way to apply it to harfbuzz upstream is to rip out
the FT_Err and _hb_err changes out, apply it, and redo them...  I'll
give it a try if it's too much pain for Simon to do (which I totally
understand if it is), but other than that, it can use a pair of eyes.
Specially the harfbuzz-buffer changes.

Tomorrow I'll make pango cache a single harfbuzz buffer instead of
recreating them all the time.

A very warm feeling of doing this all is that I feel much more
comfortable with the GSUB code now.  GPOS still has a bit of mystery to
discover.  All in all quite good just in time for picking up the rewrite
again, which I'm starting next week.



"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759

More information about the HarfBuzz mailing list