static table_OTL *otfcc_readOtl_common(font_file_pointer data, uint32_t tableLength, otl_LookupType lookup_type_base, const otfcc_Options *options) { table_OTL *table = table_iOTL.create(); if (!table) goto FAIL; checkLength(10); uint32_t scriptListOffset = read_16u(data + 4); checkLength(scriptListOffset + 2); uint32_t featureListOffset = read_16u(data + 6); checkLength(featureListOffset + 2); uint32_t lookupListOffset = read_16u(data + 8); checkLength(lookupListOffset + 2); // parse lookup list { tableid_t lookupCount = read_16u(data + lookupListOffset); checkLength(lookupListOffset + 2 + lookupCount * 2); for (tableid_t j = 0; j < lookupCount; j++) { otl_Lookup *lookup; otl_iLookupPtr.init(&lookup); lookup->_offset = lookupListOffset + read_16u(data + lookupListOffset + 2 + 2 * j); checkLength(lookup->_offset + 6); lookup->type = read_16u(data + lookup->_offset) + lookup_type_base; otl_iLookupList.push(&table->lookups, lookup); } } // parse feature list { tableid_t featureCount = read_16u(data + featureListOffset); checkLength(featureListOffset + 2 + featureCount * 6); tableid_t lnk = 0; for (tableid_t j = 0; j < featureCount; j++) { otl_Feature *feature; otl_iFeaturePtr.init(&feature); uint32_t tag = read_32u(data + featureListOffset + 2 + j * 6); if (options->glyph_name_prefix) { feature->name = sdscatprintf(sdsempty(), "%c%c%c%c_%s_%05d", (tag >> 24) & 0xFF, (tag >> 16) & 0xFF, (tag >> 8) & 0xff, tag & 0xff, options->glyph_name_prefix, j); } else { feature->name = sdscatprintf(sdsempty(), "%c%c%c%c_%05d", (tag >> 24) & 0xFF, (tag >> 16) & 0xFF, (tag >> 8) & 0xff, tag & 0xff, j); } uint32_t featureOffset = featureListOffset + read_16u(data + featureListOffset + 2 + j * 6 + 4); checkLength(featureOffset + 4); tableid_t lookupCount = read_16u(data + featureOffset + 2); checkLength(featureOffset + 4 + lookupCount * 2); for (tableid_t k = 0; k < lookupCount; k++) { tableid_t lookupid = read_16u(data + featureOffset + 4 + k * 2); if (lookupid < table->lookups.length) { otl_Lookup *lookup = table->lookups.items[lookupid]; if (!lookup->name) { if (options->glyph_name_prefix) { lookup->name = sdscatprintf(sdsempty(), "lookup_%s_%c%c%c%c_%d", options->glyph_name_prefix, (tag >> 24) & 0xFF, (tag >> 16) & 0xFF, (tag >> 8) & 0xff, tag & 0xff, lnk++); } else { lookup->name = sdscatprintf(sdsempty(), "lookup_%c%c%c%c_%d", (tag >> 24) & 0xFF, (tag >> 16) & 0xFF, (tag >> 8) & 0xff, tag & 0xff, lnk++); } }
#include "PCLT.h" table_PCLT *caryll_read_PCLT(caryll_packet packet) { FOR_TABLE('PCLT', table) { font_file_pointer data = table.data; table_PCLT *PCLT = (table_PCLT *)malloc(sizeof(table_PCLT) * 1); PCLT->version = read_32u(data); PCLT->FontNumber = read_32u(data + 4); PCLT->Pitch = read_16u(data + 8); PCLT->xHeight = read_16u(data + 10); PCLT->Style = read_16u(data + 12); PCLT->TypeFamily = read_16u(data + 14); PCLT->CapHeight = read_16u(data + 16); PCLT->SymbolSet = read_16u(data + 18); memcpy(PCLT->Typeface, data + 20, 16); memcpy(PCLT->CharacterComplement, data + 36, 8); memcpy(PCLT->FileName, data + 44, 6); PCLT->StrokeWeight = *(data + 50); PCLT->WidthType = *(data + 51); PCLT->SerifStyle = *(data + 52); PCLT->pad = 0; return PCLT; } return NULL; }