Common data types and APIs

HarfBuzz includes several APIs for working with general-purpose data that you may find convenient to leverage in your own software. They include set operations and integer-to-integer mapping operations.

HarfBuzz uses set operations for internal bookkeeping, such as when it collects all of the glyph IDs covered by a particular font feature. You can also use the set API to build sets, add and remove elements, test whether or not sets contain particular elements, or compute the unions, intersections, or differences between sets.

All set elements are integers (specifically, hb_codepoint_t 32-bit unsigned ints), and there are functions for fetching the minimum and maximum element from a set. The set API also includes some functions that might not be part of a generic set facility, such as the ability to add a contiguous range of integer elements to a set in bulk, and the ability to fetch the next-smallest or next-largest element.

The HarfBuzz set API includes some conveniences as well. All sets are lifecycle-managed, just like other HarfBuzz objects. You increase the reference count on a set with hb_set_reference() and decrease it with hb_set_destroy(). You can also attach user data to a set, just like you can to blobs, buffers, faces, fonts, and other objects, and set destroy callbacks.

HarfBuzz also provides an API for keeping track of integer-to-integer mappings. As with the set API, each integer is stored as an unsigned 32-bit hb_codepoint_t element. Maps, like other objects, are reference counted with reference and destroy functions, and you can attach user data to them. The mapping operations include adding and deleting integer-to-integer key:value pairs to the map, testing for the presence of a key, fetching the population of the map, and so on.

There are several other internal HarfBuzz facilities that are exposed publicly and which you may want to take advantage of while processing text. HarfBuzz uses a common hb_tag_t for a variety of OpenType tag identifiers (for scripts, languages, font features, table names, variation-axis names, and more), and provides functions for converting strings to tags and vice-versa.

Finally, HarfBuzz also includes data type for Booleans, bit masks, and other simple types.