/* Free font record */ static void freeFonts(tcCtx g) { tcprivCtx h = g->ctx.tcpriv; int i; /* Free font data */ for (i = 0; i < h->set.cnt; i++) { Font *font = &h->set.array[i]; MEM_FREE(g, font->FontName); dnaFREE(font->dict); dnaFREE(font->Private); csFreeFont(g, font); if (font->flags & FONT_CID) { int fdCount = font->fdCount; int fd; if (font->fdInfo) { for (fd = 0; fd < fdCount; fd++) { dnaFREE(font->fdInfo[fd].FD); dnaFREE(font->fdInfo[fd].Private); } MEM_FREE(g, font->fdInfo); } MEM_FREE(g, font->fdIndex); } MEM_FREE(g, font->chameleon.data); (void)fontInit(g, 1, font); /* Prepare to reuse */ } h->set.cnt = 0; }
void MMFXFree(hotCtx g) { MMFXCtx h = g->ctx.MMFX; dnaFREE(h->metrics); dnaFREE(h->cstrs); MEM_FREE(g, g->ctx.MMFX); }
void vmtxFree(hotCtx g) { vmtxCtx h = g->ctx.vmtx; dnaFREE(h->tbl.vMetrics); dnaFREE(h->tbl.topSideBearing); MEM_FREE(g, g->ctx.vmtx); }
/* Free resources */ void cfwEncodingFree(cfwCtx g) { encodingCtx h = g->ctx.encoding; int i; if (h == NULL) { return; } for (i = 0; i < h->encodings.size; i++) { Encoding *encoding = &h->encodings.array[i]; dnaFREE(encoding->codes); dnaFREE(encoding->supcodes); } dnaFREE(h->encodings); cfwMemFree(g, h); g->ctx.encoding = NULL; }
/* Free context. */ void ufwFree(ufwCtx h) { if (h == NULL) return; /* Close debug stream */ if (h->stm.dbg != NULL) { (void)h->cb.stm.close(&h->cb.stm, h->stm.dbg); h->stm.dbg = NULL; } dnaFREE(h->glyphs); dnaFREE(h->path.opList); dnaFree(h->dna); /* Free library context */ h->cb.mem.manage(&h->cb.mem, h, 0); return; }
/* 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; }
/* Free resources. */ void cfwCstrFree(cfwCtx g) { cstrCtx h = g->ctx.cstr; if (h == NULL) { return; } dnaFREE(h->cstr); dnaFREE(h->masks); dnaFREE(h->hints); dnaFREE(h->cntrs); /* Close tmp stream */ if (g->cb.stm.close(&g->cb.stm, g->stm.tmp)) { cfwFatal(g, cfwErrTmpStream, NULL); } cfwMemFree(g, g->ctx.cstr); g->ctx.cstr = NULL; }
/* Free resources */ void cfwDictFree(cfwCtx g) { dictCtx h = g->ctx.dict; if (h == NULL) { return; } dnaFREE(h->tmp); cfwMemFree(g, h); g->ctx.dict = NULL; }
void GDEFFree(hotCtx g) { int i; GDEFCtx h = g->ctx.GDEF; dnaFREE(h->glyphClasess); if (h->glyphClassTable != NULL) otlTableFree(g, h->glyphClassTable); for (i = 0; i < h->attachEntries.cnt; i++) dnaFREE(h->attachEntries.array[i].contourIndices); dnaFREE(h->attachEntries); if (h->attachTable.otl != NULL) otlTableFree(g, h->attachTable.otl); for (i = 0; i < h->ligCaretEntries.cnt; i++) dnaFREE(h->ligCaretEntries.array[i].caretTables); dnaFREE(h->ligCaretEntries); if (h->ligCaretTable.otl != NULL) otlTableFree(g, h->ligCaretTable.otl); dnaFREE(h->markAttachClasses); if (h->markAttachClassTable != NULL) otlTableFree(g, h->markAttachClassTable); dnaFREE(h->markSetClasses); if (h->tbl.MarkGlyphSetsDefOffset != 0) { for (i = 0; i < h->markSetClassTable.markSetEntries.cnt; i++) { MarkSetEntry* markSetEntry = dnaINDEX(h->markSetClassTable.markSetEntries, i); otlTableFree(g, markSetEntry->otl); } dnaFREE(h->markSetClassTable.markSetEntries); } MEM_FREE(g, g->ctx.GDEF); }
/* Free context */ void tcFree(tcCtx g) { tcprivCtx h = g->ctx.tcpriv; /* Free modules */ sindexFree(g); encodingFree(g); charsetFree(g); parseFree(g); csFree(g); recodeFree(g); #if TC_SUBR_SUPPORT subrFree(g); #endif /* TC_SUBR_SUPPORT */ fdselectFree(g); t13Free(g); freeFonts(g); dnaFREE(h->set); MEM_FREE(g, h); g->cb.free(g->cb.ctx, g); /* Free context */ }
void anonFree(hotCtx g) { anonCtx h = g->ctx.anon; dnaFREE(h->tbls); MEM_FREE(g, g->ctx.anon); }
/* Free resources */ void encodingFree(tcCtx g) { encodingCtx h = g->ctx.encoding; dnaFREE(h->encodings); MEM_FREE(g, g->ctx.encoding); }
/* Fill font set from PostScript font files */ static void fillSet(tcCtx g) { tcprivCtx h = g->ctx.tcpriv; int duplicate; int i; Font *last; /* Sort set by font name */ qsort(h->set.array, h->set.cnt, sizeof(Font), cmpFontNames); /* Check for duplicate fonts */ duplicate = 0; last = &h->set.array[0]; for (i = 1; i < h->set.cnt; i++) { Font *curr = &h->set.array[i]; if (strcmp(curr->FontName, last->FontName) == 0) { if (g->cb.message != NULL) { /* Report duplicate FontNames */ char text[513]; sprintf(text, "--- duplicate FontName: %s, files:", curr->FontName); g->cb.message(g->cb.ctx, tcERROR, text); g->cb.message(g->cb.ctx, tcERROR, last->filename); g->cb.message(g->cb.ctx, tcERROR, curr->filename); } duplicate = 1; } last = curr; } if (duplicate) { if (g->cb.message != NULL) { g->cb.message(g->cb.ctx, tcFATAL, "aborting because of errors"); } g->cb.fatal(g->cb.ctx); } /* Handle synthetic fonts */ for (i = 0; i < h->set.cnt; i++) { Font *font = &h->set.array[i]; if (font->flags & FONT_SYNTHETIC) { Font *base = (Font *)bsearch(font->synthetic.baseName, h->set.array, h->set.cnt, sizeof(Font), matchFontName); font->iEncoding = font->synthetic.iEncoding; if (base == NULL) { /* No synthetic base font; make conventional font */ dnaFREE(font->synthetic.dict); font->flags &= ~FONT_SYNTHETIC; } else { /* Synthetic base found: make synthetic font */ csFreeFont(g, font); dnaFREE(font->Private); font->Private.cnt = 0; /* Build new dict with SyntheticBase op first */ font->dict.cnt = 0; dictSaveInt(&font->dict, base - h->set.array); DICTSAVEOP(font->dict, cff_SyntheticBase); /* Append the other synthetic ops to dict */ COPY(dnaEXTEND(font->dict, font->synthetic.dict.cnt), font->synthetic.dict.array, font->synthetic.dict.cnt); dnaFREE(font->synthetic.dict); } MEM_FREE(g, font->synthetic.baseName); } } #if TC_SUBR_SUPPORT if (g->flags & TC_SUBRIZE) { subrSubrize(g, h->set.cnt, h->set.array); } #endif /* TC_SUBR_SUPPORT */ if (t13CheckAuth(g, &h->set.array[0]) && h->set.cnt != 1) { tcFatal(g, "authentication applied to multiple fonts"); } h->size.encodings = encodingFill(g); h->size.charsets = charsetFill(g); h->size.strings = sindexSize(g); h->size.FDSelects = fdselectFill(g); fillOffsets(h); h->FontSet.size = h->offset.copyright + ((h->copyright == NULL) ? 0 : strlen(h->copyright)); }