[HarfBuzz] Python: accessing harfbuzz enums

Martin Hosken mhosken at gmail.com
Mon Jun 20 01:57:44 UTC 2016


On Sun, 19 Jun 2016 16:34:23 -0400
Kelvin Ma <kelvinsthirteen at gmail.com> wrote:

> When using the python harfbuzz bindings, how do I access the harfbuzz enums
> for direction, script, & language? Also can someone explain the difference
> between direction and script because I thought script implies direction.

Look in hb-common.h which is pulled in by hb.h.

There are enums for hb_direction_t and hb_script_t. There is no enum for hb_language_t, but you can get one by using hb_language_from_string().

A run needs to have a separate direction from its script because, in the case of bidi scripts like Arabic, a particular sequence of letters may be in the opposite order to the default direction of the script (arab). Harfbuzz expects each run to be in a single direction. So a sequence of arabic digits in an arabic text: ARABIC1234ARABIC, would get passed to harfbuzz as 3 runs "ARABIC" (rtl), "1234" (ltr), "ARABIC" (rtl). A bidi processor, say from icu, will do the maths for you here and work out the runs and their directions.

HTH,
Yours,
Martin


More information about the HarfBuzz mailing list