hb-subset-depend: HarfBuzz Manual

## hb-subset-depend hb-subset-depend — Glyph dependency graph for font optimization |

## Functions

hb_subset_depend_t * | hb_subset_depend_from_face_or_fail ()
unsigned int | hb_subset_depend_lookup_glyph ()
hb_bool_t | hb_subset_depend_lookup_set ()
void | hb_subset_depend_destroy ()

## Types and Values

typedef | hb_subset_depend_t
| hb_subset_depend_entry_t
enum | hb_subset_depend_edge_flags_t

## Includes

    #include <hb-subset-depend.h>

## Description

This API is highly experimental and subject to change. It is not enabled by default and should not be used in production code without understanding the stability implications.

Functions for extracting a glyph dependency graph.

A dependency graph represents the relationships between glyphs in a font, tracking which glyphs reference or produce other glyphs through OpenType mechanisms such as character mapping, glyph substitution, composite construction, color layering, and math variants.

Dependency graphs enable finding all glyphs reachable from a given input set. This is useful for font subsetting, analyzing glyph coverage, optimizing font delivery, and determining which glyphs are needed to render specific characters.

## Functions

### hb_subset_depend_from_face_or_fail ()

    hb_subset_depend_t *
    hb_subset_depend_from_face_or_fail (hb_face_t *face);

Calculates the dependencies between glyphs in the supplied face. Extracts dependency information from GSUB, glyf, CFF, COLR, and MATH tables. UVS (Unicode Variation Sequence) dependencies are not included; handle those via `hb_font_get_variation_glyph()`.

Example: `c hb_subset_depend_t *depend = hb_subset_depend_from_face_or_fail (face); if (!depend) { // Handle error (OOM or invalid face) return; } // ... use depend ... hb_subset_depend_destroy (depend);`

#### Parameters

face | font face to collect dependencies from |

#### Returns

New depend object, or `nullptr` if creation failed (out of memory or invalid face). Destroy with `hb_subset_depend_destroy()`.

[transfer full]

Since: 14.3.0

### hb_subset_depend_lookup_glyph ()

    unsigned int
    hb_subset_depend_lookup_glyph (hb_subset_depend_t *depend,
                                   hb_codepoint_t gid,
                                   unsigned int start_offset,
                                   unsigned int *entry_count,
                                   hb_subset_depend_entry_t *entries);

Retrieve dependency edges for a glyph. Follows the standard HarfBuzz array-getter pattern: always returns the total number of edges for `gid` regardless of `start_offset` or `entry_count` .

Example (iterate all entries): `c unsigned int total = hb_subset_depend_lookup_glyph (depend, gid, 0, NULL, NULL); for (unsigned int i = 0; i &lt; total; i++) { hb_subset_depend_entry_t entry; unsigned int count = 1; hb_subset_depend_lookup_glyph (depend, gid, i, &amp;count, &amp;entry); // Process entry.table_tag, entry.dependent, etc. }`

#### Parameters

depend | depend object |
gid | GID to retrieve dependencies from |
start_offset | offset of first entry to retrieve |
entry_count | Input = number of entries to fill; output = number actually filled. Pass NULL to query total count without filling. | [inout][optional]
entries | Array to fill with dependency edge data. May be NULL if `entry_count` is also NULL. | [out][optional][array length=entry_count]

#### Returns

Total number of dependency edges for `gid` .

Since: 14.3.0

### hb_subset_depend_lookup_set ()

    hb_bool_t
    hb_subset_depend_lookup_set (hb_subset_depend_t *depend,
                                 hb_codepoint_t index,
                                 hb_set_t *out);

Get all glyphs in a set identified by `index` . The set index comes from the ligature_set_index or context_set_index field returned by `hb_subset_depend_lookup_glyph()`.

Example: `c hb_set_t *ligature_glyphs = `hb_set_create()`; if (hb_subset_depend_lookup_set (depend, entry.ligature_set_index, ligature_glyphs)) { // Process glyphs in the set... } hb_set_destroy (ligature_glyphs);`

#### Parameters

depend | depend object |
index | the index of the set |
out | A pointer to a set to copy into. | [out]

#### Returns

true if there is such a set, false otherwise

Since: 14.3.0

### hb_subset_depend_destroy ()

    void
    hb_subset_depend_destroy (hb_subset_depend_t *depend);

Decreases the reference count on `depend` , and if it reaches zero, destroys `depend` , freeing all memory.

#### Parameters

depend | a hb_subset_depend_t |

Since: 14.3.0

## Types and Values

### hb_subset_depend_t

    typedef struct hb_subset_depend_t hb_subset_depend_t;

Data type for holding glyph dependency graphs.

Highly experimental API. Subject to change.

Since: 14.3.0

### hb_subset_depend_entry_t

    typedef struct {
      hb_tag_t table_tag;
      hb_codepoint_t dependent;
      hb_tag_t layout_tag;
      hb_codepoint_t ligature_set_index;
      hb_codepoint_t context_set_index;
      hb_subset_depend_edge_flags_t flags;
    } hb_subset_depend_entry_t;

A single dependency edge returned by `hb_subset_depend_lookup_glyph()`.

#### Members

hb_tag_t `table_tag`; | Source table (e.g. GSUB, glyf, CFF, COLR, MATH). |
hb_codepoint_t `dependent`; | Target glyph ID. |
hb_tag_t `layout_tag`; | Feature tag for GSUB edges; 0 otherwise. |
hb_codepoint_t `ligature_set_index`; | Index into the sets array for ligature component glyphs, or HB_CODEPOINT_INVALID if not a ligature edge. |
hb_codepoint_t `context_set_index`; | Index into the sets array for context requirement glyphs, or HB_CODEPOINT_INVALID if none. Use `hb_subset_depend_lookup_set()` to retrieve the set. |
hb_subset_depend_edge_flags_t `flags`; | Edge flags (hb_subset_depend_edge_flags_t). |

Since: 14.3.0

### enum hb_subset_depend_edge_flags_t

Flags on dependency edges returned by `hb_subset_depend_lookup_glyph()` that mark edges which may produce expected over-approximation when computing closure via the depend graph, relative to `hb_ot_layout_lookups_substitute_closure()`. These flags help distinguish known limitations of static dependency analysis (expected over-approximation) from bugs (unexpected over-approximation).

#### Members

HB_SUBSET_DEPEND_EDGE_FLAG_NONE | No flags set. |
HB_SUBSET_DEPEND_EDGE_FLAG_FROM_CONTEXT_POSITION | Edge from a multi-position contextual rule (Context or ChainContext with inputCount > 1). Depend extraction records edges based on what glyphs could statically be at each position according to input coverage or class. However, at runtime lookups within the rule are applied sequentially: a lookup at an earlier position may transform the glyph at a later position, and two lookups at the same position may interact such that one produces a glyph that another immediately consumes as an "intermediate". A glyph that matches the static coverage may therefore not persist at that position when the rule actually fires, so this edge may not trigger during closure. |
HB_SUBSET_DEPEND_EDGE_FLAG_FROM_NESTED_CONTEXT | Edge from a lookup invoked within another contextual lookup. The outer context's requirements are not propagated to this edge, so the edge may fire even when those requirements are not met. |

Since: 14.3.0