[HarfBuzz] Fwd: harfbuzz work

Adam Langley agl at google.com
Wed Aug 5 14:36:16 PDT 2009


On Wed, Aug 5, 2009 at 2:27 PM, Behdad Esfahbod <behdad at behdad.org> wrote:
> As of now, I'm not quite sure whether we want to have script itemization in
> harfbuzz to begin with.  *If* we do, however, it will use a callback to get
> the script for a character, so higher level can control what script is
> returned for unencoded characters.

As part of the glib example code that I wrote (which is living in
contrib/ at the moment), there are a few functions:

(this will probably wrap badly...)

// -----------------------------------------------------------------------------
// Return the script of the given code point
// -----------------------------------------------------------------------------
HB_Script code_point_to_script(uint32_t cp);

// -----------------------------------------------------------------------------
// Find the next script run in a UTF-16 string.
//
// A script run is a subvector of codepoints, all of which are in the same
// script. A run will never cut a surrogate pair in half at either end.
//
// num_code_points: (output, maybe NULL) the number of code points in the run
// output: (output) the @pos, @length and @script fields are set on success
// chars: the UTF-16 string
// len: the length of @chars, in words
// iter: (in/out) the current index into the string. This should be 0 for the
//   first call and is updated on exit.
//
// returns: non-zero if a script run was found and returned.
// -----------------------------------------------------------------------------
char hb_utf16_script_run_next(unsigned *num_code_points, HB_ScriptItem *output,
                              const uint16_t *chars, size_t len, ssize_t *iter);

// -----------------------------------------------------------------------------
// This is the same as above, except that the input is traversed backwards.
// Thus, on the first call, |iter| should be |len| - 1.
// -----------------------------------------------------------------------------
char hb_utf16_script_run_prev(unsigned *num_code_points, HB_ScriptItem *output,
                              const uint16_t *chars, size_t len, ssize_t *iter);

This is what Chromium is using at the moment. Then again, I don't
really know what I'm doing, so there may well be bugs!


AGL



More information about the HarfBuzz mailing list