void GDEFNew(hotCtx g) { GDEFCtx h = MEM_NEW(g, sizeof(struct GDEFCtx_)); /* Link contexts */ h->g = g; g->ctx.GDEF = h; dnaINIT(g->dnaCtx, h->glyphClasess, 50, 200); dnaINIT(g->dnaCtx, h->attachEntries, 50, 200); dnaINIT(g->dnaCtx, h->ligCaretEntries, 50, 200); dnaINIT(g->dnaCtx, h->markAttachClasses, 50, 200); dnaINIT(g->dnaCtx, h->markSetClasses, 50, 200); h->offset = 0; h->tbl.GlyphClassDefOffset = 0; h->tbl.AttachTableOffset = 0; h->tbl.LigCaretTableOffset = 0; h->tbl.MarkClassDefOffset = 0; h->tbl.MarkGlyphSetsDefOffset = 0; h->glyphClassTable = NULL; h->attachTable.otl = NULL; h->attachTable.GlyphCount = 0; h->ligCaretTable.otl = NULL; h->ligCaretTable.LigGlyphCount = 0; h->markAttachClassTable = NULL; }
/* Initialize font record */ static void fontInit(void *ctx, long count, Font *font) { long i; tcCtx g = ctx; for (i = 0; i < count; i++) { font->flags = 0; font->FontName = NULL; font->fdCount = 0; font->fdInfo = NULL; font->fdIndex = NULL; font->iFDSelect = 0; dnaINIT(g->ctx.dnaCtx, font->dict, 50, 50); dnaINIT(g->ctx.dnaCtx, font->Private, 100, 50); font->chars.nStrings = 0; font->subrs.nStrings = 0; /* Not used in low-memory mode. Avoid freeing them. */ font->subrs.offset = NULL; font->subrs.data = NULL; font->chars.offset = NULL; font->chars.data = NULL; font->chameleon.data = NULL; #if TC_STATISTICS font->flatSize = 0; #endif /* TC_STATISTICS */ font++; } return; }
/* Initialize module. */ void cfwCstrNew(cfwCtx g) { cstrCtx h = cfwMemNew(g, sizeof(struct cstrCtx_)); /* Link contexts */ h->g = g; g->ctx.cstr = h; dnaINIT(g->ctx.dnaFail, h->cstr, 500, 5000); dnaINIT(g->ctx.dnaFail, h->masks, 30, 60); dnaINIT(g->ctx.dnaFail, h->hints, 10, 40); dnaINIT(g->ctx.dnaFail, h->cntrs, 1, 10); /* Open tmp stream */ g->stm.tmp = g->cb.stm.open(&g->cb.stm, CFW_TMP_STREAM_ID, 0); if (g->stm.tmp == NULL) { cfwFatal(g, cfwErrTmpStream, NULL); } h->tmpoff = 0; /* Initialize warning accumulator */ memset(h->warning, 0, sizeof(h->warning)); /* Used as charstring separator for subroutinizer */ h->unique = 0; }
/* Initialize encoding. */ static void initEncoding(void *ctx, long cnt, Encoding *encoding) { cfwCtx g = (cfwCtx)ctx; while (cnt--) { dnaINIT(g->ctx.dnaSafe, encoding->codes, 256, 256); dnaINIT(g->ctx.dnaSafe, encoding->supcodes, 5, 10); encoding++; } }
void vmtxNew(hotCtx g) { vmtxCtx h = MEM_NEW(g, sizeof(struct vmtxCtx_)); dnaINIT(g->dnaCtx, h->tbl.vMetrics, 14000, 14000); dnaINIT(g->dnaCtx, h->tbl.topSideBearing, 14000, 14000); /* Link contexts */ h->g = g; g->ctx.vmtx = h; }
void MMFXNew(hotCtx g) { MMFXCtx h = MEM_NEW(g, sizeof(struct MMFXCtx_)); h->nextUnnamedId = MMFXNamedMetricCnt; h->tbl.offset = NULL; dnaINIT(g->dnaCtx, h->metrics, 1000, 2000); dnaINIT(g->dnaCtx, h->cstrs, 5000, 10000); /* Link contexts */ h->g = g; g->ctx.MMFX = h; }
/* Validate client and create context. */ ufwCtx ufwNew(ctlMemoryCallbacks *mem_cb, ctlStreamCallbacks *stm_cb, CTL_CHECK_ARGS_DCL) { ufwCtx h; /* Check client/library compatibility */ if (CTL_CHECK_ARGS_TEST(UFW_VERSION)) return NULL; /* Allocate context */ h = mem_cb->manage(mem_cb, NULL, sizeof(struct ufwCtx_)); if (h == NULL) return NULL; /* Safety initialization */ h->state = 0; h->top = NULL; h->glyphs.size = 0; h->path.opList.size = 0; h->dna = NULL; h->stm.dst = NULL; h->stm.dbg = NULL; h->err.code = ufwSuccess; h->lastiFD = ABF_UNSET_INT; /* Copy callbacks */ h->cb.mem = *mem_cb; h->cb.stm = *stm_cb; /* Initialize service library */ h->dna = dnaNew(&h->cb.mem, DNA_CHECK_ARGS); if (h->dna == NULL) goto cleanup; h->arg.glyphLayer = "glyphs"; dnaINIT(h->dna, h->glyphs, 256, 750); dnaINIT(h->dna, h->path.opList, 256, 750); /* Open debug stream */ h->stm.dbg = h->cb.stm.open(&h->cb.stm, UFW_DBG_STREAM_ID, 0); return h; cleanup: /* Initialization failed */ ufwFree(h); return NULL; }
static LOffset createMarkSetClassDef(GDEFCtx h, hotCtx g) { int i; Offset size = (Offset)MARK_SET_TABLE_SIZE(h->markSetClasses.cnt); h->markSetClassTable.MarkSetTableFormat = 1; h->markSetClassTable.MarkSetCount = (unsigned short)h->markSetClasses.cnt; dnaINIT(g->dnaCtx, h->markSetClassTable.markSetEntries, h->markSetClasses.cnt, 10); for (i = 0; i < h->markSetClasses.cnt; i++) { GNode * p; otlTbl otl; MarkSetEntry* markSetEntry; GNode* srcNode = h->markSetClasses.array[i]; GNode* headNode; markSetEntry = dnaNEXT(h->markSetClassTable.markSetEntries); otl = otlTableNew(g); markSetEntry->otl = otl; featGlyphClassCopy(g, &headNode, srcNode); featGlyphClassSort(g, &headNode, 1, 1); otlCoverageBegin(g, otl); for (p = headNode; p != NULL; p = p->nextCl) otlCoverageAddGlyph(g, otl, p->gid); otlCoverageEnd(g, otl); markSetEntry->MarkSetCoverage = size; size += (Offset)otlGetCoverageSize(otl); featRecycleNodes(g, headNode); /* Don't need this class any more*/ h->markSetClasses.array[i] = NULL; } return size; }
/* Initialize module. */ void cfwDictNew(cfwCtx g) { dictCtx h = cfwMemNew(g, sizeof(struct dictCtx_)); /* Link contexts */ h->g = g; g->ctx.dict = h; dnaINIT(g->ctx.dnaSafe, h->tmp, 30, 10); }
/* Initialize module. */ void cfwEncodingNew(cfwCtx g) { encodingCtx h = (encodingCtx)cfwMemNew(g, sizeof(struct encodingCtx_)); /* Link contexts */ h->g = g; g->ctx.encoding = h; dnaINIT(g->ctx.dnaSafe, h->encodings, 1, 10); h->encodings.func = initEncoding; }
void anonNew(hotCtx g) { anonCtx h = MEM_NEW(g, sizeof(struct anonCtx_)); dnaINIT(g->dnaCtx, h->tbls, 5, 5); h->iTbl = 0; /* Link contexts */ h->g = g; g->ctx.anon = h; }
/* Main program */ int main(int argc, char *argv[]) { dnaCtx mainDnaCtx = NULL; long value; /* Extract program name */ progname = strrchr(argv[0], '/'); if (progname == NULL) { progname = strrchr(argv[0], '\\'); } progname = (progname == NULL) ? argv[0] : progname + 1; argc--; argv++; value = setjmp(mark); if (value == -1) { return 1; } /* Initialize */ cb_dna_memcb.ctx = mainDnaCtx; cb_dna_memcb.manage = cb_manage; mainDnaCtx = dnaNew(&cb_dna_memcb, DNA_CHECK_ARGS); cbctx = cbNew(progname, convert.dir.pfb, convert.dir.otf, convert.dir.cmap, convert.dir.feat, mainDnaCtx); script.buf = NULL; dnaINIT(mainDnaCtx, script.args, 100, 500); convert.dir.pfb[0] = '\0'; convert.dir.otf[0] = '\0'; convert.dir.cmap[0] = '\0'; convert.dir.feat[0] = '\0'; convert.features = NULL; convert.hCMap = NULL; convert.vCMap = NULL; convert.flags = 0; convert.otherflags = 0; convert.os2_version = 0; convert.fsSelectionMask_on = -1; convert.fsSelectionMask_off = -1; /* Process args. Call convFont at end. */ parseArgs(argc, argv, 0); fprintf(stderr, "\n"); /* Terminate progress line */ /* Clean up */ cbMemFree(cbctx, script.buf); dnaFREE(script.args); cbFree(cbctx); return 0; }
/* Initialize module */ void encodingNew(tcCtx g) { encodingCtx h = MEM_NEW(g, sizeof(struct encodingCtx_)); dnaINIT(g->ctx.dnaCtx, h->encodings, 1, 10); h->encodings.func = initEncoding; /* Link contexts */ h->g = g; g->ctx.encoding = h; }
/* Create new context */ tcCtx tcNew(tcCallbacks *cb) { tcCtx g = cb->malloc(cb->ctx, sizeof(struct tcCtx_)); tcprivCtx h; g->cb = *cb; h = MEM_NEW(g, sizeof(struct tcprivCtx_)); tc_dna_memcb.ctx = g; tc_dna_memcb.manage = tc_manage; g->ctx.dnaCtx = dnaNew(&tc_dna_memcb, DNA_CHECK_ARGS); dnaINIT(g->ctx.dnaCtx, h->set, 4, 120); h->set.func = fontInit; initSet(g, h); /* Initialize other library modules */ g->ctx.sindex = NULL; g->ctx.fdselect = NULL; g->ctx.subr = NULL; g->ctx.cs = NULL; g->ctx.encoding = NULL; g->ctx.charset = NULL; g->ctx.recode = NULL; g->ctx.parse = NULL; g->ctx.tcpriv = NULL; g->ctx.t13 = NULL; sindexNew(g); encodingNew(g); charsetNew(g); parseNew(g); csNew(g); recodeNew(g); #if TC_SUBR_SUPPORT subrNew(g); #endif /* TC_SUBR_SUPPORT */ fdselectNew(g); t13New(g); /* Link contexts */ h->g = g; g->ctx.tcpriv = h; return g; }
int addLigCaretEntryGDEF(hotCtx g, GNode* glyphNode, unsigned short caretValue, unsigned short format) { int i; LigGlyphEntry *lge = NULL; GID gid = glyphNode->gid; GDEFCtx h = g->ctx.GDEF; int seenCaretValue = 0; /* See if we can find matching GID entry in the attach point list.*/ i = 0; while (i < h->ligCaretEntries.cnt) { if (h->ligCaretEntries.array[i].gid == gid) { unsigned short j; CaretTable *ct; lge = &h->ligCaretEntries.array[i]; /* make sure the contour isn't already in the list. */ for (j = 0; j < lge->caretTables.cnt; j++) if (lge->caretTables.array[j].CaretValue == caretValue) { seenCaretValue = 1; break; } if (!seenCaretValue) { ct = dnaNEXT(lge->caretTables); ct->format = format; ct->CaretValue = caretValue; } break; } i++; } if (lge == NULL) { CaretTable *ct; lge = dnaNEXT(h->ligCaretEntries); lge->gid = gid; dnaINIT(g->dnaCtx, lge->caretTables, 10, 10); ct = dnaNEXT(lge->caretTables); ct->format = format; ct->CaretValue = caretValue; } return seenCaretValue; }
int addAttachEntryGDEF(hotCtx g, GNode* glyphNode, unsigned short contour) { int i; AttachEntry *attachEntry = NULL; GID gid = glyphNode->gid; GDEFCtx h = g->ctx.GDEF; int seenContour = 0; /* See if we can find matching GID entry in the attach point list.*/ i = 0; while (i < h->attachEntries.cnt) { if (h->attachEntries.array[i].gid == gid) { unsigned short j, *indexEntry; attachEntry = &h->attachEntries.array[i]; /* make sure the contour isn't already in the list. */ for (j = 0; j < attachEntry->contourIndices.cnt; j++) if (attachEntry->contourIndices.array[j] == contour) { seenContour = 1; break; } if (!seenContour) { indexEntry = dnaNEXT(attachEntry->contourIndices); *indexEntry = contour; } break; } i++; } if (attachEntry == NULL) { unsigned short *indexEntry; attachEntry = dnaNEXT(h->attachEntries); attachEntry->gid = gid; dnaINIT(g->dnaCtx, attachEntry->contourIndices, 10, 10); indexEntry = dnaNEXT(attachEntry->contourIndices); *indexEntry = contour; } return seenContour; }