sometimes when I am bored I look at the kitty terminal's source code. it's so good!

void
shaped_run_put(
SHAPED_RUN_MAP_HANDLE map,
const CPUCell *cells,
index_type num_cells,
const TextCache *tc,
bool disable_ligature,
bool force_ltr,
uint8_t scale,
uint8_t subscale,
const hb_glyph_info_t *info,
const hb_glyph_position_t *positions,
unsigned num_glyphs,
const ShapeGroup *groups,
unsigned num_groups) {
HashTable *ht = (HashTable *)map;
if (!ht) return;
if (shaped_run_too_long(num_cells)) return;
if ((num_glyphs && (!info || !positions)) || (num_groups && !groups)) return;
if (!fill_key(ht, cells, num_cells, tc, disable_ligature, force_ltr, scale, subscale)) return;
#define scratch ht->scratch.key
if (!vt_is_end(vt_get(&ht->table, scratch))) return;
if (shaped_run_at_cap(ht)) shaped_run_drop(ht);
ShapedRunKey *key = Key_get(&ht->keys, sizeof(ShapedRunKey) + scratch->keysz_in_bytes);
if (!key) return;
memcpy(key, scratch, sizeof(scratch[0]) + scratch->keysz_in_bytes);
ShapedRunValue *val = Val_get(&ht->vals, val_size(num_glyphs, num_groups));
if (!val) return;
val->num_glyphs = num_glyphs;
val->num_groups = num_groups;
if (num_glyphs) {
memcpy(val_info(val), info, num_glyphs * sizeof(info[0]));
memcpy(val_positions(val), positions, num_glyphs * sizeof(positions[0]));
}
if (num_groups) memcpy(val_groups(val), groups, num_groups * sizeof(groups[0]));
if (vt_is_end(vt_insert(&ht->table, key, val))) return;
#undef scratch
}

put a #define in the middle of a function body for some reason! why not! you are allowed to do anything! the buttons on the keyboard are there to be pressed! press them however you want!

en