diff options
38 files changed, 343 insertions, 1098 deletions
@@ -16,4 +16,3 @@ SubInclude TOP fitz ; SubInclude TOP fitzdraw ; SubInclude TOP mupdf ; SubInclude TOP apps ; - diff --git a/apps/Jamfile b/apps/Jamfile index 08d8bad5..0d745403 100644 --- a/apps/Jamfile +++ b/apps/Jamfile @@ -16,33 +16,40 @@ LinkLibraries pdfclean : libpdftool $(FITZLIBS) ; Main pdfdraw : pdfdraw.c ; LinkLibraries pdfdraw : libpdftool $(FITZLIBS) ; -Main pdfinfo : pdfinfo.c ; -LinkLibraries pdfinfo : libpdftool $(FITZLIBS) ; +# Main pdfinfo : pdfinfo.c ; +# LinkLibraries pdfinfo : libpdftool $(FITZLIBS) ; Main pdfextract : pdfextract.c ; LinkLibraries pdfextract : libpdftool $(FITZLIBS) ; +SubDir TOP apps common ; +Library libpdfapp : pdfapp.c ; + +SubDir TOP apps common ; +Library libpdftool : pdftool.c ; + if $(BUILD_WINAPP) { - Main mupdf : win_main.c win_res.rc ; + SubDir TOP apps windows ; + Main mupdf : winmain.c winres.rc ; LinkLibraries mupdf : libpdfapp $(FITZLIBS) ; LINKLIBS on mupdf$(SUFEXE) = $(LINKLIBS) $(APPLINKLIBS) ; } if $(BUILD_X11APP) { - Main mupdf : x11_main.c x11_image.c ; + SubDir TOP apps unix ; + Main mupdf : x11pdf.c ximage.c ; LinkLibraries mupdf : libpdfapp $(FITZLIBS) ; LINKLIBS on mupdf$(SUFEXE) = $(LINKLIBS) $(APPLINKLIBS) ; } if $(BUILD_PLUGIN) { - SubDir TOP apps mozilla ; - SUFEXE on npmupdf.dll = ; - LINKFLAGS on npmupdf.dll = $(LINKFLAGS) -shared -Wl,--kill-at ; - LINKLIBS on npmupdf.dll = $(LINKLIBS) $(APPLINKLIBS) ; - Main npmupdf.dll : npwin.c moz_winres.rc moz_main.c ; - LinkLibraries npmupdf.dll : $(FITZLIBS) ; + SubDir TOP apps mozilla ; + SUFEXE on npmupdf.dll = ; + LINKFLAGS on npmupdf.dll = $(LINKFLAGS) -shared -Wl,--kill-at ; + LINKLIBS on npmupdf.dll = $(LINKLIBS) $(APPLINKLIBS) ; + Main npmupdf.dll : npwin.c moz_winres.rc moz_main.c ; + LinkLibraries npmupdf.dll : $(FITZLIBS) ; } - diff --git a/apps/pdfdraw.c b/apps/pdfdraw.c index 31d78d39..7fc07a2b 100644 --- a/apps/pdfdraw.c +++ b/apps/pdfdraw.c @@ -47,7 +47,7 @@ static void local_cleanup(void) if (drawgc) { - fz_droprenderer(drawgc); +// fz_droprenderer(drawgc); drawgc = nil; } } @@ -60,8 +60,6 @@ static void drawusage(void) " -d -\tpassword for decryption\n" " -o -\tpattern (%%d for page number) for output file\n" " -r -\tresolution in dpi\n" - " -t \tutf-8 text output instead of graphics\n" - " -x \txml dump of display tree\n" " -m \tprint benchmark results\n" " example:\n" " pdfdraw -o output%%03d.pnm input.pdf 1-3,5,9-\n"); @@ -195,9 +193,9 @@ static void drawpnm(int pagenum, struct benchmark *loadtimes, struct benchmark * if (drawbands > 1) fprintf(stderr, "drawing band %d / %d\n", b + 1, drawbands); - error = fz_rendertreeover(drawgc, pix, drawpage->tree, ctm); - if (error) - die(error); +//XXX error = fz_rendertreeover(drawgc, pix, drawpage->tree, ctm); +// if (error) +// die(error); if (drawpattern) { @@ -266,35 +264,6 @@ static void drawpnm(int pagenum, struct benchmark *loadtimes, struct benchmark * fprintf(stderr, "\n"); } -static void drawtxt(int pagenum) -{ - fz_error error; - pdf_textline *line; - fz_matrix ctm; - - drawloadpage(pagenum, NULL); - - ctm = fz_concat( - fz_translate(0, -drawpage->mediabox.y1), - fz_scale(drawzoom, -drawzoom)); - - error = pdf_loadtextfromtree(&line, drawpage->tree, ctm); - if (error) - die(error); - - pdf_debugtextline(line); - pdf_droptextline(line); - - drawfreepage(); -} - -static void drawxml(int pagenum) -{ - drawloadpage(pagenum, NULL); - fz_debugtree(drawpage->tree); - drawfreepage(); -} - static void drawpages(char *pagelist) { int page, spage, epage; @@ -344,8 +313,8 @@ static void drawpages(char *pagelist) switch (drawmode) { case DRAWPNM: drawpnm(page, &loadtimes, &drawtimes); break; - case DRAWTXT: drawtxt(page); break; - case DRAWXML: drawxml(page); break; +// case DRAWTXT: drawtxt(page); break; +// case DRAWXML: drawxml(page); break; } } @@ -410,9 +379,9 @@ int main(int argc, char **argv) closexref(); - error = fz_newrenderer(&drawgc, pdf_devicergb, 0, 1024 * 512); - if (error) - die(error); +//XXX error = fz_newrenderer(&drawgc, pdf_devicergb, 0, 1024 * 512); +// if (error) +// die(error); openxref(argv[fz_optind], password, 0); state = NO_PAGES_DRAWN; diff --git a/fitz/Jamfile b/fitz/Jamfile index f9d8d5f5..14b15d74 100644 --- a/fitz/Jamfile +++ b/fitz/Jamfile @@ -68,22 +68,15 @@ if $(HAVE_JBIG2DEC) { Library libfitz : filt_jbig2d.c ; } if $(HAVE_OPENJPEG) { Library libfitz : filt_jpxd.c ; } # -# Resources and display tree. +# Resources. # Library libfitz : - - node_toxml.c - node_misc1.c - node_misc2.c node_path.c node_text.c - node_tree.c - res_colorspace.c res_font.c res_image.c res_shade.c - ; diff --git a/fitz/fitz.h b/fitz/fitz.h index 0e9bcd08..caba61e4 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -3,7 +3,7 @@ #include "fitz_base.h" #include "fitz_stream.h" -#include "fitz_tree.h" +#include "fitz_res.h" #include "fitz_draw.h" #endif diff --git a/fitz/fitz_draw.h b/fitz/fitz_draw.h index 7e3baa9e..c22b8a1c 100644 --- a/fitz/fitz_draw.h +++ b/fitz/fitz_draw.h @@ -60,10 +60,9 @@ void fz_dropael(fz_ael *ael); fz_error fz_scanconvert(fz_gel *gel, fz_ael *ael, int eofill, fz_irect clip, fz_pixmap *pix, unsigned char *argb, int over); -fz_error fz_fillpath(fz_gel *gel, fz_pathnode *path, fz_matrix ctm, float flatness); -fz_error fz_strokepath(fz_gel *gel, fz_pathnode *path, fz_matrix ctm, float flatness, float linewidth); -fz_error fz_dashpath(fz_gel *gel, fz_pathnode *path, fz_matrix ctm, float flatness, float linewidth); - +fz_error fz_fillpath(fz_gel *gel, fz_path *path, fz_matrix ctm, float flatness); +fz_error fz_strokepath(fz_gel *gel, fz_path *path, fz_matrix ctm, float flatness, float linewidth); +fz_error fz_dashpath(fz_gel *gel, fz_path *path, fz_matrix ctm, float flatness, float linewidth); /* * Function pointers -- they can be replaced by cpu-optimized versions @@ -132,9 +131,5 @@ struct fz_renderer_s extern void fz_accelerate(void); -fz_error fz_newrenderer(fz_renderer **gcp, fz_colorspace *pcm, int maskonly, int gcmem); +fz_renderer * fz_newrenderer(fz_colorspace *pcm, int maskonly, int gcmem); void fz_droprenderer(fz_renderer *gc); -fz_error fz_rendertree(fz_pixmap **out, fz_renderer *gc, fz_tree *tree, fz_matrix ctm, fz_irect bbox, int white); -fz_error fz_rendertreeover(fz_renderer *gc, fz_pixmap *dest, fz_tree *tree, fz_matrix ctm); - - diff --git a/fitz/fitz_tree.h b/fitz/fitz_tree.h index 29da14cb..74962048 100644 --- a/fitz/fitz_tree.h +++ b/fitz/fitz_tree.h @@ -319,7 +319,7 @@ struct fz_colorspace_s void (*convcolor)(fz_colorspace *ss, float *sv, fz_colorspace *ds, float *dv); void (*toxyz)(fz_colorspace *, float *src, float *xyz); void (*fromxyz)(fz_colorspace *, float *xyz, float *dst); - void (*freefunc)(fz_colorspace *); + void (*drop)(fz_colorspace *); }; struct fz_colorcube1_s { unsigned char v[17]; }; @@ -386,7 +386,7 @@ struct fz_image_s { int refs; fz_error (*loadtile)(fz_image*,fz_pixmap*); - void (*freefunc)(fz_image*); + void (*drop)(fz_image*); fz_colorspace *cs; int w, h, n, a; }; diff --git a/fitz/node_misc1.c b/fitz/node_misc1.c index 48bd1278..128406e3 100644 --- a/fitz/node_misc1.c +++ b/fitz/node_misc1.c @@ -32,44 +32,39 @@ fz_initnode(fz_node *node, fz_nodekind kind) void fz_dropnode(fz_node *node) { - fz_node *next; + if (node->first) + fz_dropnode(node->first); + if (node->next) + fz_dropnode(node->next); - while (node) + switch (node->kind) { - if (node->first) - fz_dropnode(node->first); - - switch (node->kind) - { - case FZ_NTRANSFORM: - case FZ_NOVER: - case FZ_NMASK: - case FZ_NBLEND: - break; - case FZ_NCOLOR: - fz_dropsolidnode((fz_solidnode *) node); - break; - case FZ_NPATH: - fz_droppathnode((fz_pathnode *) node); - break; - case FZ_NTEXT: - fz_droptextnode((fz_textnode *) node); - break; - case FZ_NIMAGE: - fz_dropimagenode((fz_imagenode *) node); - break; - case FZ_NSHADE: - fz_dropshadenode((fz_shadenode *) node); - break; - case FZ_NLINK: - fz_droplinknode((fz_linknode *) node); - break; - } - - next = node->next; - fz_free(node); - node = next; + case FZ_NTRANSFORM: + case FZ_NOVER: + case FZ_NMASK: + case FZ_NBLEND: + break; + case FZ_NCOLOR: + fz_dropsolidnode((fz_solidnode *) node); + break; + case FZ_NPATH: + fz_droppathnode((fz_pathnode *) node); + break; + case FZ_NTEXT: + fz_droptextnode((fz_textnode *) node); + break; + case FZ_NIMAGE: + fz_dropimagenode((fz_imagenode *) node); + break; + case FZ_NSHADE: + fz_dropshadenode((fz_shadenode *) node); + break; + case FZ_NLINK: + fz_droplinknode((fz_linknode *) node); + break; } + + fz_free(node); } fz_rect diff --git a/fitz/node_misc2.c b/fitz/node_misc2.c deleted file mode 100644 index 330c09de..00000000 --- a/fitz/node_misc2.c +++ /dev/null @@ -1,296 +0,0 @@ -#include "fitz_base.h" -#include "fitz_tree.h" - -/* - * Over - */ - -fz_error -fz_newovernode(fz_node **nodep) -{ - fz_node *node; - - node = *nodep = fz_malloc(sizeof (fz_overnode)); - if (!node) - return fz_rethrow(-1, "out of memory"); - - fz_initnode(node, FZ_NOVER); - - return fz_okay; -} - -fz_rect -fz_boundovernode(fz_overnode *node, fz_matrix ctm) -{ - fz_node *child; - fz_rect bbox; - fz_rect temp; - - child = node->super.first; - if (!child) - return fz_emptyrect; - - bbox = fz_boundnode(child, ctm); - - child = child->next; - while (child) - { - temp = fz_boundnode(child, ctm); - bbox = fz_mergerects(temp, bbox); - child = child->next; - } - - return bbox; -} - -/* - * Mask - */ - -fz_error -fz_newmasknode(fz_node **nodep) -{ - fz_node *node; - - node = *nodep = fz_malloc(sizeof (fz_masknode)); - if (!node) - return fz_rethrow(-1, "out of memory"); - - fz_initnode(node, FZ_NMASK); - - return fz_okay; -} - -fz_rect -fz_boundmasknode(fz_masknode *node, fz_matrix ctm) -{ - fz_node *shape; - fz_node *color; - fz_rect one, two; - - shape = node->super.first; - color = shape->next; - - one = fz_boundnode(shape, ctm); - two = fz_boundnode(color, ctm); - return fz_intersectrects(one, two); -} - -/* - * Blend - */ - -fz_error -fz_newblendnode(fz_node **nodep, fz_blendkind b, int i, int k) -{ - fz_blendnode *node; - - node = fz_malloc(sizeof (fz_blendnode)); - if (!node) - return fz_rethrow(-1, "out of memory"); - *nodep = (fz_node*)node; - - fz_initnode((fz_node*)node, FZ_NBLEND); - node->mode = b; - node->isolated = i; - node->knockout = k; - - return fz_okay; -} - -fz_rect -fz_boundblendnode(fz_blendnode *node, fz_matrix ctm) -{ - fz_node *child; - fz_rect bbox; - fz_rect temp; - - child = node->super.first; - if (!child) - return fz_emptyrect; - - bbox = fz_boundnode(child, ctm); - - child = child->next; - while (child) - { - temp = fz_boundnode(child, ctm); - bbox = fz_mergerects(temp, bbox); - child = child->next; - } - - return bbox; -} - -void -fz_dropblendnode(fz_blendnode *node) -{ - fz_dropcolorspace(node->cs); -} - -/* - * Transform - */ - -fz_error -fz_newtransformnode(fz_node **nodep, fz_matrix m) -{ - fz_transformnode *node; - - node = fz_malloc(sizeof (fz_transformnode)); - if (!node) - return fz_rethrow(-1, "out of memory"); - *nodep = (fz_node*)node; - - fz_initnode((fz_node*)node, FZ_NTRANSFORM); - node->m = m; - - return fz_okay; -} - -fz_rect -fz_boundtransformnode(fz_transformnode *node, fz_matrix ctm) -{ - if (!node->super.first) - return fz_emptyrect; - return fz_boundnode(node->super.first, fz_concat(node->m, ctm)); -} - -/* - * Link to tree - */ - -fz_error -fz_newlinknode(fz_node **nodep, fz_tree *subtree) -{ - fz_linknode *node; - - node = fz_malloc(sizeof (fz_linknode)); - if (!node) - return fz_rethrow(-1, "out of memory"); - *nodep = (fz_node*)node; - - fz_initnode((fz_node*)node, FZ_NLINK); - node->tree = fz_keeptree(subtree); - - return fz_okay; -} - -void -fz_droplinknode(fz_linknode *node) -{ - fz_droptree(node->tree); -} - -fz_rect -fz_boundlinknode(fz_linknode *node, fz_matrix ctm) -{ - return fz_boundtree(node->tree, ctm); -} - -/* - * Solid color - */ - -fz_error -fz_newsolidnode(fz_node **nodep, float a, fz_colorspace *cs, int n, float *v) -{ - fz_solidnode *node; - int i; - - node = fz_malloc(sizeof(fz_solidnode) + sizeof(float) * n); - if (!node) - return fz_rethrow(-1, "out of memory"); - *nodep = (fz_node*)node; - - fz_initnode((fz_node*)node, FZ_NCOLOR); - node->a = a; - node->cs = fz_keepcolorspace(cs); - node->n = n; - for (i = 0; i < n; i++) - node->samples[i] = v[i]; - - return fz_okay; -} - -fz_rect -fz_boundsolidnode(fz_solidnode *node, fz_matrix ctm) -{ - return fz_infiniterect; -} - -void -fz_dropsolidnode(fz_solidnode *node) -{ - fz_dropcolorspace(node->cs); -} - -/* - * Image node - */ - -fz_error -fz_newimagenode(fz_node **nodep, fz_image *image) -{ - fz_imagenode *node; - - node = fz_malloc(sizeof (fz_imagenode)); - if (!node) - return fz_rethrow(-1, "out of memory"); - *nodep = (fz_node*)node; - - fz_initnode((fz_node*)node, FZ_NIMAGE); - node->image = fz_keepimage(image); - - return fz_okay; -} - -void -fz_dropimagenode(fz_imagenode *node) -{ - fz_dropimage(node->image); -} - -fz_rect -fz_boundimagenode(fz_imagenode *node, fz_matrix ctm) -{ - fz_rect bbox; - bbox.x0 = 0; - bbox.y0 = 0; - bbox.x1 = 1; - bbox.y1 = 1; - return fz_transformaabb(ctm, bbox); -} - -/* - * Shade node - */ - -fz_error -fz_newshadenode(fz_node **nodep, fz_shade *shade) -{ - fz_shadenode *node; - - node = fz_malloc(sizeof (fz_shadenode)); - if (!node) - return fz_rethrow(-1, "out of memory"); - *nodep = (fz_node*)node; - - fz_initnode((fz_node*)node, FZ_NSHADE); - node->shade = fz_keepshade(shade); - - return fz_okay; -} - -void -fz_dropshadenode(fz_shadenode *node) -{ - fz_dropshade(node->shade); -} - -fz_rect -fz_boundshadenode(fz_shadenode *node, fz_matrix ctm) -{ - return fz_boundshade(node->shade, ctm); -} - diff --git a/fitz/node_path.c b/fitz/node_path.c index 1ef469eb..bca274d3 100644 --- a/fitz/node_path.c +++ b/fitz/node_path.c @@ -1,17 +1,12 @@ #include "fitz_base.h" -#include "fitz_tree.h" +#include "fitz_res.h" -fz_error -fz_newpathnode(fz_pathnode **pathp) +fz_path * +fz_newpath(void) { - fz_pathnode *path; - - path = *pathp = fz_malloc(sizeof(fz_pathnode)); - if (!path) - return fz_rethrow(-1, "out of memory"); - - fz_initnode((fz_node*)path, FZ_NPATH); + fz_path *path; + path = fz_malloc(sizeof(fz_path)); path->paint = FZ_FILL; path->linecap = 0; path->linejoin = 0; @@ -22,99 +17,55 @@ fz_newpathnode(fz_pathnode **pathp) path->cap = 0; path->els = nil; - return fz_okay; -} - -fz_error -fz_clonepathnode(fz_pathnode **pathp, fz_pathnode *oldpath) -{ - fz_pathnode *path; - - path = *pathp = fz_malloc(sizeof(fz_pathnode)); - if (!path) - return fz_rethrow(-1, "out of memory"); - - fz_initnode((fz_node*)path, FZ_NPATH); - - path->paint = FZ_FILL; - path->linecap = 0; - path->linejoin = 0; - path->linewidth = 1.0; - path->miterlimit = 10.0; - path->dash = nil; - path->len = oldpath->len; - path->cap = oldpath->len; - - path->els = fz_malloc(sizeof (fz_pathel) * path->len); - if (!path->els) { - fz_free(path); - return fz_rethrow(-1, "out of memory"); - } - memcpy(path->els, oldpath->els, sizeof(fz_pathel) * path->len); - - return fz_okay; + return path; } void -fz_droppathnode(fz_pathnode *node) +fz_droppath(fz_path *node) { fz_free(node->dash); fz_free(node->els); } -static fz_error -growpath(fz_pathnode *path, int n) +static void +growpath(fz_path *path, int n) { - int newcap; - fz_pathel *newels; - + if (path->len + n < path->cap) + return; while (path->len + n > path->cap) - { - newcap = path->cap + 36; - newels = fz_realloc(path->els, sizeof (fz_pathel) * newcap); - if (!newels) - return fz_rethrow(-1, "out of memory"); - path->cap = newcap; - path->els = newels; - } - - return fz_okay; + path->cap = path->cap + 36; + path->els = fz_realloc(path->els, sizeof (fz_pathel) * path->cap); } -fz_error -fz_moveto(fz_pathnode *path, float x, float y) +void +fz_moveto(fz_path *path, float x, float y) { - if (growpath(path, 3) != fz_okay) - return fz_rethrow(-1, "out of memory"); + growpath(path, 3); path->els[path->len++].k = FZ_MOVETO; path->els[path->len++].v = x; path->els[path->len++].v = y; - return fz_okay; } -fz_error -fz_lineto(fz_pathnode *path, float x, float y) +void +fz_lineto(fz_path *path, float x, float y) { if (path->len == 0) - return fz_throw("no current point"); - if (growpath(path, 3) != fz_okay) - return fz_rethrow(-1, "out of memory"); + fz_moveto(path, 0, 0); + growpath(path, 3); path->els[path->len++].k = FZ_LINETO; path->els[path->len++].v = x; path->els[path->len++].v = y; - return fz_okay; } -fz_error -fz_curveto(fz_pathnode *path, +void +fz_curveto(fz_path *path, float x1, float y1, float x2, float y2, float x3, float y3) { if (path->len == 0) - return fz_throw("no current point"); - if (growpath(path, 7) != fz_okay) - return fz_rethrow(-1, "out of memory"); + fz_moveto(path, 0, 0); + growpath(path, 7); path->els[path->len++].k = FZ_CURVETO; path->els[path->len++].v = x1; path->els[path->len++].v = y1; @@ -122,40 +73,33 @@ fz_curveto(fz_pathnode *path, path->els[path->len++].v = y2; path->els[path->len++].v = x3; path->els[path->len++].v = y3; - return fz_okay; } -fz_error -fz_curvetov(fz_pathnode *path, float x2, float y2, float x3, float y3) +void +fz_curvetov(fz_path *path, float x2, float y2, float x3, float y3) { float x1 = path->els[path->len-2].v; float y1 = path->els[path->len-1].v; - return fz_curveto(path, x1, y1, x2, y2, x3, y3); + fz_curveto(path, x1, y1, x2, y2, x3, y3); } -fz_error -fz_curvetoy(fz_pathnode *path, float x1, float y1, float x3, float y3) +void +fz_curvetoy(fz_path *path, float x1, float y1, float x3, float y3) { - return fz_curveto(path, x1, y1, x3, y3, x3, y3); + fz_curveto(path, x1, y1, x3, y3, x3, y3); } -fz_error -fz_closepath(fz_pathnode *path) +void +fz_closepath(fz_path *path) { if (path->len == 0) - { - fz_warn("tried to close an empty path"); - return fz_okay; - } - - if (growpath(path, 1) != fz_okay) - return fz_rethrow(-1, "out of memory"); + return; + growpath(path, 1); path->els[path->len++].k = FZ_CLOSEPATH; - return fz_okay; } -fz_error -fz_endpath(fz_pathnode *path, fz_pathkind paint, fz_stroke *stroke, fz_dash *dash) +void +fz_setpathstate(fz_path *path, fz_pathkind paint, fz_stroke *stroke, fz_dash *dash) { path->paint = paint; path->dash = dash; @@ -166,8 +110,6 @@ fz_endpath(fz_pathnode *path, fz_pathkind paint, fz_stroke *stroke, fz_dash *das path->linewidth = stroke->linewidth; path->miterlimit = stroke->miterlimit; } - - return fz_okay; } static inline fz_rect boundexpand(fz_rect r, fz_point p) @@ -180,7 +122,7 @@ static inline fz_rect boundexpand(fz_rect r, fz_point p) } fz_rect -fz_boundpathnode(fz_pathnode *path, fz_matrix ctm) +fz_boundpath(fz_path *path, fz_matrix ctm) { fz_point p; fz_rect r = fz_emptyrect; @@ -232,7 +174,7 @@ fz_boundpathnode(fz_pathnode *path, fz_matrix ctm) } void -fz_printpathnode(fz_pathnode *path, int indent) +fz_printpath(fz_path *path, int indent) { float x, y; int i = 0; @@ -287,7 +229,7 @@ fz_printpathnode(fz_pathnode *path, int indent) } void -fz_debugpathnode(fz_pathnode *path, int indent) +fz_debugpath(fz_path *path, int indent) { float x, y; int i = 0; @@ -325,22 +267,19 @@ fz_debugpathnode(fz_pathnode *path, int indent) } } -fz_error -fz_newdash(fz_dash **dashp, float phase, int len, float *array) +fz_dash * +fz_newdash(float phase, int len, float *array) { fz_dash *dash; int i; - dash = *dashp = fz_malloc(sizeof(fz_dash) + sizeof(float) * len); - if (!dash) - return fz_rethrow(-1, "out of memory"); - + dash = fz_malloc(sizeof(fz_dash) + sizeof(float) * len); dash->len = len; dash->phase = phase; for (i = 0; i < len; i++) dash->array[i] = array[i]; - return fz_okay; + return dash; } void diff --git a/fitz/node_text.c b/fitz/node_text.c index c7d973b7..8f11ed26 100644 --- a/fitz/node_text.c +++ b/fitz/node_text.c @@ -1,67 +1,30 @@ #include "fitz_base.h" -#include "fitz_tree.h" +#include "fitz_res.h" -fz_error -fz_newtextnode(fz_textnode **textp, fz_font *font) +fz_text * +fz_newtext(fz_font *font) { - fz_textnode *text; - - text = fz_malloc(sizeof(fz_textnode)); - if (!text) - return fz_rethrow(-1, "out of memory"); - - fz_initnode((fz_node*)text, FZ_NTEXT); + fz_text *text; + text = fz_malloc(sizeof(fz_text)); text->font = fz_keepfont(font); text->trm = fz_identity(); text->len = 0; text->cap = 0; text->els = nil; - *textp = text; - return fz_okay; -} - -fz_error -fz_clonetextnode(fz_textnode **textp, fz_textnode *oldtext) -{ - fz_textnode *text; - - text = *textp = fz_malloc(sizeof(fz_textnode)); - if (!text) - return fz_rethrow(-1, "out of memory"); - - fz_initnode((fz_node*)text, FZ_NTEXT); - - text->font = fz_keepfont(oldtext->font); - text->trm = oldtext->trm; - text->len = oldtext->len; - text->cap = oldtext->len; - text->els = nil; - - text->els = fz_malloc(sizeof(fz_textel) * text->len); - if (!text->els) - { - fz_dropfont(text->font); - fz_free(text); - return fz_rethrow(-1, "out of memory"); - } - - memcpy(text->els, oldtext->els, sizeof(fz_textel) * text->len); - - *textp = text; - return fz_okay; + return text; } void -fz_droptextnode(fz_textnode *text) +fz_droptext(fz_text *text) { fz_dropfont(text->font); fz_free(text->els); } fz_rect -fz_boundtextnode(fz_textnode *text, fz_matrix ctm) +fz_boundtext(fz_text *text, fz_matrix ctm) { fz_matrix trm; fz_rect bbox; @@ -109,35 +72,23 @@ fz_boundtextnode(fz_textnode *text, fz_matrix ctm) return bbox; } -static fz_error -growtext(fz_textnode *text, int n) +static void +growtext(fz_text *text, int n) { - int newcap; - fz_textel *newels; - + if (text->len + n < text->cap) + return; while (text->len + n > text->cap) - { - newcap = text->cap + 36; - newels = fz_realloc(text->els, sizeof (fz_textel) * newcap); - if (!newels) - return fz_rethrow(-1, "out of memory"); - text->cap = newcap; - text->els = newels; - } - - return fz_okay; + text->cap = text->cap + 36; + text->els = fz_realloc(text->els, sizeof (fz_textel) * text->cap); } -fz_error -fz_addtext(fz_textnode *text, int gid, int ucs, float x, float y) +void +fz_addtext(fz_text *text, int gid, int ucs, float x, float y) { - if (growtext(text, 1) != fz_okay) - return fz_rethrow(-1, "out of memory"); + growtext(text, 1); text->els[text->len].ucs = ucs; text->els[text->len].gid = gid; text->els[text->len].x = x; text->els[text->len].y = y; text->len++; - return fz_okay; } - diff --git a/fitz/node_toxml.c b/fitz/node_toxml.c deleted file mode 100644 index 173b41b7..00000000 --- a/fitz/node_toxml.c +++ /dev/null @@ -1,186 +0,0 @@ -#include "fitz_base.h" -#include "fitz_tree.h" - -static void indent(int level) -{ - while (level--) - putchar(' '); -} - -static void xmlnode(fz_node *node, int level); - -static void xmlover(fz_overnode *node, int level) -{ - fz_node *child; - indent(level); - printf("<over>\n"); - for (child = node->super.first; child; child = child->next) - xmlnode(child, level + 1); - indent(level); - printf("</over>\n"); -} - -static void xmlmask(fz_masknode *node, int level) -{ - fz_node *child; - indent(level); - printf("<mask>\n"); - for (child = node->super.first; child; child = child->next) - xmlnode(child, level + 1); - indent(level); - printf("</mask>\n"); -} - -static void xmlblend(fz_blendnode *node, int level) -{ - fz_node *child; - indent(level); - printf("<blend mode=\"%d\" isolated=\"%d\" knockout=\"%d\">\n", - node->mode, node->isolated, node->knockout); - for (child = node->super.first; child; child = child->next) - xmlnode(child, level + 1); - indent(level); - printf("</blend>\n"); -} - -static void xmltransform(fz_transformnode *node, int level) -{ - indent(level); - printf("<transform matrix=\"%g %g %g %g %g %g\">\n", - node->m.a, node->m.b, - node->m.c, node->m.d, - node->m.e, node->m.f); - xmlnode(node->super.first, level + 1); - indent(level); - printf("</transform>\n"); -} - -static void xmlsolid(fz_solidnode *node, int level) -{ - int i; - indent(level); - printf("<solid colorspace=\"%s\" alpha=\"%g\" v=\"", node->cs->name, node->a); - for (i = 0; i < node->n; i++) - { - printf("%g", node->samples[i]); - if (i < node->n - 1) - putchar(' '); - } - printf("\" />\n"); -} - -static void xmllink(fz_linknode *node, int level) -{ - indent(level); - printf("<link name=\"%p\" />\n", (void *) node->tree); -} - -static void xmlpath(fz_pathnode *node, int level) -{ - int i; - - indent(level); - - if (node->paint == FZ_STROKE) - { - printf("<path fill=\"stroke\" cap=\"%d\" join=\"%d\" width=\"%g\" miter=\"%g\"", - node->linecap, - node->linejoin, - node->linewidth, - node->miterlimit); - if (node->dash) - { - printf(" phase=\"%g\" array=\"", node->dash->phase); - for (i = 0; i < node->dash->len; i++) - printf("%g ", node->dash->array[i]); - printf("\""); - } - printf(">\n"); - } - else - { - printf("<path fill=\"%s\">\n", - node->paint == FZ_FILL ? "nonzero" : "evenodd"); - } - - fz_debugpathnode(node, level + 2); - - indent(level); - printf("</path>\n"); -} - -static void xmltext(fz_textnode *node, int level) -{ - int i; - - indent(level); - printf("<text font=\"%s\" matrix=\"%g %g %g %g\">\n", node->font->name, - node->trm.a, node->trm.b, node->trm.c, node->trm.d); - - for (i = 0; i < node->len; i++) - { - indent(level + 1); - if (node->els[i].ucs >= 32 && node->els[i].ucs < 128) - printf("<g ucs=\"%c\" gid=%d x=\"%g\" y=\"%g\" />\n", - node->els[i].ucs, node->els[i].gid, node->els[i].x, node->els[i].y); - else - printf("<g ucs=\"U+%04X\" gid=%d x=\"%g\" y=\"%g\" />\n", - node->els[i].ucs, node->els[i].gid, node->els[i].x, node->els[i].y); - } - - indent(level); - printf("</text>\n"); -} - -static void xmlimage(fz_imagenode *node, int level) -{ - fz_image *image = node->image; - indent(level); - printf("<image w=\"%d\" h=\"%d\" n=\"%d\" a=\"%d\" />\n", - image->w, image->h, image->n, image->a); -} - -static void xmlshade(fz_shadenode *node, int level) -{ - indent(level); - printf("<shade />\n"); -} - -static void xmlnode(fz_node *node, int level) -{ - if (!node) - { - indent(level); - printf("<nil />\n"); - return; - } - - switch (node->kind) - { - case FZ_NOVER: xmlover((fz_overnode*)node, level); break; - case FZ_NMASK: xmlmask((fz_masknode*)node, level); break; - case FZ_NBLEND: xmlblend((fz_blendnode*)node, level); break; - case FZ_NTRANSFORM: xmltransform((fz_transformnode*)node, level); break; - case FZ_NCOLOR: xmlsolid((fz_solidnode*)node, level); break; - case FZ_NPATH: xmlpath((fz_pathnode*)node, level); break; - case FZ_NTEXT: xmltext((fz_textnode*)node, level); break; - case FZ_NIMAGE: xmlimage((fz_imagenode*)node, level); break; - case FZ_NSHADE: xmlshade((fz_shadenode*)node, level); break; - case FZ_NLINK: xmllink((fz_linknode*)node, level); break; - } -} - -void -fz_debugnode(fz_node *node) -{ - xmlnode(node, 0); -} - -void -fz_debugtree(fz_tree *tree) -{ - printf("<tree>\n"); - xmlnode(tree->root, 1); - printf("</tree>\n"); -} - diff --git a/fitz/node_tree.c b/fitz/node_tree.c deleted file mode 100644 index 6dc035e1..00000000 --- a/fitz/node_tree.c +++ /dev/null @@ -1,108 +0,0 @@ -#include "fitz_base.h" -#include "fitz_tree.h" - -fz_error -fz_newtree(fz_tree **treep) -{ - fz_tree *tree; - - tree = *treep = fz_malloc(sizeof (fz_tree)); - if (!tree) - return fz_rethrow(-1, "out of memory"); - - tree->refs = 1; - tree->root = nil; - tree->head = nil; - - return fz_okay; -} - -fz_tree * -fz_keeptree(fz_tree *tree) -{ - tree->refs ++; - return tree; -} - -void -fz_droptree(fz_tree *tree) -{ - if (--tree->refs == 0) - { - if (tree->root) - fz_dropnode(tree->root); - fz_free(tree); - } -} - -fz_rect -fz_boundtree(fz_tree *tree, fz_matrix ctm) -{ - if (tree->root) - return fz_boundnode(tree->root, ctm); - return fz_emptyrect; -} - -void -fz_insertnodefirst(fz_node *parent, fz_node *child) -{ - child->parent = parent; - child->next = parent->first; - parent->first = child; - if (!parent->last) - parent->last = child; -} - -void -fz_insertnodelast(fz_node *parent, fz_node *child) -{ - child->parent = parent; - if (!parent->first) - parent->first = child; - else - parent->last->next = child; - parent->last = child; -} - -void -fz_insertnodeafter(fz_node *prev, fz_node *child) -{ - fz_node *parent = prev->parent; - child->parent = parent; - if (parent->last == prev) - parent->last = child; - child->next = prev->next; - prev->next = child; -} - -void -fz_removenode(fz_node *child) -{ - fz_node *parent = child->parent; - fz_node *prev; - fz_node *node; - - if (parent->first == child) - { - parent->first = child->next; - if (parent->last == child) - parent->last = nil; - return; - } - - prev = parent->first; - node = prev->next; - - while (node) - { - if (node == child) - { - prev->next = child->next; - } - prev = node; - node = node->next; - } - - parent->last = prev; -} - diff --git a/fitz/res_colorspace.c b/fitz/res_colorspace.c index 9de10973..a3d6f211 100644 --- a/fitz/res_colorspace.c +++ b/fitz/res_colorspace.c @@ -1,5 +1,5 @@ #include "fitz_base.h" -#include "fitz_tree.h" +#include "fitz_res.h" void fz_convertpixmap(fz_colorspace *srcs, fz_pixmap *src, fz_colorspace *dsts, fz_pixmap *dst) diff --git a/fitz/res_font.c b/fitz/res_font.c index 16ff3523..64ba5730 100644 --- a/fitz/res_font.c +++ b/fitz/res_font.c @@ -1,5 +1,6 @@ #include "fitz_base.h" -#include "fitz_tree.h" +#include "fitz_stream.h" +#include "fitz_res.h" #include "fitz_draw.h" /* FIXME -- for glyph rendering callbacks */ #include <ft2build.h> @@ -51,7 +52,7 @@ fz_dropfont(fz_font *font) { for (i = 0; i < 256; i++) if (font->t3procs[i]) - fz_droptree(font->t3procs[i]); + ; // XXX fz_droptree(font->t3procs[i]); fz_free(font->t3procs); fz_free(font->t3widths); } @@ -338,7 +339,7 @@ fz_newtype3font(char *name, fz_matrix matrix) int i; font = fz_newfont(); - font->t3procs = fz_malloc(sizeof(fz_tree*) * 256); + font->t3procs = fz_malloc(sizeof(fz_buffer*) * 256); font->t3widths = fz_malloc(sizeof(float) * 256); strlcpy(font->name, name, sizeof(font->name)); @@ -358,6 +359,7 @@ extern fz_colorspace *pdf_devicegray; fz_error fz_rendert3glyph(fz_glyph *glyph, fz_font *font, int gid, fz_matrix trm) { +#if 0 // XXX fz_error error; fz_renderer *gc; fz_tree *tree; @@ -401,7 +403,7 @@ fz_rendert3glyph(fz_glyph *glyph, fz_font *font, int gid, fz_matrix trm) glyph->w = pixmap->w; glyph->h = pixmap->h; glyph->samples = pixmap->samples; - +#endif return fz_okay; } diff --git a/fitz/res_image.c b/fitz/res_image.c index e5918c64..3ccc01dc 100644 --- a/fitz/res_image.c +++ b/fitz/res_image.c @@ -1,5 +1,5 @@ #include "fitz_base.h" -#include "fitz_tree.h" +#include "fitz_res.h" fz_image * fz_keepimage(fz_image *image) diff --git a/fitz/res_shade.c b/fitz/res_shade.c index 2d1b1cea..5efa1827 100644 --- a/fitz/res_shade.c +++ b/fitz/res_shade.c @@ -1,5 +1,5 @@ #include "fitz_base.h" -#include "fitz_tree.h" +#include "fitz_res.h" fz_shade * fz_keepshade(fz_shade *shade) diff --git a/fitzdraw/Jamfile b/fitzdraw/Jamfile index c76d9c6d..7c66733c 100644 --- a/fitzdraw/Jamfile +++ b/fitzdraw/Jamfile @@ -8,14 +8,13 @@ Library libfitzdraw : imagedraw.c imageunpack.c imagescale.c - pathscan.c - pathfill.c - pathstroke.c - render.c +# pathscan.c +# pathfill.c +# pathstroke.c +# render.c blendmodes.c ; if $(OSPLAT) = PPC { Library libfitzdraw : archppc.c ; } if $(OSPLAT) = SPARC { Library libfitzdraw : archsparc.c ; } if $(OSPLAT) = X86 { Library libfitzdraw : archx86.c ; } - diff --git a/fitzdraw/archx86.c b/fitzdraw/archx86.c index f3d9ef24..23efa93d 100644 --- a/fitzdraw/archx86.c +++ b/fitzdraw/archx86.c @@ -3,7 +3,7 @@ */ #include "fitz_base.h" -#include "fitz_tree.h" +#include "fitz_res.h" #include "fitz_draw.h" typedef unsigned char byte; diff --git a/fitzdraw/blendmodes.c b/fitzdraw/blendmodes.c index 0b6fedcc..66517d8b 100644 --- a/fitzdraw/blendmodes.c +++ b/fitzdraw/blendmodes.c @@ -1,5 +1,5 @@ #include "fitz_base.h" -#include "fitz_tree.h" +#include "fitz_res.h" #include "fitz_draw.h" typedef unsigned char byte; diff --git a/fitzdraw/glyphcache.c b/fitzdraw/glyphcache.c index 0b602857..a921ba89 100644 --- a/fitzdraw/glyphcache.c +++ b/fitzdraw/glyphcache.c @@ -1,5 +1,5 @@ #include "fitz_base.h" -#include "fitz_tree.h" +#include "fitz_res.h" #include "fitz_draw.h" typedef struct fz_hash_s fz_hash; diff --git a/fitzdraw/imagedraw.c b/fitzdraw/imagedraw.c index 8a7cf2cc..aa1698dc 100644 --- a/fitzdraw/imagedraw.c +++ b/fitzdraw/imagedraw.c @@ -1,5 +1,5 @@ #include "fitz_base.h" -#include "fitz_tree.h" +#include "fitz_res.h" #include "fitz_draw.h" typedef unsigned char byte; diff --git a/fitzdraw/imagescale.c b/fitzdraw/imagescale.c index ad73ece1..e9f503cb 100644 --- a/fitzdraw/imagescale.c +++ b/fitzdraw/imagescale.c @@ -1,5 +1,5 @@ #include "fitz_base.h" -#include "fitz_tree.h" +#include "fitz_res.h" #include "fitz_draw.h" typedef unsigned char byte; diff --git a/fitzdraw/imageunpack.c b/fitzdraw/imageunpack.c index 4df495ba..61eacb63 100644 --- a/fitzdraw/imageunpack.c +++ b/fitzdraw/imageunpack.c @@ -1,5 +1,5 @@ #include "fitz_base.h" -#include "fitz_tree.h" +#include "fitz_res.h" #include "fitz_draw.h" typedef unsigned char byte; diff --git a/fitzdraw/meshdraw.c b/fitzdraw/meshdraw.c index ba1e036c..4c341a82 100644 --- a/fitzdraw/meshdraw.c +++ b/fitzdraw/meshdraw.c @@ -1,5 +1,5 @@ #include "fitz_base.h" -#include "fitz_tree.h" +#include "fitz_res.h" #include "fitz_draw.h" /* diff --git a/fitzdraw/pathscan.c b/fitzdraw/pathscan.c index dc0ca7c7..e2e18e7e 100644 --- a/fitzdraw/pathscan.c +++ b/fitzdraw/pathscan.c @@ -1,5 +1,5 @@ #include "fitz_base.h" -#include "fitz_tree.h" +#include "fitz_res.h" #include "fitz_draw.h" /* divide and floor towards -inf */ diff --git a/fitzdraw/pathstroke.c b/fitzdraw/pathstroke.c index 13e70dd4..7b08ab5c 100644 --- a/fitzdraw/pathstroke.c +++ b/fitzdraw/pathstroke.c @@ -1,5 +1,5 @@ #include "fitz_base.h" -#include "fitz_tree.h" +#include "fitz_res.h" #include "fitz_draw.h" enum { BUTT = 0, ROUND = 1, SQUARE = 2, MITER = 0, BEVEL = 2 }; diff --git a/fitzdraw/pixmap.c b/fitzdraw/pixmap.c index 592eaf44..6ea1d1d9 100644 --- a/fitzdraw/pixmap.c +++ b/fitzdraw/pixmap.c @@ -1,5 +1,5 @@ #include "fitz_base.h" -#include "fitz_tree.h" +#include "fitz_res.h" #include "fitz_draw.h" fz_error diff --git a/fitzdraw/porterduff.c b/fitzdraw/porterduff.c index 755ba434..59c7714b 100644 --- a/fitzdraw/porterduff.c +++ b/fitzdraw/porterduff.c @@ -1,5 +1,5 @@ #include "fitz_base.h" -#include "fitz_tree.h" +#include "fitz_res.h" #include "fitz_draw.h" typedef unsigned char byte; diff --git a/fitzdraw/render.c b/fitzdraw/render.c index b4cfa4fa..0c202e9e 100644 --- a/fitzdraw/render.c +++ b/fitzdraw/render.c @@ -1,5 +1,5 @@ #include "fitz_base.h" -#include "fitz_tree.h" +#include "fitz_res.h" #include "fitz_draw.h" #ifdef _MSC_VER diff --git a/mupdf/Jamfile b/mupdf/Jamfile index a90ac003..b8a8be13 100644 --- a/mupdf/Jamfile +++ b/mupdf/Jamfile @@ -50,8 +50,7 @@ Library libmupdf : pdf_xobject.c # pages, resource dictionaries, ... - pdf_build.c - pdf_interpret.c +# pdf_interpret.c pdf_page.c pdf_pagetree.c pdf_store.c @@ -64,54 +63,98 @@ Library libmupdf : SubDir TOP cmaps ; -GenFile cmap_tounicode.c : cmapdump - Adobe-CNS1-UCS2 Adobe-GB1-UCS2 - Adobe-Japan1-UCS2 Adobe-Korea1-UCS2 ; - -GenFile cmap_cns.c : cmapdump - Adobe-CNS1-0 Adobe-CNS1-1 Adobe-CNS1-2 Adobe-CNS1-3 - Adobe-CNS1-4 Adobe-CNS1-5 Adobe-CNS1-6 B5-H B5-V B5pc-H B5pc-V - CNS-EUC-H CNS-EUC-V CNS1-H CNS1-V CNS2-H CNS2-V ETen-B5-H - ETen-B5-V ETenms-B5-H ETenms-B5-V ETHK-B5-H ETHK-B5-V - HKdla-B5-H HKdla-B5-V HKdlb-B5-H HKdlb-B5-V HKgccs-B5-H - HKgccs-B5-V HKm314-B5-H HKm314-B5-V HKm471-B5-H HKm471-B5-V - HKscs-B5-H HKscs-B5-V UniCNS-UCS2-H UniCNS-UCS2-V - UniCNS-UTF16-H UniCNS-UTF16-V ; - -GenFile cmap_gb.c : cmapdump - Adobe-GB1-0 Adobe-GB1-1 Adobe-GB1-2 Adobe-GB1-3 Adobe-GB1-4 - Adobe-GB1-5 GB-EUC-H GB-EUC-V GB-H GB-V GBK-EUC-H GBK-EUC-V - GBK2K-H GBK2K-V GBKp-EUC-H GBKp-EUC-V GBpc-EUC-H GBpc-EUC-V - GBT-EUC-H GBT-EUC-V GBT-H GBT-V GBTpc-EUC-H GBTpc-EUC-V - UniGB-UCS2-H UniGB-UCS2-V UniGB-UTF16-H UniGB-UTF16-V ; - -GenFile cmap_japan.c : cmapdump - 78-EUC-H 78-EUC-V 78-H 78-RKSJ-H 78-RKSJ-V 78-V 78ms-RKSJ-H - 78ms-RKSJ-V 83pv-RKSJ-H 90ms-RKSJ-H 90ms-RKSJ-V 90msp-RKSJ-H - 90msp-RKSJ-V 90pv-RKSJ-H 90pv-RKSJ-V Add-H Add-RKSJ-H - Add-RKSJ-V Add-V Adobe-Japan1-0 Adobe-Japan1-1 Adobe-Japan1-2 - Adobe-Japan1-3 Adobe-Japan1-4 Adobe-Japan1-5 Adobe-Japan1-6 - EUC-H EUC-V Ext-H Ext-RKSJ-H Ext-RKSJ-V Ext-V H Hankaku - Hiragana Katakana NWP-H NWP-V RKSJ-H RKSJ-V Roman - UniJIS-UCS2-H UniJIS-UCS2-HW-H UniJIS-UCS2-HW-V UniJIS-UCS2-V - UniJISPro-UCS2-HW-V UniJISPro-UCS2-V V WP-Symbol - Adobe-Japan2-0 Hojo-EUC-H Hojo-EUC-V Hojo-H Hojo-V - UniHojo-UCS2-H UniHojo-UCS2-V UniHojo-UTF16-H UniHojo-UTF16-V - UniJIS-UTF16-H UniJIS-UTF16-V ; - -GenFile cmap_korea.c : cmapdump - Adobe-Korea1-0 Adobe-Korea1-1 Adobe-Korea1-2 KSC-EUC-H - KSC-EUC-V KSC-H KSC-Johab-H KSC-Johab-V KSC-V KSCms-UHC-H - KSCms-UHC-HW-H KSCms-UHC-HW-V KSCms-UHC-V KSCpc-EUC-H - KSCpc-EUC-V UniKS-UCS2-H UniKS-UCS2-V UniKS-UTF16-H UniKS-UTF16-V ; - -Library libcmaps : - cmap_tounicode.c - cmap_cns.c - cmap_gb.c - cmap_japan.c - cmap_korea.c - ; +SubDir TOP cmaps chinese_s ; +GenFile cmap_chinese_s.c : cmapdump + Adobe-GB1-4 + Adobe-GB1-UCS2 + GB-EUC-H + GB-EUC-V + GBK-EUC-H + GBK-EUC-UCS2 + GBK-EUC-V + GBK2K-H + GBK2K-V + GBKp-EUC-H + GBKp-EUC-V + GBT-EUC-H + GBT-EUC-V + GBpc-EUC-H + GBpc-EUC-UCS2 + GBpc-EUC-UCS2C + GBpc-EUC-V + UniGB-UCS2-H + UniGB-UCS2-V + ; +Library libcmaps : cmap_chinese_s.c ; + +SubDir TOP cmaps chinese_t ; +GenFile cmap_chinese_t.c : cmapdump + Adobe-CNS1-3 + Adobe-CNS1-UCS2 + B5pc-H + B5pc-UCS2 + B5pc-UCS2C + B5pc-V + CNS-EUC-H + CNS-EUC-V + ETen-B5-H + ETen-B5-UCS2 + ETen-B5-V + ETenms-B5-H + ETenms-B5-V + HKscs-B5-H + HKscs-B5-V + UniCNS-UCS2-H + UniCNS-UCS2-V + ; +Library libcmaps : cmap_chinese_t.c ; + +SubDir TOP cmaps japanese ; +GenFile cmap_japanese.c : cmapdump + 83pv-RKSJ-H + 90ms-RKSJ-H + 90ms-RKSJ-UCS2 + 90ms-RKSJ-V + 90msp-RKSJ-H + 90msp-RKSJ-V + 90pv-RKSJ-H + 90pv-RKSJ-UCS2 + 90pv-RKSJ-UCS2C + Add-RKSJ-H + Add-RKSJ-V + Adobe-Japan1-4 + Adobe-Japan1-UCS2 + EUC-H + EUC-V + Ext-RKSJ-H + Ext-RKSJ-V + H + UniJIS-UCS2-H + UniJIS-UCS2-HW-H + UniJIS-UCS2-HW-V + UniJIS-UCS2-V + V + ; +Library libcmaps : cmap_japanese.c ; + +SubDir TOP cmaps korean ; +GenFile cmap_korean.c : cmapdump + Adobe-Korea1-2 + Adobe-Korea1-UCS2 + KSC-EUC-H + KSC-EUC-V + KSCms-UHC-H + KSCms-UHC-HW-H + KSCms-UHC-HW-V + KSCms-UHC-UCS2 + KSCms-UHC-V + KSCpc-EUC-H + KSCpc-EUC-UCS2 + KSCpc-EUC-UCS2C + UniKS-UCS2-H + UniKS-UCS2-V + ; +Library libcmaps : cmap_korean.c ; # The base 14 fonts are the Type1 URW fonts converted to raw CFF format. # DroidSansFallback.ttf is a compact CJK font from Google's Android project. @@ -119,31 +162,31 @@ Library libcmaps : SubDir TOP fonts ; GenFile font_misc.c : fontdump - Dingbats.cff - StandardSymL.cff - URWChanceryL-MediItal.cff - ; + Dingbats.cff + StandardSymL.cff + URWChanceryL-MediItal.cff + ; GenFile font_mono.c : fontdump - NimbusMonL-Regu.cff - NimbusMonL-ReguObli.cff - NimbusMonL-Bold.cff - NimbusMonL-BoldObli.cff - ; + NimbusMonL-Regu.cff + NimbusMonL-ReguObli.cff + NimbusMonL-Bold.cff + NimbusMonL-BoldObli.cff + ; GenFile font_serif.c : fontdump - NimbusRomNo9L-Regu.cff - NimbusRomNo9L-ReguItal.cff - NimbusRomNo9L-Medi.cff - NimbusRomNo9L-MediItal.cff - ; + NimbusRomNo9L-Regu.cff + NimbusRomNo9L-ReguItal.cff + NimbusRomNo9L-Medi.cff + NimbusRomNo9L-MediItal.cff + ; GenFile font_sans.c : fontdump - NimbusSanL-Bold.cff - NimbusSanL-BoldItal.cff - NimbusSanL-Regu.cff - NimbusSanL-ReguItal.cff - ; + NimbusSanL-Bold.cff + NimbusSanL-BoldItal.cff + NimbusSanL-Regu.cff + NimbusSanL-ReguItal.cff + ; Library libfonts : font_misc.c diff --git a/mupdf/mupdf.h b/mupdf/mupdf.h index 604cd62a..cbb9c287 100644 --- a/mupdf/mupdf.h +++ b/mupdf/mupdf.h @@ -249,7 +249,7 @@ struct pdf_pattern_s float ystep; fz_matrix matrix; fz_rect bbox; - fz_tree *tree; +// XXX fz_tree *tree; }; fz_error pdf_loadpattern(pdf_pattern **patp, pdf_xref *xref, fz_obj *obj); @@ -577,7 +577,7 @@ struct pdf_page_s fz_rect mediabox; int rotate; fz_obj *resources; - fz_tree *tree; +// XXX fz_tree *tree; pdf_comment *comments; pdf_link *links; }; @@ -605,7 +605,6 @@ fz_error pdf_loadpage(pdf_page **pagep, pdf_xref *xref, fz_obj *ref); void pdf_droppage(pdf_page *page); /* unicode.c */ -fz_error pdf_loadtextfromtree(pdf_textline **linep, fz_tree *tree, fz_matrix ctm); void pdf_debugtextline(pdf_textline *line); pdf_textline * pdf_newtextline(void); void pdf_droptextline(pdf_textline *line); @@ -671,9 +670,6 @@ struct pdf_gstate_s float size; int render; float rise; - - /* tree construction state */ - fz_node *head; }; struct pdf_csi_s @@ -686,18 +682,15 @@ struct pdf_csi_s fz_obj *array; /* path object state */ - fz_pathnode *path; + fz_path *path; int clip; int clipevenodd; /* text object state */ - fz_node *textclip; - fz_textnode *text; + fz_text *text; fz_matrix tlm; fz_matrix tm; int textmode; - - fz_tree *tree; }; /* build.c */ @@ -706,14 +699,6 @@ fz_error pdf_setcolorspace(pdf_csi *csi, int what, fz_colorspace *cs); fz_error pdf_setcolor(pdf_csi *csi, int what, float *v); fz_error pdf_setpattern(pdf_csi *csi, int what, pdf_pattern *pat, float *v); fz_error pdf_setshade(pdf_csi *csi, int what, fz_shade *shade); - -fz_error pdf_buildstrokepath(pdf_gstate *gs, fz_pathnode *path); -fz_error pdf_buildfillpath(pdf_gstate *gs, fz_pathnode *path, int evenodd); -fz_error pdf_addfillshape(pdf_gstate *gs, fz_node *shape); -fz_error pdf_addstrokeshape(pdf_gstate *gs, fz_node *shape); -fz_error pdf_addclipmask(pdf_gstate *gs, fz_node *shape); -fz_error pdf_addtransform(pdf_gstate *gs, fz_node *transform); -fz_error pdf_addshade(pdf_gstate *gs, fz_shade *shade); fz_error pdf_showpath(pdf_csi*, int close, int fill, int stroke, int evenodd); fz_error pdf_showtext(pdf_csi*, fz_obj *text); fz_error pdf_flushtext(pdf_csi*); diff --git a/mupdf/pdf_build.c b/mupdf/pdf_build.c index 0e773796..ac612ad5 100644 --- a/mupdf/pdf_build.c +++ b/mupdf/pdf_build.c @@ -40,8 +40,6 @@ pdf_initgstate(pdf_gstate *gs) gs->size = -1; gs->render = 0; gs->rise = 0; - - gs->head = nil; } static fz_error diff --git a/mupdf/pdf_open.c b/mupdf/pdf_open.c index 691baba3..ba8e7434 100644 --- a/mupdf/pdf_open.c +++ b/mupdf/pdf_open.c @@ -732,14 +732,15 @@ pdf_loadxref(pdf_xref *xref, char *filename) xref->table[0].type = 'f'; } - /* broken pdfs where freed objects have offset and gen set to 0 - but still exits */ + /* broken pdfs where freed objects have offset and gen set to 0 but still exist */ for (i = 0; i < xref->len; i++) + { if (xref->table[i].type == 'n' && xref->table[i].ofs == 0 && xref->table[i].gen == 0 && xref->table[i].obj == nil) - { - fz_warn("object (%d %d R) has invalid offset, assumed missing", i, xref->table[i].gen); - xref->table[i].type = 'f'; + { + fz_warn("object (%d %d R) has invalid offset, assumed missing", i, xref->table[i].gen); + xref->table[i].type = 'f'; + } } return fz_okay; @@ -751,4 +752,3 @@ cleanup: xref->table = nil; return error; } - diff --git a/mupdf/pdf_page.c b/mupdf/pdf_page.c index 1be6d748..31b0f4de 100644 --- a/mupdf/pdf_page.c +++ b/mupdf/pdf_page.c @@ -1,6 +1,7 @@ #include "fitz.h" #include "mupdf.h" +#if 0 // XXX static fz_error runone(pdf_csi *csi, pdf_xref *xref, fz_obj *rdb, fz_obj *stmref) { @@ -119,6 +120,7 @@ loadpagecontents(fz_tree **treep, pdf_xref *xref, fz_obj *rdb, fz_obj *obj) return fz_okay; } +#endif fz_error pdf_loadpage(pdf_page **pagep, pdf_xref *xref, fz_obj *dict) @@ -129,7 +131,6 @@ pdf_loadpage(pdf_page **pagep, pdf_xref *xref, fz_obj *dict) fz_obj *rdb; pdf_comment *comments = nil; pdf_link *links = nil; - fz_tree *tree = nil; fz_rect bbox; int rotate; @@ -197,13 +198,14 @@ pdf_loadpage(pdf_page **pagep, pdf_xref *xref, fz_obj *dict) */ obj = fz_dictgets(dict, "Contents"); - +#if 0 // XXX error = loadpagecontents(&tree, xref, rdb, obj); if (error) { fz_dropobj(rdb); return fz_rethrow(error, "cannot load page contents"); } +#endif /* * Create page object @@ -216,7 +218,7 @@ pdf_loadpage(pdf_page **pagep, pdf_xref *xref, fz_obj *dict) page->mediabox.y1 = MAX(bbox.y0, bbox.y1); page->rotate = rotate; page->resources = rdb; /* we have already kept or created it */ - page->tree = tree; +// page->tree = tree; page->comments = comments; page->links = links; @@ -236,8 +238,6 @@ pdf_droppage(pdf_page *page) fz_dropobj(page->resources); if (page->links) pdf_droplink(page->links); - if (page->tree) - fz_droptree(page->tree); fz_free(page); } diff --git a/mupdf/pdf_pattern.c b/mupdf/pdf_pattern.c index 8052c356..3c62d813 100644 --- a/mupdf/pdf_pattern.c +++ b/mupdf/pdf_pattern.c @@ -13,8 +13,8 @@ pdf_droppattern(pdf_pattern *pat) { if (pat && --pat->refs == 0) { - if (pat->tree) - fz_droptree(pat->tree); +//XXX if (pat->tree) +//XXX fz_droptree(pat->tree); fz_free(pat); } } @@ -39,7 +39,6 @@ pdf_loadpattern(pdf_pattern **patp, pdf_xref *xref, fz_obj *dict) pat = fz_malloc(sizeof(pdf_pattern)); pat->refs = 1; - pat->tree = nil; pat->ismask = fz_toint(fz_dictgets(dict, "PaintType")) == 2; pat->xstep = fz_toreal(fz_dictgets(dict, "XStep")); pat->ystep = fz_toreal(fz_dictgets(dict, "YStep")); @@ -85,6 +84,7 @@ pdf_loadpattern(pdf_pattern **patp, pdf_xref *xref, fz_obj *dict) */ pdf_logrsrc("content stream\n"); +#if 0 // XXX error = pdf_newcsi(&csi, pat->ismask); if (error) @@ -119,6 +119,7 @@ pdf_loadpattern(pdf_pattern **patp, pdf_xref *xref, fz_obj *dict) fz_dropstream(stm); pdf_dropcsi(csi); +#endif pdf_logrsrc("}\n"); diff --git a/mupdf/pdf_type3.c b/mupdf/pdf_type3.c index e82df455..4313ac9d 100644 --- a/mupdf/pdf_type3.c +++ b/mupdf/pdf_type3.c @@ -1,6 +1,7 @@ #include "fitz.h" #include "mupdf.h" +#if 0 // XXX static fz_error loadcharproc(fz_tree **treep, pdf_xref *xref, fz_obj *rdb, fz_obj *stmref) { @@ -34,6 +35,7 @@ loadcharproc(fz_tree **treep, pdf_xref *xref, fz_obj *rdb, fz_obj *stmref) pdf_dropcsi(csi); return fz_okay; } +#endif fz_error pdf_loadtype3font(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict) @@ -194,9 +196,9 @@ pdf_loadtype3font(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *rdb, fz_obj if (obj) { pdf_logfont("load charproc %s {\n", estrings[i]); - error = loadcharproc(&fontdesc->font->t3procs[i], xref, resources, obj); - if (error) - goto cleanup; +// XXX error = loadcharproc(&fontdesc->font->t3procs[i], xref, resources, obj); +// XXX if (error) +// XXX goto cleanup; pdf_logfont("}\n"); } diff --git a/mupdf/pdf_unicode.c b/mupdf/pdf_unicode.c index 5b24de12..4c0ce353 100644 --- a/mupdf/pdf_unicode.c +++ b/mupdf/pdf_unicode.c @@ -153,125 +153,82 @@ addtextchar(pdf_textline *line, int x, int y, int c) line->cap = line->cap ? (line->cap * 3) / 2 : 80; line->text = fz_realloc(line->text, sizeof(pdf_textchar) * line->cap); } - line->text[line->len].x = x; line->text[line->len].y = y; line->text[line->len].c = c; line->len ++; } -static fz_error -extracttext(pdf_textline **line, fz_node *node, fz_matrix ctm, fz_point *oldpt) +void +pdf_extracttextline(pdf_textline **line, fz_text *text, fz_matrix ctm, fz_point *oldpt) { - fz_error error; + fz_font *font = text->font; + fz_matrix tm = text->trm; + fz_matrix inv = fz_invertmatrix(text->trm); + fz_matrix trm; + float dx, dy; + fz_point p; + float adv; + int i, x, y, fterr; + + if (font->ftface) + { + FT_Set_Transform(font->ftface, NULL, NULL); + fterr = FT_Set_Char_Size(font->ftface, 64, 64, 72, 72); + if (fterr) + fz_warn("freetype set character size: %s", ft_errorstring(fterr)); + } - if (fz_istextnode(node)) + for (i = 0; i < text->len; i++) { - fz_textnode *text = (fz_textnode*)node; - fz_font *font = text->font; - fz_matrix tm = text->trm; - fz_matrix inv = fz_invertmatrix(text->trm); - fz_matrix trm; - float dx, dy; - fz_point p; - float adv; - int i, x, y, fterr; + tm.e = text->els[i].x; + tm.f = text->els[i].y; + trm = fz_concat(tm, ctm); + x = trm.e; + y = trm.f; + trm.e = 0; + trm.f = 0; + + p.x = text->els[i].x; + p.y = text->els[i].y; + p = fz_transformpoint(inv, p); + dx = oldpt->x - p.x; + dy = oldpt->y - p.y; + *oldpt = p; + + /* TODO: flip advance and test for vertical writing */ if (font->ftface) { - FT_Set_Transform(font->ftface, NULL, NULL); - fterr = FT_Set_Char_Size(font->ftface, 64, 64, 72, 72); + FT_Fixed ftadv; + fterr = FT_Get_Advance(font->ftface, text->els[i].gid, + FT_LOAD_NO_BITMAP | FT_LOAD_NO_HINTING, + &ftadv); if (fterr) - return fz_throw("freetype set character size: %s", ft_errorstring(fterr)); + fz_warn("freetype get advance (gid %d): %s", text->els[i].gid, ft_errorstring(fterr)); + adv = ftadv / 65536.0; + oldpt->x += adv; } - - for (i = 0; i < text->len; i++) + else { - tm.e = text->els[i].x; - tm.f = text->els[i].y; - trm = fz_concat(tm, ctm); - x = trm.e; - y = trm.f; - trm.e = 0; - trm.f = 0; - - p.x = text->els[i].x; - p.y = text->els[i].y; - p = fz_transformpoint(inv, p); - dx = oldpt->x - p.x; - dy = oldpt->y - p.y; - *oldpt = p; - - /* TODO: flip advance and test for vertical writing */ - - if (font->ftface) - { - FT_Fixed ftadv; - fterr = FT_Get_Advance(font->ftface, text->els[i].gid, - FT_LOAD_NO_BITMAP | FT_LOAD_NO_HINTING, - &ftadv); - if (fterr) - return fz_throw("freetype get advance (gid %d): %s", text->els[i].gid, ft_errorstring(fterr)); - adv = ftadv / 65536.0; - oldpt->x += adv; - } - else - { - adv = font->t3widths[text->els[i].gid]; - oldpt->x += adv; - } - - if (fabs(dy) > 0.2) - { - pdf_textline *newline = pdf_newtextline(); - (*line)->next = newline; - *line = newline; - } - else if (fabs(dx) > 0.2) - { - addtextchar(*line, x, y, ' '); - } - - addtextchar(*line, x, y, text->els[i].ucs); + adv = font->t3widths[text->els[i].gid]; + oldpt->x += adv; } - } - - if (fz_istransformnode(node)) - ctm = fz_concat(((fz_transformnode*)node)->m, ctm); - for (node = node->first; node; node = node->next) - { - error = extracttext(line, node, ctm, oldpt); - if (error) - return fz_rethrow(error, "cannot extract text from display node"); - } - - return fz_okay; -} - -fz_error -pdf_loadtextfromtree(pdf_textline **outp, fz_tree *tree, fz_matrix ctm) -{ - pdf_textline *root; - pdf_textline *line; - fz_error error; - fz_point oldpt; - - oldpt.x = -1; - oldpt.y = -1; - - root = pdf_newtextline(); - line = root; + if (fabs(dy) > 0.2) + { + pdf_textline *newline; + newline = pdf_newtextline(); + (*line)->next = newline; + *line = newline; + } + else if (fabs(dx) > 0.2) + { + addtextchar(*line, x, y, ' '); + } - error = extracttext(&line, tree->root, ctm, &oldpt); - if (error) - { - pdf_droptextline(root); - return fz_rethrow(error, "cannot extract text from display tree"); + addtextchar(*line, x, y, text->els[i].ucs); } - - *outp = root; - return fz_okay; } void |