summaryrefslogtreecommitdiff
path: root/apps/mupdfextract.c
diff options
context:
space:
mode:
authorRobin Watts <robin.watts@artifex.com>2012-02-26 11:15:16 -0800
committerRobin Watts <robin@ghostscript.com>2012-02-26 19:36:30 +0000
commitbbfe635555dce16858403706e2031dd3bfa1a9f1 (patch)
tree6e414005f04f233a83dbeec5607c0665a6d498bc /apps/mupdfextract.c
parentca578b08dc1243dc6cbb3235272d52d9e2336925 (diff)
downloadmupdf-bbfe635555dce16858403706e2031dd3bfa1a9f1.tar.xz
Move fz_obj to be pdf_obj.
Currently, we are in the slightly strange position of having the PDF specific object types as part of fitz. Here we pull them out into the pdf layer instead. This has been made possible by the recent changes to make the store no longer be tied to having fz_obj's as keys. Most of this work is a simple huge rename; to help customers who may have code that use such functions we have provided a sed script to do the renaming; scripts/rename2.sed. Various other small tweaks are required; the store used to have some debugging code that still required knowledge of fz_obj types - we extract that into a nicer 'type' based function pointer. Also, the type 3 font handling used to have an fz_obj pointer for type 3 resources, and therefore needed to know how to free this; this has become a void * with a function to free it.
Diffstat (limited to 'apps/mupdfextract.c')
-rw-r--r--apps/mupdfextract.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/apps/mupdfextract.c b/apps/mupdfextract.c
index 239e9ea7..dd3066f5 100644
--- a/apps/mupdfextract.c
+++ b/apps/mupdfextract.c
@@ -17,26 +17,26 @@ static void usage(void)
exit(1);
}
-static int isimage(fz_obj *obj)
+static int isimage(pdf_obj *obj)
{
- fz_obj *type = fz_dict_gets(obj, "Subtype");
- return fz_is_name(type) && !strcmp(fz_to_name(type), "Image");
+ pdf_obj *type = pdf_dict_gets(obj, "Subtype");
+ return pdf_is_name(type) && !strcmp(pdf_to_name(type), "Image");
}
-static int isfontdesc(fz_obj *obj)
+static int isfontdesc(pdf_obj *obj)
{
- fz_obj *type = fz_dict_gets(obj, "Type");
- return fz_is_name(type) && !strcmp(fz_to_name(type), "FontDescriptor");
+ pdf_obj *type = pdf_dict_gets(obj, "Type");
+ return pdf_is_name(type) && !strcmp(pdf_to_name(type), "FontDescriptor");
}
static void saveimage(int num)
{
fz_image *image;
fz_pixmap *img;
- fz_obj *ref;
+ pdf_obj *ref;
char name[1024];
- ref = fz_new_indirect(ctx, num, 0, doc);
+ ref = pdf_new_indirect(ctx, num, 0, doc);
/* TODO: detect DCTD and save as jpeg */
@@ -67,49 +67,49 @@ static void saveimage(int num)
}
fz_drop_pixmap(ctx, img);
- fz_drop_obj(ref);
+ pdf_drop_obj(ref);
}
-static void savefont(fz_obj *dict, int num)
+static void savefont(pdf_obj *dict, int num)
{
char name[1024];
char *subtype;
fz_buffer *buf;
- fz_obj *stream = NULL;
- fz_obj *obj;
+ pdf_obj *stream = NULL;
+ pdf_obj *obj;
char *ext = "";
FILE *f;
char *fontname = "font";
int n;
- obj = fz_dict_gets(dict, "FontName");
+ obj = pdf_dict_gets(dict, "FontName");
if (obj)
- fontname = fz_to_name(obj);
+ fontname = pdf_to_name(obj);
- obj = fz_dict_gets(dict, "FontFile");
+ obj = pdf_dict_gets(dict, "FontFile");
if (obj)
{
stream = obj;
ext = "pfa";
}
- obj = fz_dict_gets(dict, "FontFile2");
+ obj = pdf_dict_gets(dict, "FontFile2");
if (obj)
{
stream = obj;
ext = "ttf";
}
- obj = fz_dict_gets(dict, "FontFile3");
+ obj = pdf_dict_gets(dict, "FontFile3");
if (obj)
{
stream = obj;
- obj = fz_dict_gets(obj, "Subtype");
- if (obj && !fz_is_name(obj))
+ obj = pdf_dict_gets(obj, "Subtype");
+ if (obj && !pdf_is_name(obj))
fz_throw(ctx, "Invalid font descriptor subtype");
- subtype = fz_to_name(obj);
+ subtype = pdf_to_name(obj);
if (!strcmp(subtype, "Type1C"))
ext = "cff";
else if (!strcmp(subtype, "CIDFontType0C"))
@@ -124,7 +124,7 @@ static void savefont(fz_obj *dict, int num)
return;
}
- buf = pdf_load_stream(doc, fz_to_num(stream), fz_to_gen(stream));
+ buf = pdf_load_stream(doc, pdf_to_num(stream), pdf_to_gen(stream));
sprintf(name, "%s-%04d.%s", fontname, num, ext);
printf("extracting font %s\n", name);
@@ -145,7 +145,7 @@ static void savefont(fz_obj *dict, int num)
static void showobject(int num)
{
- fz_obj *obj;
+ pdf_obj *obj;
if (!doc)
fz_throw(ctx, "no file specified");
@@ -157,7 +157,7 @@ static void showobject(int num)
else if (isfontdesc(obj))
savefont(obj, num);
- fz_drop_obj(obj);
+ pdf_drop_obj(obj);
}
#ifdef MUPDF_COMBINED_EXE