Debian Codegraph @

texk/web2c/mfluadir/otfcc/lib/table/TSI5.c

raw
1 #include "TSI5.h"
2 #include "support/util.h"
3
4 table_TSI5 *otfcc_readTSI5(const otfcc_Packet packet, const otfcc_Options *options) {
5 FOR_TABLE(OTFCC_CHR('T','S','I','5'), table) {
6 table_TSI5 *tsi5 = otl_iClassDef.create();
7 for (glyphid_t j = 0; j * 2 < table.length; j++) {
8 otl_iClassDef.push(tsi5, Handle.fromIndex(j), read_16u(table.data + j * 2));
9 }
10 return tsi5;
11 }
12 return NULL;
13 }
14 void otfcc_dumpTSI5(const table_TSI5 *table, json_value *root, const otfcc_Options *options) {
15 if (!table) return;
16 json_object_push(root, "TSI5", otl_iClassDef.dump(table));
17 }
18 table_TSI5 *otfcc_parseTSI5(const json_value *root, const otfcc_Options *options) {
19 json_value *_tsi = NULL;
20 if (!(_tsi = json_obj_get_type(root, "TSI5", json_object))) return NULL;
21 return otl_iClassDef.parse(_tsi);
22 }
23 caryll_Buffer *otfcc_buildTSI5(const table_TSI5 *tsi5, const otfcc_Options *options,
24 glyphid_t numGlyphs) {
25 if (!tsi5) return NULL;
26 uint16_t *tsi5cls;
27 NEW_CLEAN_N(tsi5cls, numGlyphs);
28 for (glyphid_t j = 0; j < tsi5->numGlyphs; j++) {
29 if (tsi5->glyphs[j].index < numGlyphs) {
30 tsi5cls[tsi5->glyphs[j].index] = tsi5->classes[j];
31 }
32 }
33 caryll_Buffer *buf = bufnew();
34 for (glyphid_t j = 0; j < numGlyphs; j++) {
35 bufwrite16b(buf, tsi5cls[j]);
36 }
37 FREE(tsi5cls);
38 return buf;
39 }