An overview of data types in HarfBuzz
HarfBuzz features two kinds of data types: non-opaque,
pass-by-value types and opaque, heap-allocated types. This kind
of separation is common in C libraries that have to provide
API/ABI compatibility (almost) indefinitely.
Value types: The non-opaque, pass-by-value
types include integer types, enums, and small structs. Exposing
a struct in the public API makes it impossible to expand the
struct in the future. As such, exposing structs is reserved for
cases where it’s extremely inefficient to do otherwise.
In HarfBuzz, several structs, like hb_glyph_info_t
and
hb_glyph_position_t
, fall into that efficiency-sensitive
category and are non-opaque.
For all non-opaque structs where future extensibility may be
necessary, reserved members are included to hold space for
possible future members. As such, it’s important to provide
equal()
, and hash()
methods for such structs, allowing users of the API do
effectively deal with the type without having to
adapt their code to future changes.
Important value types provided by HarfBuzz include the structs
for working with Unicode code points, glyphs, and tags for font
tables and features, as well as the enums for many Unicode and
OpenType properties.