| Top |
| 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 () |
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.
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);
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
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 < total; i++) {
hb_subset_depend_entry_t entry;
unsigned int count = 1;
hb_subset_depend_lookup_glyph (depend, gid, i, &count, &entry);
// Process entry.table_tag, entry.dependent, etc.
}
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 |
[out][optional][array length=entry_count] |
Since: 14.3.0
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);
depend |
depend object |
|
index |
the index of the set |
|
out |
A pointer to a set to copy into. |
[out] |
Since: 14.3.0
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.
Since: 14.3.0
typedef struct hb_subset_depend_t hb_subset_depend_t;
Data type for holding glyph dependency graphs.
Since: 14.3.0
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().
hb_tag_t |
Source table (e.g. GSUB, glyf, CFF, COLR, MATH). |
|
hb_codepoint_t |
Target glyph ID. |
|
hb_tag_t |
Feature tag for GSUB edges; 0 otherwise. |
|
hb_codepoint_t |
Index into the sets array for ligature component glyphs, or HB_CODEPOINT_INVALID if not a ligature edge. |
|
hb_codepoint_t |
Index into the sets array for context requirement
glyphs, or HB_CODEPOINT_INVALID if none. Use |
|
Edge flags (hb_subset_depend_edge_flags_t). |
Since: 14.3.0
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).
|
No flags set. |
||
|
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. |
||
|
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