static fz_error * parseTTCs(char *path) { fz_error *err = nil; int byteread; fz_stream *file = nil; FONT_COLLECTION fontcollectioin; ULONG i; err = fz_openrfile(&file, path); if(err) goto cleanup; SAFE_FZ_READ(file, &fontcollectioin, sizeof(FONT_COLLECTION)); if(memcmp(fontcollectioin.Tag,"ttcf",sizeof(fontcollectioin.Tag)) == 0) { fontcollectioin.Version = SWAPLONG(fontcollectioin.Version); fontcollectioin.NumFonts = SWAPLONG(fontcollectioin.NumFonts); if( fontcollectioin.Version == TTC_VERSION1 || fontcollectioin.Version == TTC_VERSION2 ) { ULONG *offsettable = fz_malloc(sizeof(ULONG)*fontcollectioin.NumFonts); if(offsettable == nil) { err = fz_outofmem; goto cleanup; } SAFE_FZ_READ(file, offsettable, sizeof(ULONG)*fontcollectioin.NumFonts); for(i = 0; i < fontcollectioin.NumFonts; ++i) { offsettable[i] = SWAPLONG(offsettable[i]); parseTTF(file,offsettable[i],i,path); } fz_free(offsettable); } else { err = fz_throw("fonterror : invalid version"); goto cleanup; } } else { err = fz_throw("fonterror: wrong format"); goto cleanup; } cleanup: if(file) fz_dropstream(file); return err; }
static fz_error parseTTFs(char *path, pdf_xref *xref) { fz_error err; fz_stream *file = fz_open_file(xref->ctx, path); if (!file) return fz_error_make(xref->ctx, "fonterror : %s not found", path); err = parseTTF(file, 0, 0, path, xref); fz_close(file); return err; }
static fz_error parseTTCs(char *path, pdf_xref *xref) { FONT_COLLECTION fontcollection; ULONG i, numFonts, *offsettable = NULL; fz_error err; fz_stream *file = fz_open_file(xref->ctx, path); if (!file) { err = fz_error_make(xref->ctx, "fonterror : %s not found", path); goto cleanup; } err = safe_read(file, (char *)&fontcollection, sizeof(FONT_COLLECTION)); if (err) goto cleanup; if (BEtoHl(fontcollection.Tag) != TTAG_ttcf) { err = fz_error_make(xref->ctx, "fonterror : wrong format"); goto cleanup; } if (BEtoHl(fontcollection.Version) != TTC_VERSION1 && BEtoHl(fontcollection.Version) != TTC_VERSION2) { err = fz_error_make(xref->ctx, "fonterror : invalid version"); goto cleanup; } numFonts = BEtoHl(fontcollection.NumFonts); offsettable = fz_calloc(xref->ctx, numFonts, sizeof(ULONG)); err = safe_read(file, (char *)offsettable, numFonts * sizeof(ULONG)); for (i = 0; i < numFonts && !err; i++) err = parseTTF(file, BEtoHl(offsettable[i]), i, path, xref); cleanup: fz_free(xref->ctx, offsettable); if (file) fz_close(file); return err; }
static fz_error * parseTTFs(char *path) { fz_error *err = nil; fz_stream *file = nil; err = fz_openrfile(&file, path); if(err) goto cleanup; err = parseTTF(file,0,0,path); if(err) goto cleanup; cleanup: if(file) fz_dropstream(file); return err; }