capsules/fonts: JetBrainsMono-Regular.ttf as a raw-blob capsule (item 4.3.7b)
mkcapsule.c already ingests arbitrary non-.4th files as raw byte blobs (validate_forth_blocks only applies to .4th filenames), so no hex/base64 text-encoding or tool changes are needed -- corrects the design premise in FABRIC.md's 4.3.7b item text (see the FABRIC.md correction note this commit carries). ttf_load_from_capsule() resolves the font capsule by name, validates its content hash, and points ttf_font_t at the capsule arena bytes directly, zero-copy. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
70b6918279
commit
2ef8d26c6f
@@ -521,4 +521,39 @@ int ttf_glyph_outline(const ttf_font_t *font, uint32_t glyph_index, ttf_outline_
|
||||
out->point_count = 0;
|
||||
out->contour_count = 0;
|
||||
return decode_glyph_r(font, glyph_index, out, 0);
|
||||
}
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* 4.3.7b — font data ingestion (capsule-backed, zero-copy)
|
||||
* ===========================================================================
|
||||
*/
|
||||
|
||||
#ifdef __STARKERNEL__
|
||||
|
||||
int ttf_load_from_capsule(
|
||||
const CapsuleDirHeader *dir,
|
||||
const CapsuleDesc *descs,
|
||||
const CapsuleNameEntry *names,
|
||||
const uint8_t *arena,
|
||||
const char *capsule_name,
|
||||
ttf_font_t *out) {
|
||||
const CapsuleDesc *cap;
|
||||
const uint8_t *payload;
|
||||
CapsuleValidateResult vr;
|
||||
|
||||
if (!dir || !descs || !names || !arena || !capsule_name || !out)
|
||||
return TTF_ERR_BAD_TABLE;
|
||||
|
||||
cap = capsule_find_by_name(dir, descs, names, capsule_name);
|
||||
if (!cap) return TTF_ERR_TABLE_MISSING;
|
||||
|
||||
vr = capsule_validate(cap, arena, dir->arena_size, 1);
|
||||
if (vr != CAPSULE_VALID) return TTF_ERR_BAD_TABLE;
|
||||
|
||||
payload = capsule_get_payload(cap, arena);
|
||||
if (!payload) return TTF_ERR_BAD_TABLE;
|
||||
|
||||
return ttf_parse(payload, (uint32_t) cap->length, out);
|
||||
}
|
||||
|
||||
#endif /* __STARKERNEL__ */
|
||||
Reference in New Issue
Block a user