Back to API Reference
Class

LanguageRegistry

static

Process-wide registry mapping BCP 47 language tags to HarfBuzz language handles and compact byte indices suitable for per-codepoint attribute storage.

Remarks

HarfBuzz language handles (hb_language_t) are opaque pointers cached internally by HarfBuzz, so equal BCP 47 strings resolve to the same pointer. HarfBuzz maps BCP 47 to OpenType language tags (e.g. zh-Hans → ZHS, ja → JAN) automatically, which drives the locl GSUB feature in pan-CJK fonts. The registry is additive: once a tag is registered, its index stays stable for the lifetime of the process. Index 0 is reserved for "unset" and maps to HB_LANGUAGE_INVALID.
public static byte Register(string bcp47)

Registers a BCP 47 language tag and returns its compact byte index. Returns Unset for null/empty tags or if the registry is full.

public static IntPtr GetHandle()

Returns the HarfBuzz language handle for a registry index, or Zero if unset.

public static string GetTag()

Returns the BCP 47 tag for a registry index, or empty string if unset.

public static const byte Unset

Index reserved for "no language set". Maps to IntPtr.Zero.