Debian Codegraph @

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

raw
1 #include "hdmx.h"
2
3 #include "support/util.h"
4
5 static INLINE void disposeHdmx(MOVE table_hdmx *table) {
6 if (!table->records) return;
7 for (uint32_t i = 0; i < table->numRecords; i++) {
8 if (table->records[i].widths != NULL) FREE(table->records[i].widths);
9 }
10 FREE(table->records);
11 }
12
13 caryll_standardRefType(table_hdmx, table_iHdmx, disposeHdmx);
14
15 table_hdmx *otfcc_readHdmx(otfcc_Packet packet, const otfcc_Options *options, table_maxp *maxp) {
16 FOR_TABLE(OTFCC_CHR('h','d','m','x'), table) {
17 font_file_pointer data = table.data;
18
19 table_hdmx *hdmx;
20 NEW(hdmx);
21 hdmx->version = read_16u(data);
22 hdmx->numRecords = read_16u(data + 2);
23 hdmx->sizeDeviceRecord = read_32u(data + 4);
24 NEW(hdmx->records, hdmx->numRecords);
25
26 for (uint32_t i = 0; i < hdmx->numRecords; i++) {
27 hdmx->records[i].pixelSize = *(data + 8 + i * (2 + maxp->numGlyphs));
28 hdmx->records[i].maxWidth = *(data + 8 + i * (2 + maxp->numGlyphs) + 1);
29 NEW(hdmx->records[i].widths, maxp->numGlyphs);
30 memcpy(hdmx->records[i].widths, data + 8 + i * (2 + maxp->numGlyphs) + 2, maxp->numGlyphs);
31 }
32
33 return hdmx;
34 }
35 return NULL;
36 }