From 7cf6ccee8c6b59d8aac17ab6e4673bcb69f5e8d2 Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Mon, 4 Apr 2011 23:35:45 +0200 Subject: Le Roi est mort, vive le Roi! The run-together words are dead! Long live the underscores! The postscript inspired naming convention of using all run-together words has served us well, but it is now time for more readable code. In this commit I have also added the sed script, rename.sed, that I used to convert the source. Use it on your patches and application code. --- android/jni/mupdf.c | 51 ++- apps/mozilla/moz_main.c | 86 ++-- apps/pdfapp.c | 156 +++---- apps/pdfapp.h | 6 +- apps/pdfclean.c | 282 ++++++------ apps/pdfdraw.c | 114 ++--- apps/pdfextract.c | 68 +-- apps/pdfinfo.c | 330 +++++++------- apps/pdfshow.c | 50 +-- apps/win_main.c | 26 +- apps/x11_image.c | 14 +- apps/x11_main.c | 22 +- apps/xpsdraw.c | 77 ++-- draw/arch_arm.c | 6 +- draw/arch_port.c | 4 +- draw/draw_affine.c | 120 ++--- draw/draw_blend.c | 62 +-- draw/draw_edge.c | 92 ++-- draw/draw_glyph.c | 90 ++-- draw/draw_mesh.c | 195 ++++---- draw/draw_paint.c | 84 ++-- draw/draw_path.c | 232 +++++----- draw/draw_scale.c | 48 +- draw/draw_unpack.c | 54 +-- fitz/base_error.c | 92 ++-- fitz/base_geometry.c | 70 +-- fitz/base_hash.c | 72 +-- fitz/base_memory.c | 2 +- fitz/base_string.c | 6 +- fitz/crypt_arc4.c | 8 +- fitz/crypt_md5.c | 10 +- fitz/crypt_sha2.c | 6 +- fitz/dev_bbox.c | 84 ++-- fitz/dev_draw.c | 546 +++++++++++------------ fitz/dev_list.c | 488 ++++++++++---------- fitz/dev_null.c | 92 ++-- fitz/dev_text.c | 200 ++++----- fitz/dev_trace.c | 232 +++++----- fitz/filt_basic.c | 88 ++-- fitz/filt_dctd.c | 30 +- fitz/filt_faxd.c | 161 ++++--- fitz/filt_flate.c | 14 +- fitz/filt_jbig2d.c | 16 +- fitz/filt_jpxd.c | 10 +- fitz/filt_lzwd.c | 104 ++--- fitz/filt_predict.c | 32 +- fitz/fitz.h | 791 ++++++++++++++++----------------- fitz/obj_array.c | 72 +-- fitz/obj_dict.c | 144 +++--- fitz/obj_print.c | 217 +++++---- fitz/obj_simple.c | 118 ++--- fitz/res_colorspace.c | 200 ++++----- fitz/res_font.c | 214 ++++----- fitz/res_path.c | 150 +++---- fitz/res_pixmap.c | 50 +-- fitz/res_shade.c | 32 +- fitz/res_text.c | 64 +-- fitz/stm_buffer.c | 12 +- fitz/stm_open.c | 50 +-- fitz/stm_read.c | 22 +- pdf/cmapdump.c | 18 +- pdf/fontdump.c | 1 - pdf/mupdf.h | 444 +++++++++--------- pdf/pdf_annot.c | 172 +++---- pdf/pdf_build.c | 432 +++++++++--------- pdf/pdf_cmap.c | 128 +++--- pdf/pdf_cmap_load.c | 94 ++-- pdf/pdf_cmap_parse.c | 236 +++++----- pdf/pdf_cmap_table.c | 2 +- pdf/pdf_colorspace.c | 270 +++++------ pdf/pdf_crypt.c | 336 +++++++------- pdf/pdf_debug.c | 12 +- pdf/pdf_font.c | 628 +++++++++++++------------- pdf/pdf_fontagl.c | 34 +- pdf/pdf_fontenc.c | 20 +- pdf/pdf_fontfile.c | 74 +-- pdf/pdf_fontmtx.c | 60 +-- pdf/pdf_function.c | 954 +++++++++++++++++++-------------------- pdf/pdf_image.c | 164 +++---- pdf/pdf_interpret.c | 628 +++++++++++++------------- pdf/pdf_lex.c | 172 +++---- pdf/pdf_nametree.c | 106 ++--- pdf/pdf_outline.c | 74 +-- pdf/pdf_page.c | 164 +++---- pdf/pdf_pagetree.c | 128 +++--- pdf/pdf_parse.c | 354 +++++++-------- pdf/pdf_pattern.c | 60 +-- pdf/pdf_repair.c | 234 +++++----- pdf/pdf_shade.c | 530 +++++++++++----------- pdf/pdf_store.c | 118 ++--- pdf/pdf_stream.c | 198 ++++----- pdf/pdf_type3.c | 102 ++--- pdf/pdf_unicode.c | 52 +-- pdf/pdf_xobject.c | 76 ++-- pdf/pdf_xref.c | 368 +++++++-------- rename.sed | 1135 +++++++++++++++++++++++++++++++++++++++++++++++ win32/slimftmodules.h | 1 - win32/slimftoptions.h | 1 - xps/xps_common.c | 16 +- xps/xps_doc.c | 2 +- xps/xps_glyphs.c | 32 +- xps/xps_gradient.c | 38 +- xps/xps_image.c | 4 +- xps/xps_jpeg.c | 12 +- xps/xps_path.c | 78 ++-- xps/xps_png.c | 14 +- xps/xps_tiff.c | 78 ++-- xps/xps_tile.c | 24 +- xps/xps_zip.c | 14 +- 109 files changed, 8368 insertions(+), 7292 deletions(-) create mode 100644 rename.sed diff --git a/android/jni/mupdf.c b/android/jni/mupdf.c index 530f7e54..c02c0f82 100644 --- a/android/jni/mupdf.c +++ b/android/jni/mupdf.c @@ -19,13 +19,13 @@ /* Globals */ fz_colorspace *colorspace; -fz_glyphcache *glyphcache; +fz_glyph_cache *glyphcache; pdf_xref *xref; int pagenum = 1; int resolution = 160; float pageWidth = 100; float pageHeight = 100; -fz_displaylist *currentPageList; +fz_display_list *currentPageList; fz_rect currentMediabox; int currentRotate; @@ -45,11 +45,11 @@ JNIEXPORT int JNICALL Java_com_artifex_mupdf_MuPDFCore_openFile(JNIEnv * env, jo if (accelerate) fz_accelerate(); - glyphcache = fz_newglyphcache(); - colorspace = fz_devicergb; + glyphcache = fz_new_glyph_cache(); + colorspace = fz_device_rgb; LOGE("Opening document..."); - error = pdf_openxref(&xref, filename, password); + error = pdf_open_xref(&xref, filename, password); if (error) { LOGE("Cannot open document: '%s'\n", filename); @@ -57,15 +57,15 @@ JNIEXPORT int JNICALL Java_com_artifex_mupdf_MuPDFCore_openFile(JNIEnv * env, jo } LOGE("Loading page tree..."); - error = pdf_loadpagetree(xref); + error = pdf_load_page_tree(xref); if (error) { LOGE("Cannot load page tree: '%s'\n", filename); return 0; } - LOGE("Done! %d pages", pdf_getpagecount(xref)); + LOGE("Done! %d pages", pdf_get_page_count(xref)); - return pdf_getpagecount(xref); + return pdf_get_page_count(xref); } JNIEXPORT void JNICALL Java_com_artifex_mupdf_MuPDFCore_gotoPageInternal( @@ -88,14 +88,14 @@ JNIEXPORT void JNICALL Java_com_artifex_mupdf_MuPDFCore_gotoPageInternal( LOGE("Goto page %d...", page); if (currentPageList != NULL) { - fz_freedisplaylist(currentPageList); + fz_free_display_list(currentPageList); currentPageList = NULL; } pagenum = page; - pageobj = pdf_getpageobject(xref, pagenum); + pageobj = pdf_get_page_object(xref, pagenum); if (pageobj == NULL) return; - error = pdf_loadpage(¤tPage, xref, pageobj); + error = pdf_load_page(¤tPage, xref, pageobj); if (error) return; zoom = resolution / 72; @@ -104,17 +104,17 @@ JNIEXPORT void JNICALL Java_com_artifex_mupdf_MuPDFCore_gotoPageInternal( ctm = fz_translate(0, -currentMediabox.y1); ctm = fz_concat(ctm, fz_scale(zoom, -zoom)); ctm = fz_concat(ctm, fz_rotate(currentRotate)); - bbox = fz_roundrect(fz_transformrect(ctm, currentMediabox)); + bbox = fz_round_rect(fz_transform_rect(ctm, currentMediabox)); pageWidth = bbox.x1-bbox.x0; pageHeight = bbox.y1-bbox.y0; /* Render to list */ - currentPageList = fz_newdisplaylist(); - dev = fz_newlistdevice(currentPageList); - error = pdf_runpage(xref, currentPage, dev, fz_identity); - pdf_freepage(currentPage); + currentPageList = fz_new_display_list(); + dev = fz_new_list_device(currentPageList); + error = pdf_run_page(xref, currentPage, dev, fz_identity); + pdf_free_page(currentPage); if (error) LOGE("cannot make displaylist from page %d", pagenum); - fz_freedevice(dev); + fz_free_device(dev); } JNIEXPORT float JNICALL Java_com_artifex_mupdf_MuPDFCore_getPageWidth( @@ -133,7 +133,6 @@ JNIEXPORT float JNICALL Java_com_artifex_mupdf_MuPDFCore_getPageHeight( return pageHeight; } - JNIEXPORT jboolean JNICALL Java_com_artifex_mupdf_MuPDFCore_drawPage( JNIEnv *env, jobject thiz, @@ -178,7 +177,7 @@ JNIEXPORT jboolean JNICALL Java_com_artifex_mupdf_MuPDFCore_drawPage( LOGE("Rendering page=%dx%d patch=[%d,%d,%d,%d]", pageW, pageH, patchX, patchY, patchW, patchH); - pix = fz_newpixmapwithdata(colorspace, + pix = fz_new_pixmap_with_data(colorspace, patchX, patchY, patchW, @@ -186,25 +185,25 @@ JNIEXPORT jboolean JNICALL Java_com_artifex_mupdf_MuPDFCore_drawPage( pixels); if (currentPageList == NULL) { - fz_clearpixmapwithcolor(pix, 0xd0); + fz_clear_pixmap_with_color(pix, 0xd0); return 0; } - fz_clearpixmapwithcolor(pix, 0xff); + fz_clear_pixmap_with_color(pix, 0xff); zoom = resolution / 72; ctm = fz_translate(0, -currentMediabox.y1); ctm = fz_concat(ctm, fz_scale(zoom, -zoom)); ctm = fz_concat(ctm, fz_rotate(currentRotate)); - bbox = fz_roundrect(fz_transformrect(ctm,currentMediabox)); + bbox = fz_round_rect(fz_transform_rect(ctm,currentMediabox)); /* Now, adjust ctm so that it would give the correct page width * heights. */ xscale = (float)pageW/(float)(bbox.x1-bbox.x0); yscale = (float)pageH/(float)(bbox.y1-bbox.y0); ctm = fz_concat(ctm, fz_scale(xscale, yscale)); - dev = fz_newdrawdevice(glyphcache, pix); - fz_executedisplaylist(currentPageList, dev, ctm); - fz_freedevice(dev); - fz_droppixmap(pix); + dev = fz_new_draw_device(glyphcache, pix); + fz_execute_display_list(currentPageList, dev, ctm); + fz_free_device(dev); + fz_drop_pixmap(pix); LOGE("Rendered"); AndroidBitmap_unlockPixels(env, bitmap); diff --git a/apps/mozilla/moz_main.c b/apps/mozilla/moz_main.c index b5ba7e7a..b71e4278 100644 --- a/apps/mozilla/moz_main.c +++ b/apps/mozilla/moz_main.c @@ -89,10 +89,10 @@ void pdfmoz_open(pdfmoz_t *moz, char *filename) moz->filename = filename; moz->xref = pdf_newxref(); - error = pdf_loadxref(moz->xref, filename); + error = pdf_load_xref(moz->xref, filename); if (error) { - error = pdf_repairxref(moz->xref, filename); + error = pdf_repair_xref(moz->xref, filename); if (error) pdfmoz_error(moz, error); } @@ -105,30 +105,30 @@ void pdfmoz_open(pdfmoz_t *moz, char *filename) if (error) pdfmoz_error(moz, error); - if (pdf_needspassword(moz->xref)) + if (pdf_needs_password(moz->xref)) { pdfmoz_warn(moz, "PDF file is encrypted and needs a password."); } - moz->pagecount = pdf_getpagecount(moz->xref); + moz->pagecount = pdf_get_page_count(moz->xref); moz->pages = fz_malloc(sizeof(page_t) * moz->pagecount); for (i = 0; i < moz->pagecount; i++) { fz_obj *pageobj; - pageobj = pdf_getpageobject(moz->xref, i); - moz->pages[i].obj = fz_keepobj(pageobj); - moz->pages[i].page = nil; - moz->pages[i].image = nil; + pageobj = pdf_get_page_object(moz->xref, i); + moz->pages[i].obj = fz_keep_obj(pageobj); + moz->pages[i].page = NULL; + moz->pages[i].image = NULL; - obj = fz_dictgets(moz->pages[i].obj, "CropBox"); + obj = fz_dict_gets(moz->pages[i].obj, "CropBox"); if (!obj) - obj = fz_dictgets(moz->pages[i].obj, "MediaBox"); - bbox = fz_roundrect(pdf_torect(obj)); + obj = fz_dict_gets(moz->pages[i].obj, "MediaBox"); + bbox = fz_round_rect(pdf_to_rect(obj)); moz->pages[i].w = bbox.x1 - bbox.x0; moz->pages[i].h = bbox.y1 - bbox.y0; - rot = fz_toint(fz_dictgets(moz->pages[i].obj, "Rotate")); + rot = fz_to_int(fz_dict_gets(moz->pages[i].obj, "Rotate")); if ((rot / 90) % 2) { int t = moz->pages[i].w; @@ -144,17 +144,17 @@ void pdfmoz_open(pdfmoz_t *moz, char *filename) * TODO: move this into mupdf library */ - obj = fz_dictgets(moz->xref->trailer, "Root"); - moz->xref->root = fz_resolveindirect(obj); + obj = fz_dict_gets(moz->xref->trailer, "Root"); + moz->xref->root = fz_resolve_indirect(obj); if (!moz->xref->root) pdfmoz_error(moz, fz_throw("syntaxerror: missing Root object")); if (moz->xref->root) - fz_keepobj(moz->xref->root); + fz_keep_obj(moz->xref->root); - obj = fz_dictgets(moz->xref->trailer, "Info"); - moz->xref->info = fz_resolveindirect(obj); + obj = fz_dict_gets(moz->xref->trailer, "Info"); + moz->xref->info = fz_resolve_indirect(obj); if (moz->xref->info) - fz_keepobj(moz->xref->info); + fz_keep_obj(moz->xref->info); moz->doctitle = filename; if (strrchr(moz->doctitle, '\\')) @@ -163,9 +163,9 @@ void pdfmoz_open(pdfmoz_t *moz, char *filename) moz->doctitle = strrchr(moz->doctitle, '/') + 1; if (moz->xref->info) { - obj = fz_dictgets(moz->xref->info, "Title"); + obj = fz_dict_gets(moz->xref->info, "Title"); if (obj) - moz->doctitle = pdf_toutf8(obj); + moz->doctitle = pdf_to_utf8(obj); } /* @@ -230,7 +230,7 @@ void pdfmoz_loadpage(pdfmoz_t *moz, int pagenum) if (page->page) return; - error = pdf_loadpage(&page->page, moz->xref, page->obj); + error = pdf_load_page(&page->page, moz->xref, page->obj); if (error) pdfmoz_error(moz, error); } @@ -249,7 +249,7 @@ void pdfmoz_drawpage(pdfmoz_t *moz, int pagenum) bbox = fz_transformaabb(ctm, page->page->mediabox); error = fz_rendertree(&page->image, moz->rast, page->page->tree, - ctm, fz_roundrect(bbox), 1); + ctm, fz_round_rect(bbox), 1); if (error) pdfmoz_error(moz, error); } @@ -257,14 +257,14 @@ void pdfmoz_drawpage(pdfmoz_t *moz, int pagenum) void pdfmoz_gotouri(pdfmoz_t *moz, fz_obj *uri) { char buf[2048]; - memcpy(buf, fz_tostrbuf(uri), fz_tostrlen(uri)); - buf[fz_tostrlen(uri)] = 0; + memcpy(buf, fz_to_str_buf(uri), fz_to_str_len(uri)); + buf[fz_to_str_len(uri)] = 0; NPN_GetURL(moz->inst, buf, "_blank"); } int pdfmoz_getpagenum(pdfmoz_t *moz, fz_obj *obj) { - return pdf_findpageobject(moz->xref, obj); + return pdf_find_page_object(moz->xref, obj); } void pdfmoz_gotopage(pdfmoz_t *moz, fz_obj *obj) @@ -272,7 +272,7 @@ void pdfmoz_gotopage(pdfmoz_t *moz, fz_obj *obj) int page; int i, y = 0; - page = pdf_findpageobject(moz->xref, obj); + page = pdf_find_page_object(moz->xref, obj); for (i = 0; i < page; i++) y += moz->pages[i].px; @@ -311,9 +311,9 @@ void pdfmoz_onmouse(pdfmoz_t *moz, int x, int y, int click) p.y = y + moz->pages[pi].image->y - py; ctm = pdfmoz_pagectm(moz, pi); - ctm = fz_invertmatrix(ctm); + ctm = fz_invert_matrix(ctm); - p = fz_transformpoint(ctm, p); + p = fz_transform_point(ctm, p); for (link = moz->pages[pi].page->links; link; link = link->next) { @@ -327,21 +327,21 @@ void pdfmoz_onmouse(pdfmoz_t *moz, int x, int y, int click) SetCursor(moz->hand); if (click) { - if (link->kind == PDF_LURI) + if (link->kind == PDF_LINK_URI) pdfmoz_gotouri(moz, link->dest); - else if (link->kind == PDF_LGOTO) + else if (link->kind == PDF_LINK_GOTO) pdfmoz_gotopage(moz, link->dest); return; } else { - if (fz_isstring(link->dest)) + if (fz_is_string(link->dest)) { - memcpy(buf, fz_tostrbuf(link->dest), fz_tostrlen(link->dest)); - buf[fz_tostrlen(link->dest)] = 0; + memcpy(buf, fz_to_str_buf(link->dest), fz_to_str_len(link->dest)); + buf[fz_to_str_len(link->dest)] = 0; NPN_Status(moz->inst, buf); } - else if (fz_isindirect(link->dest)) + else if (fz_is_indirect(link->dest)) { sprintf(buf, "Go to page %d", pdfmoz_getpagenum(moz, link->dest) + 1); @@ -462,15 +462,15 @@ MozWinProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) if (moz->pages[i].page) { pdf_droppage(moz->pages[i].page); - moz->pages[i].page = nil; + moz->pages[i].page = NULL; } } if (i < moz->scrollpage - 1 || i > moz->scrollpage + 3) { if (moz->pages[i].image) { - fz_droppixmap(moz->pages[i].image); - moz->pages[i].image = nil; + fz_drop_pixmap(moz->pages[i].image); + moz->pages[i].image = NULL; } } } @@ -555,8 +555,8 @@ MozWinProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) if (moz->pages[i].image) { - fz_droppixmap(moz->pages[i].image); - moz->pages[i].image = nil; + fz_drop_pixmap(moz->pages[i].image); + moz->pages[i].image = NULL; } si.nMax += moz->pages[i].px; @@ -708,11 +708,11 @@ NPP_Destroy(NPP inst, NPSavedData **saved) for (i = 0; i < moz->pagecount; i++) { if (moz->pages[i].obj) - fz_dropobj(moz->pages[i].obj); + fz_drop_obj(moz->pages[i].obj); if (moz->pages[i].page) pdf_droppage(moz->pages[i].page); if (moz->pages[i].image) - fz_droppixmap(moz->pages[i].image); + fz_drop_pixmap(moz->pages[i].image); } fz_free(moz->pages); @@ -722,7 +722,7 @@ NPP_Destroy(NPP inst, NPSavedData **saved) if (moz->xref->store) { pdf_dropstore(moz->xref->store); - moz->xref->store = nil; + moz->xref->store = NULL; } pdf_closexref(moz->xref); @@ -839,5 +839,3 @@ NPP_Shutdown(void) { // MSG("NPP_Shutdown"); } - - diff --git a/apps/pdfapp.c b/apps/pdfapp.c index bebb8088..277bdbf0 100644 --- a/apps/pdfapp.c +++ b/apps/pdfapp.c @@ -108,8 +108,8 @@ static void pdfapp_open_pdf(pdfapp_t *app, char *filename, int fd) * Open PDF and load xref table */ - file = fz_openfd(fd); - error = pdf_openxrefwithstream(&app->xref, file, nil); + file = fz_open_fd(fd); + error = pdf_open_xref_with_stream(&app->xref, file, NULL); if (error) pdfapp_error(app, fz_rethrow(error, "cannot open document '%s'", filename)); fz_close(file); @@ -118,15 +118,15 @@ static void pdfapp_open_pdf(pdfapp_t *app, char *filename, int fd) * Handle encrypted PDF files */ - if (pdf_needspassword(app->xref)) + if (pdf_needs_password(app->xref)) { - int okay = pdf_authenticatepassword(app->xref, password); + int okay = pdf_authenticate_password(app->xref, password); while (!okay) { password = winpassword(app, filename); if (!password) exit(1); - okay = pdf_authenticatepassword(app->xref, password); + okay = pdf_authenticate_password(app->xref, password); if (!okay) pdfapp_warn(app, "Invalid password."); } @@ -136,30 +136,30 @@ static void pdfapp_open_pdf(pdfapp_t *app, char *filename, int fd) * Load meta information */ - app->outline = pdf_loadoutline(app->xref); + app->outline = pdf_load_outline(app->xref); app->doctitle = filename; if (strrchr(app->doctitle, '\\')) app->doctitle = strrchr(app->doctitle, '\\') + 1; if (strrchr(app->doctitle, '/')) app->doctitle = strrchr(app->doctitle, '/') + 1; - info = fz_dictgets(app->xref->trailer, "Info"); + info = fz_dict_gets(app->xref->trailer, "Info"); if (info) { - obj = fz_dictgets(info, "Title"); + obj = fz_dict_gets(info, "Title"); if (obj) - app->doctitle = pdf_toutf8(obj); + app->doctitle = pdf_to_utf8(obj); } /* * Start at first page */ - error = pdf_loadpagetree(app->xref); + error = pdf_load_page_tree(app->xref); if (error) pdfapp_error(app, fz_rethrow(error, "cannot load page tree")); - app->pagecount = pdf_getpagecount(app->xref); + app->pagecount = pdf_get_page_count(app->xref); } static void pdfapp_open_xps(pdfapp_t *app, char *filename, int fd) @@ -185,7 +185,7 @@ void pdfapp_open(pdfapp_t *app, char *filename, int fd) else pdfapp_open_pdf(app, filename, fd); - app->cache = fz_newglyphcache(); + app->cache = fz_new_glyph_cache(); app->shrinkwrap = 1; if (app->pageno < 1) @@ -206,25 +206,25 @@ void pdfapp_open(pdfapp_t *app, char *filename, int fd) void pdfapp_close(pdfapp_t *app) { if (app->cache) - fz_freeglyphcache(app->cache); - app->cache = nil; + fz_free_glyph_cache(app->cache); + app->cache = NULL; if (app->image) - fz_droppixmap(app->image); - app->image = nil; + fz_drop_pixmap(app->image); + app->image = NULL; if (app->outline) - pdf_freeoutline(app->outline); - app->outline = nil; + pdf_free_outline(app->outline); + app->outline = NULL; if (app->xref) { if (app->xref->store) - pdf_freestore(app->xref->store); - app->xref->store = nil; + pdf_free_store(app->xref->store); + app->xref->store = NULL; - pdf_freexref(app->xref); - app->xref = nil; + pdf_free_xref(app->xref); + app->xref = NULL; } if (app->xps) @@ -233,7 +233,7 @@ void pdfapp_close(pdfapp_t *app) app->xps = NULL; } - fz_flushwarnings(); + fz_flush_warnings(); } static fz_matrix pdfapp_viewctm(pdfapp_t *app) @@ -280,8 +280,8 @@ static void pdfapp_loadpage_pdf(pdfapp_t *app) fz_device *mdev; fz_obj *obj; - obj = pdf_getpageobject(app->xref, app->pageno); - error = pdf_loadpage(&page, app->xref, obj); + obj = pdf_get_page_object(app->xref, app->pageno); + error = pdf_load_page(&page, app->xref, obj); if (error) pdfapp_error(app, error); @@ -291,19 +291,19 @@ static void pdfapp_loadpage_pdf(pdfapp_t *app) page->links = NULL; /* Create display list */ - app->page_list = fz_newdisplaylist(); - mdev = fz_newlistdevice(app->page_list); - error = pdf_runpage(app->xref, page, mdev, fz_identity); + app->page_list = fz_new_display_list(); + mdev = fz_new_list_device(app->page_list); + error = pdf_run_page(app->xref, page, mdev, fz_identity); if (error) { error = fz_rethrow(error, "cannot draw page %d in '%s'", app->pageno, app->doctitle); pdfapp_error(app, error); } - fz_freedevice(mdev); + fz_free_device(mdev); - pdf_freepage(page); + pdf_free_page(page); - pdf_agestore(app->xref->store, 3); + pdf_age_store(app->xref->store, 3); } static void pdfapp_loadpage_xps(pdfapp_t *app) @@ -323,12 +323,12 @@ static void pdfapp_loadpage_xps(pdfapp_t *app) app->page_links = NULL; /* Create display list */ - app->page_list = fz_newdisplaylist(); - mdev = fz_newlistdevice(app->page_list); + app->page_list = fz_new_display_list(); + mdev = fz_new_list_device(app->page_list); app->xps->dev = mdev; xps_parse_fixed_page(app->xps, fz_identity, page); - app->xps->dev = nil; - fz_freedevice(mdev); + app->xps->dev = NULL; + fz_free_device(mdev); xps_free_page(app->xps, page); } @@ -347,11 +347,11 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repai if (loadpage) { if (app->page_list) - fz_freedisplaylist(app->page_list); + fz_free_display_list(app->page_list); if (app->page_text) - fz_freetextspan(app->page_text); + fz_free_text_span(app->page_text); if (app->page_links) - pdf_freelink(app->page_links); + pdf_free_link(app->page_links); if (app->xref) pdfapp_loadpage_pdf(app); @@ -363,10 +363,10 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repai app->hitlen = 0; /* Extract text */ - app->page_text = fz_newtextspan(); - tdev = fz_newtextdevice(app->page_text); - fz_executedisplaylist(app->page_list, tdev, fz_identity, fz_infinitebbox); - fz_freedevice(tdev); + app->page_text = fz_new_text_span(); + tdev = fz_new_text_device(app->page_text); + fz_execute_display_list(app->page_list, tdev, fz_identity, fz_infinite_bbox); + fz_free_device(tdev); } if (drawpage) @@ -376,24 +376,24 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repai wintitle(app, buf); ctm = pdfapp_viewctm(app); - bbox = fz_roundrect(fz_transformrect(ctm, app->page_bbox)); + bbox = fz_round_rect(fz_transform_rect(ctm, app->page_bbox)); /* Draw */ if (app->image) - fz_droppixmap(app->image); + fz_drop_pixmap(app->image); if (app->grayscale) - colorspace = fz_devicegray; + colorspace = fz_device_gray; else #ifdef _WIN32 - colorspace = fz_devicebgr; + colorspace = fz_device_bgr; #else - colorspace = fz_devicergb; + colorspace = fz_device_rgb; #endif - app->image = fz_newpixmapwithrect(colorspace, bbox); - fz_clearpixmapwithcolor(app->image, 255); - idev = fz_newdrawdevice(app->cache, app->image); - fz_executedisplaylist(app->page_list, idev, ctm, bbox); - fz_freedevice(idev); + app->image = fz_new_pixmap_with_rect(colorspace, bbox); + fz_clear_pixmap_with_color(app->image, 255); + idev = fz_new_draw_device(app->cache, app->image); + fz_execute_display_list(app->page_list, idev, ctm, bbox); + fz_free_device(idev); } if (repaint) @@ -421,15 +421,15 @@ static void pdfapp_showpage(pdfapp_t *app, int loadpage, int drawpage, int repai wincursor(app, ARROW); } - fz_flushwarnings(); + fz_flush_warnings(); } static void pdfapp_gotouri(pdfapp_t *app, fz_obj *uri) { char *buf; - buf = fz_malloc(fz_tostrlen(uri) + 1); - memcpy(buf, fz_tostrbuf(uri), fz_tostrlen(uri)); - buf[fz_tostrlen(uri)] = 0; + buf = fz_malloc(fz_to_str_len(uri) + 1); + memcpy(buf, fz_to_str_buf(uri), fz_to_str_len(uri)); + buf[fz_to_str_len(uri)] = 0; winopenuri(app, buf); fz_free(buf); } @@ -438,7 +438,7 @@ static void pdfapp_gotopage(pdfapp_t *app, fz_obj *obj) { int page; - page = pdf_findpageobject(app->xref, obj); + page = pdf_find_page_object(app->xref, obj); if (app->histlen + 1 == 256) { @@ -450,7 +450,7 @@ static void pdfapp_gotopage(pdfapp_t *app, fz_obj *obj) pdfapp_showpage(app, 1, 1, 1); } -static inline fz_bbox bboxcharat(fz_textspan *span, int idx) +static inline fz_bbox bboxcharat(fz_text_span *span, int idx) { int ofs = 0; while (span) @@ -460,13 +460,13 @@ static inline fz_bbox bboxcharat(fz_textspan *span, int idx) if (span->eol) { if (idx == ofs + span->len) - return fz_emptybbox; + return fz_empty_bbox; ofs ++; } ofs += span->len; span = span->next; } - return fz_emptybbox; + return fz_empty_bbox; } void pdfapp_inverthit(pdfapp_t *app) @@ -478,29 +478,29 @@ void pdfapp_inverthit(pdfapp_t *app) if (app->hit < 0) return; - hitbox = fz_emptybbox; + hitbox = fz_empty_bbox; ctm = pdfapp_viewctm(app); for (i = app->hit; i < app->hit + app->hitlen; i++) { bbox = bboxcharat(app->page_text, i); - if (fz_isemptyrect(bbox)) + if (fz_is_empty_rect(bbox)) { - if (!fz_isemptyrect(hitbox)) - pdfapp_invert(app, fz_transformbbox(ctm, hitbox)); - hitbox = fz_emptybbox; + if (!fz_is_empty_rect(hitbox)) + pdfapp_invert(app, fz_transform_bbox(ctm, hitbox)); + hitbox = fz_empty_bbox; } else { - hitbox = fz_unionbbox(hitbox, bbox); + hitbox = fz_union_bbox(hitbox, bbox); } } - if (!fz_isemptyrect(hitbox)) - pdfapp_invert(app, fz_transformbbox(ctm, hitbox)); + if (!fz_is_empty_rect(hitbox)) + pdfapp_invert(app, fz_transform_bbox(ctm, hitbox)); } -static inline int charat(fz_textspan *span, int idx) +static inline int charat(fz_text_span *span, int idx) { int ofs = 0; while (span) @@ -519,7 +519,7 @@ static inline int charat(fz_textspan *span, int idx) return 0; } -static int textlen(fz_textspan *span) +static int textlen(fz_text_span *span) { int len = 0; while (span) @@ -532,7 +532,7 @@ static int textlen(fz_textspan *span) return len; } -static int match(char *s, fz_textspan *span, int n) +static int match(char *s, fz_text_span *span, int n) { int orig = n; int c; @@ -951,9 +951,9 @@ void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int sta p.y = y - app->pany + app->image->y; ctm = pdfapp_viewctm(app); - ctm = fz_invertmatrix(ctm); + ctm = fz_invert_matrix(ctm); - p = fz_transformpoint(ctm, p); + p = fz_transform_point(ctm, p); for (link = app->page_links; link; link = link->next) { @@ -967,10 +967,10 @@ void pdfapp_onmouse(pdfapp_t *app, int x, int y, int btn, int modifiers, int sta wincursor(app, HAND); if (btn == 1 && state == 1) { - if (link->kind == PDF_LURI) + if (link->kind == PDF_LINK_URI) pdfapp_gotouri(app, link->dest); - else if (link->kind == PDF_LGOTO) - pdfapp_gotopage(app, fz_arrayget(link->dest, 0)); /* [ pageobj ... ] */ + else if (link->kind == PDF_LINK_GOTO) + pdfapp_gotopage(app, fz_array_get(link->dest, 0)); /* [ pageobj ... ] */ return; } } @@ -1067,7 +1067,7 @@ void pdfapp_oncopy(pdfapp_t *app, unsigned short *ucsbuf, int ucslen) { fz_bbox hitbox; fz_matrix ctm; - fz_textspan *span; + fz_text_span *span; int c, i, p; int seen; @@ -1085,7 +1085,7 @@ void pdfapp_oncopy(pdfapp_t *app, unsigned short *ucsbuf, int ucslen) for (i = 0; i < span->len; i++) { - hitbox = fz_transformbbox(ctm, span->text[i].bbox); + hitbox = fz_transform_bbox(ctm, span->text[i].bbox); c = span->text[i].c; if (c < 32) c = '?'; diff --git a/apps/pdfapp.h b/apps/pdfapp.h index dda637db..feb0a8ce 100644 --- a/apps/pdfapp.h +++ b/apps/pdfapp.h @@ -34,7 +34,7 @@ struct pdfapp_s xps_context *xps; int pagecount; - fz_glyphcache *cache; + fz_glyph_cache *cache; /* current view params */ int resolution; @@ -46,8 +46,8 @@ struct pdfapp_s int pageno; fz_rect page_bbox; float page_rotate; - fz_displaylist *page_list; - fz_textspan *page_text; + fz_display_list *page_list; + fz_text_span *page_text; pdf_link *page_links; /* snapback history */ diff --git a/apps/pdfclean.c b/apps/pdfclean.c index 2be479aa..67c7809c 100644 --- a/apps/pdfclean.c +++ b/apps/pdfclean.c @@ -12,24 +12,24 @@ #include "fitz.h" #include "mupdf.h" -static FILE *out = nil; +static FILE *out = NULL; -static char *uselist = nil; -static int *ofslist = nil; -static int *genlist = nil; -static int *renumbermap = nil; +static char *uselist = NULL; +static int *ofslist = NULL; +static int *genlist = NULL; +static int *renumbermap = NULL; static int dogarbage = 0; static int doexpand = 0; static int doascii = 0; -static pdf_xref *xref = nil; +static pdf_xref *xref = NULL; void die(fz_error error) { fz_catch(error, "aborting"); if (xref) - pdf_freexref(xref); + pdf_free_xref(xref); exit(1); } @@ -57,22 +57,22 @@ static void sweepobj(fz_obj *obj) { int i; - if (fz_isindirect(obj)) + if (fz_is_indirect(obj)) sweepref(obj); - else if (fz_isdict(obj)) - for (i = 0; i < fz_dictlen(obj); i++) - sweepobj(fz_dictgetval(obj, i)); + else if (fz_is_dict(obj)) + for (i = 0; i < fz_dict_len(obj); i++) + sweepobj(fz_dict_get_val(obj, i)); - else if (fz_isarray(obj)) - for (i = 0; i < fz_arraylen(obj); i++) - sweepobj(fz_arrayget(obj, i)); + else if (fz_is_array(obj)) + for (i = 0; i < fz_array_len(obj); i++) + sweepobj(fz_array_get(obj, i)); } static void sweepref(fz_obj *obj) { - int num = fz_tonum(obj); - int gen = fz_togen(obj); + int num = fz_to_num(obj); + int gen = fz_to_gen(obj); if (num < 0 || num >= xref->len) return; @@ -82,18 +82,18 @@ static void sweepref(fz_obj *obj) uselist[num] = 1; /* Bake in /Length in stream objects */ - if (pdf_isstream(xref, num, gen)) + if (pdf_is_stream(xref, num, gen)) { - fz_obj *len = fz_dictgets(obj, "Length"); - if (fz_isindirect(len)) + fz_obj *len = fz_dict_gets(obj, "Length"); + if (fz_is_indirect(len)) { - uselist[fz_tonum(len)] = 0; - len = fz_resolveindirect(len); - fz_dictputs(obj, "Length", len); + uselist[fz_to_num(len)] = 0; + len = fz_resolve_indirect(len); + fz_dict_puts(obj, "Length", len); } } - sweepobj(fz_resolveindirect(obj)); + sweepobj(fz_resolve_indirect(obj)); } /* @@ -117,17 +117,17 @@ static void removeduplicateobjs(void) /* * Comparing stream objects data contents would take too long. * - * pdf_isstream calls pdf_cacheobject and ensures + * pdf_is_stream calls pdf_cache_object and ensures * that the xref table has the objects loaded. */ - if (pdf_isstream(xref, num, 0) || pdf_isstream(xref, other, 0)) + if (pdf_is_stream(xref, num, 0) || pdf_is_stream(xref, other, 0)) continue; a = xref->table[num].obj; b = xref->table[other].obj; - a = fz_resolveindirect(a); - b = fz_resolveindirect(b); + a = fz_resolve_indirect(a); + b = fz_resolve_indirect(b); if (fz_objcmp(a, b)) continue; @@ -177,17 +177,17 @@ static void renumberobj(fz_obj *obj) { int i; - if (fz_isdict(obj)) + if (fz_is_dict(obj)) { - for (i = 0; i < fz_dictlen(obj); i++) + for (i = 0; i < fz_dict_len(obj); i++) { - fz_obj *key = fz_dictgetkey(obj, i); - fz_obj *val = fz_dictgetval(obj, i); - if (fz_isindirect(val)) + fz_obj *key = fz_dict_get_key(obj, i); + fz_obj *val = fz_dict_get_val(obj, i); + if (fz_is_indirect(val)) { - val = fz_newindirect(renumbermap[fz_tonum(val)], 0, xref); - fz_dictput(obj, key, val); - fz_dropobj(val); + val = fz_new_indirect(renumbermap[fz_to_num(val)], 0, xref); + fz_dict_put(obj, key, val); + fz_drop_obj(val); } else { @@ -196,16 +196,16 @@ static void renumberobj(fz_obj *obj) } } - else if (fz_isarray(obj)) + else if (fz_is_array(obj)) { - for (i = 0; i < fz_arraylen(obj); i++) + for (i = 0; i < fz_array_len(obj); i++) { - fz_obj *val = fz_arrayget(obj, i); - if (fz_isindirect(val)) + fz_obj *val = fz_array_get(obj, i); + if (fz_is_indirect(val)) { - val = fz_newindirect(renumbermap[fz_tonum(val)], 0, xref); - fz_arrayput(obj, i, val); - fz_dropobj(val); + val = fz_new_indirect(renumbermap[fz_to_num(val)], 0, xref); + fz_array_put(obj, i, val); + fz_drop_obj(val); } else { @@ -217,7 +217,7 @@ static void renumberobj(fz_obj *obj) static void renumberobjs(void) { - pdf_xrefentry *oldxref; + pdf_xref_entry *oldxref; int newlen; int num; @@ -227,11 +227,11 @@ static void renumberobjs(void) { fz_obj *obj = xref->table[num].obj; - if (fz_isindirect(obj)) + if (fz_is_indirect(obj)) { - obj = fz_newindirect(renumbermap[fz_tonum(obj)], 0, xref); - pdf_updateobject(xref, num, 0, obj); - fz_dropobj(obj); + obj = fz_new_indirect(renumbermap[fz_to_num(obj)], 0, xref); + pdf_update_object(xref, num, 0, obj); + fz_drop_obj(obj); } else { @@ -241,7 +241,7 @@ static void renumberobjs(void) /* Create new table for the reordered, compacted xref */ oldxref = xref->table; - xref->table = fz_calloc(xref->len, sizeof(pdf_xrefentry)); + xref->table = fz_calloc(xref->len, sizeof(pdf_xref_entry)); xref->table[0] = oldxref[0]; /* Move used objects into the new compacted xref */ @@ -257,7 +257,7 @@ static void renumberobjs(void) else { if (oldxref[num].obj) - fz_dropobj(oldxref[num].obj); + fz_drop_obj(oldxref[num].obj); } } @@ -281,25 +281,25 @@ static void retainpages(int argc, char **argv) fz_obj *oldroot, *root, *pages, *kids, *countobj, *parent; /* Load the old page tree */ - error = pdf_loadpagetree(xref); + error = pdf_load_page_tree(xref); if (error) die(fz_rethrow(error, "cannot load page tree")); /* Keep only pages/type entry to avoid references to unretained pages */ - oldroot = fz_dictgets(xref->trailer, "Root"); - pages = fz_dictgets(oldroot, "Pages"); + oldroot = fz_dict_gets(xref->trailer, "Root"); + pages = fz_dict_gets(oldroot, "Pages"); - root = fz_newdict(2); - fz_dictputs(root, "Type", fz_dictgets(oldroot, "Type")); - fz_dictputs(root, "Pages", fz_dictgets(oldroot, "Pages")); + root = fz_new_dict(2); + fz_dict_puts(root, "Type", fz_dict_gets(oldroot, "Type")); + fz_dict_puts(root, "Pages", fz_dict_gets(oldroot, "Pages")); - pdf_updateobject(xref, fz_tonum(oldroot), fz_togen(oldroot), root); + pdf_update_object(xref, fz_to_num(oldroot), fz_to_gen(oldroot), root); - fz_dropobj(root); + fz_drop_obj(root); /* Create a new kids array with only the pages we want to keep */ - parent = fz_newindirect(fz_tonum(pages), fz_togen(pages), xref); - kids = fz_newarray(1); + parent = fz_new_indirect(fz_to_num(pages), fz_to_gen(pages), xref); + kids = fz_new_array(1); /* Retain pages specified */ while (argc - fz_optind) @@ -314,7 +314,7 @@ static void retainpages(int argc, char **argv) dash = strchr(spec, '-'); if (dash == spec) - spage = epage = pdf_getpagecount(xref); + spage = epage = pdf_get_page_count(xref); else spage = epage = atoi(spec); @@ -323,7 +323,7 @@ static void retainpages(int argc, char **argv) if (strlen(dash) > 1) epage = atoi(dash + 1); else - epage = pdf_getpagecount(xref); + epage = pdf_get_page_count(xref); } if (spage > epage) @@ -331,18 +331,18 @@ static void retainpages(int argc, char **argv) if (spage < 1) spage = 1; - if (epage > pdf_getpagecount(xref)) - epage = pdf_getpagecount(xref); + if (epage > pdf_get_page_count(xref)) + epage = pdf_get_page_count(xref); for (page = spage; page <= epage; page++) { - fz_obj *pageobj = pdf_getpageobject(xref, page); - fz_obj *pageref = pdf_getpageref(xref, page); + fz_obj *pageobj = pdf_get_page_object(xref, page); + fz_obj *pageref = pdf_get_page_ref(xref, page); - fz_dictputs(pageobj, "Parent", parent); + fz_dict_puts(pageobj, "Parent", parent); /* Store page object in new kids array */ - fz_arraypush(kids, pageref); + fz_array_push(kids, pageref); } spec = fz_strsep(&pagelist, ","); @@ -351,14 +351,14 @@ static void retainpages(int argc, char **argv) fz_optind++; } - fz_dropobj(parent); + fz_drop_obj(parent); /* Update page count and kids array */ - countobj = fz_newint(fz_arraylen(kids)); - fz_dictputs(pages, "Count", countobj); - fz_dropobj(countobj); - fz_dictputs(pages, "Kids", kids); - fz_dropobj(kids); + countobj = fz_new_int(fz_array_len(kids)); + fz_dict_puts(pages, "Count", countobj); + fz_drop_obj(countobj); + fz_dict_puts(pages, "Kids", kids); + fz_drop_obj(kids); } /* @@ -375,10 +375,10 @@ static void preloadobjstms(void) { if (xref->table[num].type == 'o') { - error = pdf_loadobject(&obj, xref, num, 0); + error = pdf_load_object(&obj, xref, num, 0); if (error) die(error); - fz_dropobj(obj); + fz_drop_obj(obj); } } } @@ -409,7 +409,7 @@ static fz_buffer *hexbuf(unsigned char *p, int n) fz_buffer *buf; int x = 0; - buf = fz_newbuffer(n * 2 + (n / 32) + 2); + buf = fz_new_buffer(n * 2 + (n / 32) + 2); while (n--) { @@ -434,46 +434,46 @@ static void addhexfilter(fz_obj *dict) fz_obj *f, *dp, *newf, *newdp; fz_obj *ahx, *nullobj; - ahx = fz_newname("ASCIIHexDecode"); - nullobj = fz_newnull(); - newf = newdp = nil; + ahx = fz_new_name("ASCIIHexDecode"); + nullobj = fz_new_null(); + newf = newdp = NULL; - f = fz_dictgets(dict, "Filter"); - dp = fz_dictgets(dict, "DecodeParms"); + f = fz_dict_gets(dict, "Filter"); + dp = fz_dict_gets(dict, "DecodeParms"); - if (fz_isname(f)) + if (fz_is_name(f)) { - newf = fz_newarray(2); - fz_arraypush(newf, ahx); - fz_arraypush(newf, f); + newf = fz_new_array(2); + fz_array_push(newf, ahx); + fz_array_push(newf, f); f = newf; - if (fz_isdict(dp)) + if (fz_is_dict(dp)) { - newdp = fz_newarray(2); - fz_arraypush(newdp, nullobj); - fz_arraypush(newdp, dp); + newdp = fz_new_array(2); + fz_array_push(newdp, nullobj); + fz_array_push(newdp, dp); dp = newdp; } } - else if (fz_isarray(f)) + else if (fz_is_array(f)) { - fz_arrayinsert(f, ahx); - if (fz_isarray(dp)) - fz_arrayinsert(dp, nullobj); + fz_array_insert(f, ahx); + if (fz_is_array(dp)) + fz_array_insert(dp, nullobj); } else f = ahx; - fz_dictputs(dict, "Filter", f); + fz_dict_puts(dict, "Filter", f); if (dp) - fz_dictputs(dict, "DecodeParms", dp); + fz_dict_puts(dict, "DecodeParms", dp); - fz_dropobj(ahx); - fz_dropobj(nullobj); + fz_drop_obj(ahx); + fz_drop_obj(nullobj); if (newf) - fz_dropobj(newf); + fz_drop_obj(newf); if (newdp) - fz_dropobj(newdp); + fz_drop_obj(newdp); } static void copystream(fz_obj *obj, int num, int gen) @@ -482,30 +482,30 @@ static void copystream(fz_obj *obj, int num, int gen) fz_buffer *buf, *tmp; fz_obj *newlen; - error = pdf_loadrawstream(&buf, xref, num, gen); + error = pdf_load_raw_stream(&buf, xref, num, gen); if (error) die(error); if (doascii && isbinarystream(buf)) { tmp = hexbuf(buf->data, buf->len); - fz_dropbuffer(buf); + fz_drop_buffer(buf); buf = tmp; addhexfilter(obj); - newlen = fz_newint(buf->len); - fz_dictputs(obj, "Length", newlen); - fz_dropobj(newlen); + newlen = fz_new_int(buf->len); + fz_dict_puts(obj, "Length", newlen); + fz_drop_obj(newlen); } fprintf(out, "%d %d obj\n", num, gen); - fz_fprintobj(out, obj, !doexpand); + fz_fprint_obj(out, obj, !doexpand); fprintf(out, "stream\n"); fwrite(buf->data, 1, buf->len, out); fprintf(out, "endstream\nendobj\n\n"); - fz_dropbuffer(buf); + fz_drop_buffer(buf); } static void expandstream(fz_obj *obj, int num, int gen) @@ -514,33 +514,33 @@ static void expandstream(fz_obj *obj, int num, int gen) fz_buffer *buf, *tmp; fz_obj *newlen; - error = pdf_loadstream(&buf, xref, num, gen); + error = pdf_load_stream(&buf, xref, num, gen); if (error) die(error); - fz_dictdels(obj, "Filter"); - fz_dictdels(obj, "DecodeParms"); + fz_dict_dels(obj, "Filter"); + fz_dict_dels(obj, "DecodeParms"); if (doascii && isbinarystream(buf)) { tmp = hexbuf(buf->data, buf->len); - fz_dropbuffer(buf); + fz_drop_buffer(buf); buf = tmp; addhexfilter(obj); } - newlen = fz_newint(buf->len); - fz_dictputs(obj, "Length", newlen); - fz_dropobj(newlen); + newlen = fz_new_int(buf->len); + fz_dict_puts(obj, "Length", newlen); + fz_drop_obj(newlen); fprintf(out, "%d %d obj\n", num, gen); - fz_fprintobj(out, obj, !doexpand); + fz_fprint_obj(out, obj, !doexpand); fprintf(out, "stream\n"); fwrite(buf->data, 1, buf->len, out); fprintf(out, "endstream\nendobj\n\n"); - fz_dropbuffer(buf); + fz_drop_buffer(buf); } static void writeobject(int num, int gen) @@ -549,43 +549,43 @@ static void writeobject(int num, int gen) fz_obj *obj; fz_obj *type; - error = pdf_loadobject(&obj, xref, num, gen); + error = pdf_load_object(&obj, xref, num, gen); if (error) die(error); /* skip ObjStm and XRef objects */ - if (fz_isdict(obj)) + if (fz_is_dict(obj)) { - type = fz_dictgets(obj, "Type"); - if (fz_isname(type) && !strcmp(fz_toname(type), "ObjStm")) + type = fz_dict_gets(obj, "Type"); + if (fz_is_name(type) && !strcmp(fz_to_name(type), "ObjStm")) { uselist[num] = 0; - fz_dropobj(obj); + fz_drop_obj(obj); return; } - if (fz_isname(type) && !strcmp(fz_toname(type), "XRef")) + if (fz_is_name(type) && !strcmp(fz_to_name(type), "XRef")) { uselist[num] = 0; - fz_dropobj(obj); + fz_drop_obj(obj); return; } } - if (!pdf_isstream(xref, num, gen)) + if (!pdf_is_stream(xref, num, gen)) { fprintf(out, "%d %d obj\n", num, gen); - fz_fprintobj(out, obj, !doexpand); + fz_fprint_obj(out, obj, !doexpand); fprintf(out, "endobj\n\n"); } else { - if (doexpand && !pdf_isjpximage(obj)) + if (doexpand && !pdf_is_jpx_image(obj)) expandstream(obj, num, gen); else copystream(obj, num, gen); } - fz_dropobj(obj); + fz_drop_obj(obj); } static void writexref(void) @@ -607,29 +607,29 @@ static void writexref(void) } fprintf(out, "\n"); - trailer = fz_newdict(5); + trailer = fz_new_dict(5); - obj = fz_newint(xref->len); - fz_dictputs(trailer, "Size", obj); - fz_dropobj(obj); + obj = fz_new_int(xref->len); + fz_dict_puts(trailer, "Size", obj); + fz_drop_obj(obj); - obj = fz_dictgets(xref->trailer, "Info"); + obj = fz_dict_gets(xref->trailer, "Info"); if (obj) - fz_dictputs(trailer, "Info", obj); + fz_dict_puts(trailer, "Info", obj); - obj = fz_dictgets(xref->trailer, "Root"); + obj = fz_dict_gets(xref->trailer, "Root"); if (obj) - fz_dictputs(trailer, "Root", obj); + fz_dict_puts(trailer, "Root", obj); - obj = fz_dictgets(xref->trailer, "ID"); + obj = fz_dict_gets(xref->trailer, "ID"); if (obj) - fz_dictputs(trailer, "ID", obj); + fz_dict_puts(trailer, "ID", obj); fprintf(out, "trailer\n"); - fz_fprintobj(out, trailer, !doexpand); + fz_fprint_obj(out, trailer, !doexpand); fprintf(out, "\n"); - fz_dropobj(trailer); + fz_drop_obj(trailer); fprintf(out, "startxref\n%d\n%%%%EOF\n", startxref); } @@ -710,7 +710,7 @@ int main(int argc, char **argv) if (argc - fz_optind > 0) subset = 1; - error = pdf_openxref(&xref, infile, password); + error = pdf_open_xref(&xref, infile, password); if (error) die(fz_rethrow(error, "cannot open input file '%s'", infile)); @@ -767,9 +767,9 @@ int main(int argc, char **argv) fz_free(genlist); fz_free(renumbermap); - pdf_freexref(xref); + pdf_free_xref(xref); - fz_flushwarnings(); + fz_flush_warnings(); return 0; } diff --git a/apps/pdfdraw.c b/apps/pdfdraw.c index 3de0a80c..f15fdfb4 100644 --- a/apps/pdfdraw.c +++ b/apps/pdfdraw.c @@ -11,7 +11,7 @@ #include #endif -char *output = nil; +char *output = NULL; float resolution = 72; float rotation = 0; @@ -23,7 +23,7 @@ int savealpha = 0; int uselist = 1; fz_colorspace *colorspace; -fz_glyphcache *glyphcache; +fz_glyph_cache *glyphcache; char *filename; struct { @@ -66,10 +66,10 @@ static int gettime(void) struct timeval now; if (once) { - gettimeofday(&first, nil); + gettimeofday(&first, NULL); once = 0; } - gettimeofday(&now, nil); + gettimeofday(&now, NULL); return (now.tv_sec - first.tv_sec) * 1000 + (now.tv_usec - first.tv_usec) / 1000; } @@ -89,7 +89,7 @@ static void drawpage(pdf_xref *xref, int pagenum) fz_error error; fz_obj *pageobj; pdf_page *page; - fz_displaylist *list; + fz_display_list *list; fz_device *dev; int start; @@ -98,51 +98,51 @@ static void drawpage(pdf_xref *xref, int pagenum) start = gettime(); } - pageobj = pdf_getpageobject(xref, pagenum); - error = pdf_loadpage(&page, xref, pageobj); + pageobj = pdf_get_page_object(xref, pagenum); + error = pdf_load_page(&page, xref, pageobj); if (error) die(fz_rethrow(error, "cannot load page %d in file '%s'", pagenum, filename)); - list = nil; + list = NULL; if (uselist) { - list = fz_newdisplaylist(); - dev = fz_newlistdevice(list); - error = pdf_runpage(xref, page, dev, fz_identity); + list = fz_new_display_list(); + dev = fz_new_list_device(list); + error = pdf_run_page(xref, page, dev, fz_identity); if (error) die(fz_rethrow(error, "cannot draw page %d in file '%s'", pagenum, filename)); - fz_freedevice(dev); + fz_free_device(dev); } if (showxml) { - dev = fz_newtracedevice(); + dev = fz_new_trace_device(); printf("\n", pagenum); if (list) - fz_executedisplaylist(list, dev, fz_identity, fz_infinitebbox); + fz_execute_display_list(list, dev, fz_identity, fz_infinite_bbox); else - pdf_runpage(xref, page, dev, fz_identity); + pdf_run_page(xref, page, dev, fz_identity); printf("\n"); - fz_freedevice(dev); + fz_free_device(dev); } if (showtext) { - fz_textspan *text = fz_newtextspan(); - dev = fz_newtextdevice(text); + fz_text_span *text = fz_new_text_span(); + dev = fz_new_text_device(text); if (list) - fz_executedisplaylist(list, dev, fz_identity, fz_infinitebbox); + fz_execute_display_list(list, dev, fz_identity, fz_infinite_bbox); else - pdf_runpage(xref, page, dev, fz_identity); - fz_freedevice(dev); + pdf_run_page(xref, page, dev, fz_identity); + fz_free_device(dev); printf("[Page %d]\n", pagenum); if (showtext > 1) - fz_debugtextspanxml(text); + fz_debug_text_span_xml(text); else - fz_debugtextspan(text); + fz_debug_text_span(text); printf("\n"); - fz_freetextspan(text); + fz_free_text_span(text); } if (showmd5 || showtime) @@ -160,34 +160,34 @@ static void drawpage(pdf_xref *xref, int pagenum) ctm = fz_concat(ctm, fz_scale(zoom, -zoom)); ctm = fz_concat(ctm, fz_rotate(page->rotate)); ctm = fz_concat(ctm, fz_rotate(rotation)); - bbox = fz_roundrect(fz_transformrect(ctm, page->mediabox)); + bbox = fz_round_rect(fz_transform_rect(ctm, page->mediabox)); /* TODO: banded rendering and multi-page ppm */ - pix = fz_newpixmapwithrect(colorspace, bbox); + pix = fz_new_pixmap_with_rect(colorspace, bbox); if (savealpha) - fz_clearpixmap(pix); + fz_clear_pixmap(pix); else - fz_clearpixmapwithcolor(pix, 255); + fz_clear_pixmap_with_color(pix, 255); - dev = fz_newdrawdevice(glyphcache, pix); + dev = fz_new_draw_device(glyphcache, pix); if (list) - fz_executedisplaylist(list, dev, ctm, bbox); + fz_execute_display_list(list, dev, ctm, bbox); else - pdf_runpage(xref, page, dev, ctm); - fz_freedevice(dev); + pdf_run_page(xref, page, dev, ctm); + fz_free_device(dev); if (output) { char buf[512]; sprintf(buf, output, pagenum); if (strstr(output, ".pgm") || strstr(output, ".ppm") || strstr(output, ".pnm")) - fz_writepnm(pix, buf); + fz_write_pnm(pix, buf); else if (strstr(output, ".pam")) - fz_writepam(pix, buf, savealpha); + fz_write_pam(pix, buf, savealpha); else if (strstr(output, ".png")) - fz_writepng(pix, buf, savealpha); + fz_write_png(pix, buf, savealpha); } if (showmd5) @@ -196,22 +196,22 @@ static void drawpage(pdf_xref *xref, int pagenum) unsigned char digest[16]; int i; - fz_md5init(&md5); - fz_md5update(&md5, pix->samples, pix->w * pix->h * pix->n); - fz_md5final(&md5, digest); + fz_md5_init(&md5); + fz_md5_update(&md5, pix->samples, pix->w * pix->h * pix->n); + fz_md5_final(&md5, digest); printf(" "); for (i = 0; i < 16; i++) printf("%02x", digest[i]); } - fz_droppixmap(pix); + fz_drop_pixmap(pix); } if (list) - fz_freedisplaylist(list); + fz_free_display_list(list); - pdf_freepage(page); + pdf_free_page(page); if (showtime) { @@ -237,9 +237,9 @@ static void drawpage(pdf_xref *xref, int pagenum) if (showmd5 || showtime) printf("\n"); - pdf_agestore(xref->store, 3); + pdf_age_store(xref->store, 3); - fz_flushwarnings(); + fz_flush_warnings(); } static void drawrange(pdf_xref *xref, char *range) @@ -253,7 +253,7 @@ static void drawrange(pdf_xref *xref, char *range) dash = strchr(spec, '-'); if (dash == spec) - spage = epage = pdf_getpagecount(xref); + spage = epage = pdf_get_page_count(xref); else spage = epage = atoi(spec); @@ -262,11 +262,11 @@ static void drawrange(pdf_xref *xref, char *range) if (strlen(dash) > 1) epage = atoi(dash + 1); else - epage = pdf_getpagecount(xref); + epage = pdf_get_page_count(xref); } - spage = CLAMP(spage, 1, pdf_getpagecount(xref)); - epage = CLAMP(epage, 1, pdf_getpagecount(xref)); + spage = CLAMP(spage, 1, pdf_get_page_count(xref)); + epage = CLAMP(epage, 1, pdf_get_page_count(xref)); if (spage < epage) for (page = spage; page <= epage; page++) @@ -320,15 +320,15 @@ int main(int argc, char **argv) if (accelerate) fz_accelerate(); - glyphcache = fz_newglyphcache(); + glyphcache = fz_new_glyph_cache(); - colorspace = fz_devicergb; + colorspace = fz_device_rgb; if (grayscale) - colorspace = fz_devicegray; + colorspace = fz_device_gray; if (output && strstr(output, ".pgm")) - colorspace = fz_devicegray; + colorspace = fz_device_gray; if (output && strstr(output, ".ppm")) - colorspace = fz_devicergb; + colorspace = fz_device_rgb; timing.count = 0; timing.total = 0; @@ -344,11 +344,11 @@ int main(int argc, char **argv) { filename = argv[fz_optind++]; - error = pdf_openxref(&xref, filename, password); + error = pdf_open_xref(&xref, filename, password); if (error) die(fz_rethrow(error, "cannot open document: %s", filename)); - error = pdf_loadpagetree(xref); + error = pdf_load_page_tree(xref); if (error) die(fz_rethrow(error, "cannot load page tree: %s", filename)); @@ -363,7 +363,7 @@ int main(int argc, char **argv) if (showxml) printf("\n"); - pdf_freexref(xref); + pdf_free_xref(xref); } if (showtime) @@ -374,9 +374,9 @@ int main(int argc, char **argv) printf("slowest page %d: %dms\n", timing.maxpage, timing.max); } - fz_freeglyphcache(glyphcache); + fz_free_glyph_cache(glyphcache); - fz_flushwarnings(); + fz_flush_warnings(); return 0; } diff --git a/apps/pdfextract.c b/apps/pdfextract.c index 1d01b4d5..45185cee 100644 --- a/apps/pdfextract.c +++ b/apps/pdfextract.c @@ -5,14 +5,14 @@ #include "fitz.h" #include "mupdf.h" -static pdf_xref *xref = nil; +static pdf_xref *xref = NULL; static int dorgb = 0; void die(fz_error error) { fz_catch(error, "aborting"); if (xref) - pdf_freexref(xref); + pdf_free_xref(xref); exit(1); } @@ -26,14 +26,14 @@ static void usage(void) static int isimage(fz_obj *obj) { - fz_obj *type = fz_dictgets(obj, "Subtype"); - return fz_isname(type) && !strcmp(fz_toname(type), "Image"); + fz_obj *type = fz_dict_gets(obj, "Subtype"); + return fz_is_name(type) && !strcmp(fz_to_name(type), "Image"); } static int isfontdesc(fz_obj *obj) { - fz_obj *type = fz_dictgets(obj, "Type"); - return fz_isname(type) && !strcmp(fz_toname(type), "FontDescriptor"); + fz_obj *type = fz_dict_gets(obj, "Type"); + return fz_is_name(type) && !strcmp(fz_to_name(type), "FontDescriptor"); } static void saveimage(int num) @@ -43,20 +43,20 @@ static void saveimage(int num) fz_obj *ref; char name[1024]; - ref = fz_newindirect(num, 0, xref); + ref = fz_new_indirect(num, 0, xref); /* TODO: detect DCTD and save as jpeg */ - error = pdf_loadimage(&img, xref, ref); + error = pdf_load_image(&img, xref, ref); if (error) die(error); - if (dorgb && img->colorspace && img->colorspace != fz_devicergb) + if (dorgb && img->colorspace && img->colorspace != fz_device_rgb) { fz_pixmap *temp; - temp = fz_newpixmap(fz_devicergb, img->x, img->y, img->w, img->h); - fz_convertpixmap(img, temp); - fz_droppixmap(img); + temp = fz_new_pixmap(fz_device_rgb, img->x, img->y, img->w, img->h); + fz_convert_pixmap(img, temp); + fz_drop_pixmap(img); img = temp; } @@ -64,17 +64,17 @@ static void saveimage(int num) { sprintf(name, "img-%04d.png", num); printf("extracting image %s\n", name); - fz_writepng(img, name, 0); + fz_write_png(img, name, 0); } else { sprintf(name, "img-%04d.pam", num); printf("extracting image %s\n", name); - fz_writepam(img, name, 0); + fz_write_pam(img, name, 0); } - fz_droppixmap(img); - fz_dropobj(ref); + fz_drop_pixmap(img); + fz_drop_obj(ref); } static void savefont(fz_obj *dict, int num) @@ -83,41 +83,41 @@ static void savefont(fz_obj *dict, int num) char name[1024]; char *subtype; fz_buffer *buf; - fz_obj *stream = nil; + fz_obj *stream = NULL; fz_obj *obj; char *ext = ""; FILE *f; char *fontname = "font"; int n; - obj = fz_dictgets(dict, "FontName"); + obj = fz_dict_gets(dict, "FontName"); if (obj) - fontname = fz_toname(obj); + fontname = fz_to_name(obj); - obj = fz_dictgets(dict, "FontFile"); + obj = fz_dict_gets(dict, "FontFile"); if (obj) { stream = obj; ext = "pfa"; } - obj = fz_dictgets(dict, "FontFile2"); + obj = fz_dict_gets(dict, "FontFile2"); if (obj) { stream = obj; ext = "ttf"; } - obj = fz_dictgets(dict, "FontFile3"); + obj = fz_dict_gets(dict, "FontFile3"); if (obj) { stream = obj; - obj = fz_dictgets(obj, "Subtype"); - if (obj && !fz_isname(obj)) + obj = fz_dict_gets(obj, "Subtype"); + if (obj && !fz_is_name(obj)) die(fz_throw("Invalid font descriptor subtype")); - subtype = fz_toname(obj); + subtype = fz_to_name(obj); if (!strcmp(subtype, "Type1C")) ext = "cff"; else if (!strcmp(subtype, "CIDFontType0C")) @@ -132,9 +132,9 @@ static void savefont(fz_obj *dict, int num) return; } - buf = fz_newbuffer(0); + buf = fz_new_buffer(0); - error = pdf_loadstream(&buf, xref, fz_tonum(stream), fz_togen(stream)); + error = pdf_load_stream(&buf, xref, fz_to_num(stream), fz_to_gen(stream)); if (error) die(error); @@ -142,7 +142,7 @@ static void savefont(fz_obj *dict, int num) printf("extracting font %s\n", name); f = fopen(name, "wb"); - if (f == nil) + if (f == NULL) die(fz_throw("Error creating font file")); n = fwrite(buf->data, 1, buf->len, f); @@ -152,7 +152,7 @@ static void savefont(fz_obj *dict, int num) if (fclose(f) < 0) die(fz_throw("Error closing font file")); - fz_dropbuffer(buf); + fz_drop_buffer(buf); } static void showobject(int num) @@ -163,7 +163,7 @@ static void showobject(int num) if (!xref) die(fz_throw("no file specified")); - error = pdf_loadobject(&obj, xref, num, 0); + error = pdf_load_object(&obj, xref, num, 0); if (error) die(error); @@ -172,7 +172,7 @@ static void showobject(int num) else if (isfontdesc(obj)) savefont(obj, num); - fz_dropobj(obj); + fz_drop_obj(obj); } int main(int argc, char **argv) @@ -196,7 +196,7 @@ int main(int argc, char **argv) usage(); infile = argv[fz_optind++]; - error = pdf_openxref(&xref, infile, password); + error = pdf_open_xref(&xref, infile, password); if (error) die(fz_rethrow(error, "cannot open input file '%s'", infile)); @@ -214,9 +214,9 @@ int main(int argc, char **argv) } } - pdf_freexref(xref); + pdf_free_xref(xref); - fz_flushwarnings(); + fz_flush_warnings(); return 0; } diff --git a/apps/pdfinfo.c b/apps/pdfinfo.c index e85ac00a..fcc2cb38 100644 --- a/apps/pdfinfo.c +++ b/apps/pdfinfo.c @@ -80,19 +80,19 @@ struct info } u; }; -static struct info *dim = nil; +static struct info *dim = NULL; static int dims = 0; -static struct info *font = nil; +static struct info *font = NULL; static int fonts = 0; -static struct info *image = nil; +static struct info *image = NULL; static int images = 0; -static struct info *shading = nil; +static struct info *shading = NULL; static int shadings = 0; -static struct info *pattern = nil; +static struct info *pattern = NULL; static int patterns = 0; -static struct info *form = nil; +static struct info *form = NULL; static int forms = 0; -static struct info *psobj = nil; +static struct info *psobj = NULL; static int psobjs = 0; void closexref(void) @@ -100,8 +100,8 @@ void closexref(void) int i; if (xref) { - pdf_freexref(xref); - xref = nil; + pdf_free_xref(xref); + xref = NULL; } if (dim) @@ -109,56 +109,56 @@ void closexref(void) for (i = 0; i < dims; i++) fz_free(dim[i].u.dim.bbox); fz_free(dim); - dim = nil; + dim = NULL; dims = 0; } if (font) { fz_free(font); - font = nil; + font = NULL; fonts = 0; } if (image) { fz_free(image); - image = nil; + image = NULL; images = 0; } if (shading) { fz_free(shading); - shading = nil; + shading = NULL; shadings = 0; } if (pattern) { fz_free(pattern); - pattern = nil; + pattern = NULL; patterns = 0; } if (form) { fz_free(form); - form = nil; + form = NULL; forms = 0; } if (psobj) { fz_free(psobj); - psobj = nil; + psobj = NULL; psobjs = 0; } if (xref && xref->store) { - pdf_freestore(xref->store); - xref->store = nil; + pdf_free_store(xref->store); + xref->store = NULL; } } @@ -184,18 +184,18 @@ showglobalinfo(void) printf("\nPDF-%d.%d\n", xref->version / 10, xref->version % 10); - obj = fz_dictgets(xref->trailer, "Info"); + obj = fz_dict_gets(xref->trailer, "Info"); if (obj) { - printf("Info object (%d %d R):\n", fz_tonum(obj), fz_togen(obj)); - fz_debugobj(fz_resolveindirect(obj)); + printf("Info object (%d %d R):\n", fz_to_num(obj), fz_to_gen(obj)); + fz_debug_obj(fz_resolve_indirect(obj)); } - obj = fz_dictgets(xref->trailer, "Encrypt"); + obj = fz_dict_gets(xref->trailer, "Encrypt"); if (obj) { - printf("\nEncryption object (%d %d R):\n", fz_tonum(obj), fz_togen(obj)); - fz_debugobj(fz_resolveindirect(obj)); + printf("\nEncryption object (%d %d R):\n", fz_to_num(obj), fz_to_gen(obj)); + fz_debug_obj(fz_resolve_indirect(obj)); } printf("\nPages: %d\n\n", pagecount); @@ -208,11 +208,11 @@ gatherdimensions(int page, fz_obj *pageref, fz_obj *pageobj) fz_obj *obj; int j; - obj = fz_dictgets(pageobj, "MediaBox"); - if (!fz_isarray(obj)) + obj = fz_dict_gets(pageobj, "MediaBox"); + if (!fz_is_array(obj)) return; - bbox = pdf_torect(obj); + bbox = pdf_to_rect(obj); for (j = 0; j < dims; j++) if (!memcmp(dim[j].u.dim.bbox, &bbox, sizeof (fz_rect))) @@ -238,25 +238,25 @@ gatherfonts(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict) { int i; - for (i = 0; i < fz_dictlen(dict); i++) + for (i = 0; i < fz_dict_len(dict); i++) { - fz_obj *fontdict = nil; - fz_obj *subtype = nil; - fz_obj *basefont = nil; - fz_obj *name = nil; + fz_obj *fontdict = NULL; + fz_obj *subtype = NULL; + fz_obj *basefont = NULL; + fz_obj *name = NULL; int k; - fontdict = fz_dictgetval(dict, i); - if (!fz_isdict(fontdict)) + fontdict = fz_dict_get_val(dict, i); + if (!fz_is_dict(fontdict)) { - fz_warn("not a font dict (%d %d R)", fz_tonum(fontdict), fz_togen(fontdict)); + fz_warn("not a font dict (%d %d R)", fz_to_num(fontdict), fz_to_gen(fontdict)); continue; } - subtype = fz_dictgets(fontdict, "Subtype"); - basefont = fz_dictgets(fontdict, "BaseFont"); - if (!basefont || fz_isnull(basefont)) - name = fz_dictgets(fontdict, "Name"); + subtype = fz_dict_gets(fontdict, "Subtype"); + basefont = fz_dict_gets(fontdict, "BaseFont"); + if (!basefont || fz_is_null(basefont)) + name = fz_dict_gets(fontdict, "Name"); for (k = 0; k < fonts; k++) if (!fz_objcmp(font[k].u.font.obj, fontdict)) @@ -282,49 +282,49 @@ gatherimages(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict) { int i; - for (i = 0; i < fz_dictlen(dict); i++) + for (i = 0; i < fz_dict_len(dict); i++) { fz_obj *imagedict; fz_obj *type; fz_obj *width; fz_obj *height; - fz_obj *bpc = nil; - fz_obj *filter = nil; - fz_obj *cs = nil; + fz_obj *bpc = NULL; + fz_obj *filter = NULL; + fz_obj *cs = NULL; fz_obj *altcs; int k; - imagedict = fz_dictgetval(dict, i); - if (!fz_isdict(imagedict)) + imagedict = fz_dict_get_val(dict, i); + if (!fz_is_dict(imagedict)) { - fz_warn("not an image dict (%d %d R)", fz_tonum(imagedict), fz_togen(imagedict)); + fz_warn("not an image dict (%d %d R)", fz_to_num(imagedict), fz_to_gen(imagedict)); continue; } - type = fz_dictgets(imagedict, "Subtype"); - if (strcmp(fz_toname(type), "Image")) + type = fz_dict_gets(imagedict, "Subtype"); + if (strcmp(fz_to_name(type), "Image")) continue; - filter = fz_dictgets(imagedict, "Filter"); + filter = fz_dict_gets(imagedict, "Filter"); - altcs = nil; - cs = fz_dictgets(imagedict, "ColorSpace"); - if (fz_isarray(cs)) + altcs = NULL; + cs = fz_dict_gets(imagedict, "ColorSpace"); + if (fz_is_array(cs)) { fz_obj *cses = cs; - cs = fz_arrayget(cses, 0); - if (fz_isname(cs) && (!strcmp(fz_toname(cs), "DeviceN") || !strcmp(fz_toname(cs), "Separation"))) + cs = fz_array_get(cses, 0); + if (fz_is_name(cs) && (!strcmp(fz_to_name(cs), "DeviceN") || !strcmp(fz_to_name(cs), "Separation"))) { - altcs = fz_arrayget(cses, 2); - if (fz_isarray(altcs)) - altcs = fz_arrayget(altcs, 0); + altcs = fz_array_get(cses, 2); + if (fz_is_array(altcs)) + altcs = fz_array_get(altcs, 0); } } - width = fz_dictgets(imagedict, "Width"); - height = fz_dictgets(imagedict, "Height"); - bpc = fz_dictgets(imagedict, "BitsPerComponent"); + width = fz_dict_gets(imagedict, "Width"); + height = fz_dict_gets(imagedict, "Height"); + bpc = fz_dict_gets(imagedict, "BitsPerComponent"); for (k = 0; k < images; k++) if (!fz_objcmp(image[k].u.image.obj, imagedict)) @@ -354,7 +354,7 @@ gatherforms(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict) { int i; - for (i = 0; i < fz_dictlen(dict); i++) + for (i = 0; i < fz_dict_len(dict); i++) { fz_obj *xobjdict; fz_obj *type; @@ -364,24 +364,24 @@ gatherforms(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict) fz_obj *reference; int k; - xobjdict = fz_dictgetval(dict, i); - if (!fz_isdict(xobjdict)) + xobjdict = fz_dict_get_val(dict, i); + if (!fz_is_dict(xobjdict)) { - fz_warn("not a xobject dict (%d %d R)", fz_tonum(xobjdict), fz_togen(xobjdict)); + fz_warn("not a xobject dict (%d %d R)", fz_to_num(xobjdict), fz_to_gen(xobjdict)); continue; } - type = fz_dictgets(xobjdict, "Subtype"); - if (strcmp(fz_toname(type), "Form")) + type = fz_dict_gets(xobjdict, "Subtype"); + if (strcmp(fz_to_name(type), "Form")) continue; - subtype = fz_dictgets(xobjdict, "Subtype2"); - if (!strcmp(fz_toname(subtype), "PS")) + subtype = fz_dict_gets(xobjdict, "Subtype2"); + if (!strcmp(fz_to_name(subtype), "PS")) continue; - group = fz_dictgets(xobjdict, "Group"); - groupsubtype = fz_dictgets(group, "S"); - reference = fz_dictgets(xobjdict, "Ref"); + group = fz_dict_gets(xobjdict, "Group"); + groupsubtype = fz_dict_gets(group, "S"); + reference = fz_dict_gets(xobjdict, "Ref"); for (k = 0; k < forms; k++) if (!fz_objcmp(form[k].u.form.obj, xobjdict)) @@ -407,24 +407,24 @@ gatherpsobjs(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict) { int i; - for (i = 0; i < fz_dictlen(dict); i++) + for (i = 0; i < fz_dict_len(dict); i++) { fz_obj *xobjdict; fz_obj *type; fz_obj *subtype; int k; - xobjdict = fz_dictgetval(dict, i); - if (!fz_isdict(xobjdict)) + xobjdict = fz_dict_get_val(dict, i); + if (!fz_is_dict(xobjdict)) { - fz_warn("not a xobject dict (%d %d R)", fz_tonum(xobjdict), fz_togen(xobjdict)); + fz_warn("not a xobject dict (%d %d R)", fz_to_num(xobjdict), fz_to_gen(xobjdict)); continue; } - type = fz_dictgets(xobjdict, "Subtype"); - subtype = fz_dictgets(xobjdict, "Subtype2"); - if (strcmp(fz_toname(type), "PS") && - (strcmp(fz_toname(type), "Form") || strcmp(fz_toname(subtype), "PS"))) + type = fz_dict_gets(xobjdict, "Subtype"); + subtype = fz_dict_gets(xobjdict, "Subtype2"); + if (strcmp(fz_to_name(type), "PS") && + (strcmp(fz_to_name(type), "Form") || strcmp(fz_to_name(subtype), "PS"))) continue; for (k = 0; k < psobjs; k++) @@ -449,24 +449,24 @@ gathershadings(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict) { int i; - for (i = 0; i < fz_dictlen(dict); i++) + for (i = 0; i < fz_dict_len(dict); i++) { fz_obj *shade; fz_obj *type; int k; - shade = fz_dictgetval(dict, i); - if (!fz_isdict(shade)) + shade = fz_dict_get_val(dict, i); + if (!fz_is_dict(shade)) { - fz_warn("not a shading dict (%d %d R)", fz_tonum(shade), fz_togen(shade)); + fz_warn("not a shading dict (%d %d R)", fz_to_num(shade), fz_to_gen(shade)); continue; } - type = fz_dictgets(shade, "ShadingType"); - if (!fz_isint(type) || fz_toint(type) < 1 || fz_toint(type) > 7) + type = fz_dict_gets(shade, "ShadingType"); + if (!fz_is_int(type) || fz_to_int(type) < 1 || fz_to_int(type) > 7) { - fz_warn("not a shading type (%d %d R)", fz_tonum(shade), fz_togen(shade)); - type = nil; + fz_warn("not a shading type (%d %d R)", fz_to_num(shade), fz_to_gen(shade)); + type = NULL; } for (k = 0; k < shadings; k++) @@ -492,48 +492,48 @@ gatherpatterns(int page, fz_obj *pageref, fz_obj *pageobj, fz_obj *dict) { int i; - for (i = 0; i < fz_dictlen(dict); i++) + for (i = 0; i < fz_dict_len(dict); i++) { fz_obj *patterndict; fz_obj *type; - fz_obj *paint = nil; - fz_obj *tiling = nil; - fz_obj *shading = nil; + fz_obj *paint = NULL; + fz_obj *tiling = NULL; + fz_obj *shading = NULL; int k; - patterndict = fz_dictgetval(dict, i); - if (!fz_isdict(patterndict)) + patterndict = fz_dict_get_val(dict, i); + if (!fz_is_dict(patterndict)) { - fz_warn("not a pattern dict (%d %d R)", fz_tonum(patterndict), fz_togen(patterndict)); + fz_warn("not a pattern dict (%d %d R)", fz_to_num(patterndict), fz_to_gen(patterndict)); continue; } - type = fz_dictgets(patterndict, "PatternType"); - if (!fz_isint(type) || fz_toint(type) < 1 || fz_toint(type) > 2) + type = fz_dict_gets(patterndict, "PatternType"); + if (!fz_is_int(type) || fz_to_int(type) < 1 || fz_to_int(type) > 2) { - fz_warn("not a pattern type (%d %d R)", fz_tonum(patterndict), fz_togen(patterndict)); - type = nil; + fz_warn("not a pattern type (%d %d R)", fz_to_num(patterndict), fz_to_gen(patterndict)); + type = NULL; } - if (fz_toint(type) == 1) + if (fz_to_int(type) == 1) { - paint = fz_dictgets(patterndict, "PaintType"); - if (!fz_isint(paint) || fz_toint(paint) < 1 || fz_toint(paint) > 2) + paint = fz_dict_gets(patterndict, "PaintType"); + if (!fz_is_int(paint) || fz_to_int(paint) < 1 || fz_to_int(paint) > 2) { - fz_warn("not a pattern paint type (%d %d R)", fz_tonum(patterndict), fz_togen(patterndict)); - paint = nil; + fz_warn("not a pattern paint type (%d %d R)", fz_to_num(patterndict), fz_to_gen(patterndict)); + paint = NULL; } - tiling = fz_dictgets(patterndict, "TilingType"); - if (!fz_isint(tiling) || fz_toint(tiling) < 1 || fz_toint(tiling) > 3) + tiling = fz_dict_gets(patterndict, "TilingType"); + if (!fz_is_int(tiling) || fz_to_int(tiling) < 1 || fz_to_int(tiling) > 3) { - fz_warn("not a pattern tiling type (%d %d R)", fz_tonum(patterndict), fz_togen(patterndict)); - tiling = nil; + fz_warn("not a pattern tiling type (%d %d R)", fz_to_num(patterndict), fz_to_gen(patterndict)); + tiling = NULL; } } else { - shading = fz_dictgets(patterndict, "Shading"); + shading = fz_dict_gets(patterndict, "Shading"); } for (k = 0; k < patterns; k++) @@ -569,56 +569,56 @@ gatherresourceinfo(int page, fz_obj *rsrc) fz_obj *subrsrc; int i; - pageobj = pdf_getpageobject(xref, page); - pageref = pdf_getpageref(xref, page); + pageobj = pdf_get_page_object(xref, page); + pageref = pdf_get_page_ref(xref, page); if (!pageobj) die(fz_throw("cannot retrieve info from page %d", page)); - font = fz_dictgets(rsrc, "Font"); + font = fz_dict_gets(rsrc, "Font"); if (font) { gatherfonts(page, pageref, pageobj, font); - for (i = 0; i < fz_dictlen(font); i++) + for (i = 0; i < fz_dict_len(font); i++) { - fz_obj *obj = fz_dictgetval(font, i); + fz_obj *obj = fz_dict_get_val(font, i); - subrsrc = fz_dictgets(obj, "Resources"); + subrsrc = fz_dict_gets(obj, "Resources"); if (subrsrc && fz_objcmp(rsrc, subrsrc)) gatherresourceinfo(page, subrsrc); } } - xobj = fz_dictgets(rsrc, "XObject"); + xobj = fz_dict_gets(rsrc, "XObject"); if (xobj) { gatherimages(page, pageref, pageobj, xobj); gatherforms(page, pageref, pageobj, xobj); gatherpsobjs(page, pageref, pageobj, xobj); - for (i = 0; i < fz_dictlen(xobj); i++) + for (i = 0; i < fz_dict_len(xobj); i++) { - fz_obj *obj = fz_dictgetval(xobj, i); - subrsrc = fz_dictgets(obj, "Resources"); + fz_obj *obj = fz_dict_get_val(xobj, i); + subrsrc = fz_dict_gets(obj, "Resources"); if (subrsrc && fz_objcmp(rsrc, subrsrc)) gatherresourceinfo(page, subrsrc); } } - shade = fz_dictgets(rsrc, "Shading"); + shade = fz_dict_gets(rsrc, "Shading"); if (shade) gathershadings(page, pageref, pageobj, shade); - pattern = fz_dictgets(rsrc, "Pattern"); + pattern = fz_dict_gets(rsrc, "Pattern"); if (pattern) { gatherpatterns(page, pageref, pageobj, pattern); - for (i = 0; i < fz_dictlen(pattern); i++) + for (i = 0; i < fz_dict_len(pattern); i++) { - fz_obj *obj = fz_dictgetval(pattern, i); - subrsrc = fz_dictgets(obj, "Resources"); + fz_obj *obj = fz_dict_get_val(pattern, i); + subrsrc = fz_dict_gets(obj, "Resources"); if (subrsrc && fz_objcmp(rsrc, subrsrc)) gatherresourceinfo(page, subrsrc); } @@ -632,15 +632,15 @@ gatherpageinfo(int page) fz_obj *pageref; fz_obj *rsrc; - pageobj = pdf_getpageobject(xref, page); - pageref = pdf_getpageref(xref, page); + pageobj = pdf_get_page_object(xref, page); + pageref = pdf_get_page_ref(xref, page); if (!pageobj) die(fz_throw("cannot retrieve info from page %d", page)); gatherdimensions(page, pageref, pageobj); - rsrc = fz_dictgets(pageobj, "Resources"); + rsrc = fz_dict_gets(pageobj, "Resources"); gatherresourceinfo(page, rsrc); } @@ -659,7 +659,7 @@ printinfo(char *filename, int show, int page) { printf(PAGE_FMT "[ %g %g %g %g ]\n", dim[i].page, - fz_tonum(dim[i].pageref), fz_togen(dim[i].pageref), + fz_to_num(dim[i].pageref), fz_to_gen(dim[i].pageref), dim[i].u.dim.bbox->x0, dim[i].u.dim.bbox->y0, dim[i].u.dim.bbox->x1, @@ -675,10 +675,10 @@ printinfo(char *filename, int show, int page) { printf(PAGE_FMT "%s '%s' (%d %d R)\n", font[i].page, - fz_tonum(font[i].pageref), fz_togen(font[i].pageref), - fz_toname(font[i].u.font.subtype), - fz_toname(font[i].u.font.name), - fz_tonum(font[i].u.font.obj), fz_togen(font[i].u.font.obj)); + fz_to_num(font[i].pageref), fz_to_gen(font[i].pageref), + fz_to_name(font[i].u.font.subtype), + fz_to_name(font[i].u.font.name), + fz_to_num(font[i].u.font.obj), fz_to_gen(font[i].u.font.obj)); } printf("\n"); } @@ -688,31 +688,31 @@ printinfo(char *filename, int show, int page) printf("Images (%d):\n", images); for (i = 0; i < images; i++) { - char *cs = nil; - char *altcs = nil; + char *cs = NULL; + char *altcs = NULL; printf(PAGE_FMT "[ ", image[i].page, - fz_tonum(image[i].pageref), fz_togen(image[i].pageref)); + fz_to_num(image[i].pageref), fz_to_gen(image[i].pageref)); - if (fz_isarray(image[i].u.image.filter)) - for (j = 0; j < fz_arraylen(image[i].u.image.filter); j++) + if (fz_is_array(image[i].u.image.filter)) + for (j = 0; j < fz_array_len(image[i].u.image.filter); j++) { - fz_obj *obj = fz_arrayget(image[i].u.image.filter, j); - char *filter = fz_strdup(fz_toname(obj)); + fz_obj *obj = fz_array_get(image[i].u.image.filter, j); + char *filter = fz_strdup(fz_to_name(obj)); if (strstr(filter, "Decode")) *(strstr(filter, "Decode")) = '\0'; printf("%s%s", filter, - j == fz_arraylen(image[i].u.image.filter) - 1 ? "" : " "); + j == fz_array_len(image[i].u.image.filter) - 1 ? "" : " "); fz_free(filter); } else if (image[i].u.image.filter) { fz_obj *obj = image[i].u.image.filter; - char *filter = fz_strdup(fz_toname(obj)); + char *filter = fz_strdup(fz_to_name(obj)); if (strstr(filter, "Decode")) *(strstr(filter, "Decode")) = '\0'; @@ -725,7 +725,7 @@ printinfo(char *filename, int show, int page) if (image[i].u.image.cs) { - cs = fz_strdup(fz_toname(image[i].u.image.cs)); + cs = fz_strdup(fz_to_name(image[i].u.image.cs)); if (!strncmp(cs, "Device", 6)) { @@ -744,7 +744,7 @@ printinfo(char *filename, int show, int page) } if (image[i].u.image.altcs) { - altcs = fz_strdup(fz_toname(image[i].u.image.altcs)); + altcs = fz_strdup(fz_to_name(image[i].u.image.altcs)); if (!strncmp(altcs, "Device", 6)) { @@ -763,13 +763,13 @@ printinfo(char *filename, int show, int page) } printf(" ] %dx%d %dbpc %s%s%s (%d %d R)\n", - fz_toint(image[i].u.image.width), - fz_toint(image[i].u.image.height), - image[i].u.image.bpc ? fz_toint(image[i].u.image.bpc) : 1, + fz_to_int(image[i].u.image.width), + fz_to_int(image[i].u.image.height), + image[i].u.image.bpc ? fz_to_int(image[i].u.image.bpc) : 1, image[i].u.image.cs ? cs : "ImageMask", image[i].u.image.altcs ? " " : "", image[i].u.image.altcs ? altcs : "", - fz_tonum(image[i].u.image.obj), fz_togen(image[i].u.image.obj)); + fz_to_num(image[i].u.image.obj), fz_to_gen(image[i].u.image.obj)); fz_free(cs); fz_free(altcs); @@ -796,9 +796,9 @@ printinfo(char *filename, int show, int page) printf(PAGE_FMT "%s (%d %d R)\n", shading[i].page, - fz_tonum(shading[i].pageref), fz_togen(shading[i].pageref), - shadingtype[fz_toint(shading[i].u.shading.type)], - fz_tonum(shading[i].u.shading.obj), fz_togen(shading[i].u.shading.obj)); + fz_to_num(shading[i].pageref), fz_to_gen(shading[i].pageref), + shadingtype[fz_to_int(shading[i].u.shading.type)], + fz_to_num(shading[i].u.shading.obj), fz_to_gen(shading[i].u.shading.obj)); } printf("\n"); } @@ -808,7 +808,7 @@ printinfo(char *filename, int show, int page) printf("Patterns (%d):\n", patterns); for (i = 0; i < patterns; i++) { - if (fz_toint(pattern[i].u.pattern.type) == 1) + if (fz_to_int(pattern[i].u.pattern.type) == 1) { char *painttype[] = { @@ -826,18 +826,18 @@ printinfo(char *filename, int show, int page) printf(PAGE_FMT "Tiling %s %s (%d %d R)\n", pattern[i].page, - fz_tonum(pattern[i].pageref), fz_togen(pattern[i].pageref), - painttype[fz_toint(pattern[i].u.pattern.paint)], - tilingtype[fz_toint(pattern[i].u.pattern.tiling)], - fz_tonum(pattern[i].u.pattern.obj), fz_togen(pattern[i].u.pattern.obj)); + fz_to_num(pattern[i].pageref), fz_to_gen(pattern[i].pageref), + painttype[fz_to_int(pattern[i].u.pattern.paint)], + tilingtype[fz_to_int(pattern[i].u.pattern.tiling)], + fz_to_num(pattern[i].u.pattern.obj), fz_to_gen(pattern[i].u.pattern.obj)); } else { printf(PAGE_FMT "Shading %d %d R (%d %d R)\n", pattern[i].page, - fz_tonum(pattern[i].pageref), fz_togen(pattern[i].pageref), - fz_tonum(pattern[i].u.pattern.shading), fz_togen(pattern[i].u.pattern.shading), - fz_tonum(pattern[i].u.pattern.obj), fz_togen(pattern[i].u.pattern.obj)); + fz_to_num(pattern[i].pageref), fz_to_gen(pattern[i].pageref), + fz_to_num(pattern[i].u.pattern.shading), fz_to_gen(pattern[i].u.pattern.shading), + fz_to_num(pattern[i].u.pattern.obj), fz_to_gen(pattern[i].u.pattern.obj)); } } printf("\n"); @@ -850,12 +850,12 @@ printinfo(char *filename, int show, int page) { printf(PAGE_FMT "Form%s%s%s%s (%d %d R)\n", form[i].page, - fz_tonum(form[i].pageref), fz_togen(form[i].pageref), + fz_to_num(form[i].pageref), fz_to_gen(form[i].pageref), form[i].u.form.groupsubtype ? " " : "", - form[i].u.form.groupsubtype ? fz_toname(form[i].u.form.groupsubtype) : "", + form[i].u.form.groupsubtype ? fz_to_name(form[i].u.form.groupsubtype) : "", form[i].u.form.groupsubtype ? " Group" : "", form[i].u.form.reference ? " Reference" : "", - fz_tonum(form[i].u.form.obj), fz_togen(form[i].u.form.obj)); + fz_to_num(form[i].u.form.obj), fz_to_gen(form[i].u.form.obj)); } printf("\n"); } @@ -867,8 +867,8 @@ printinfo(char *filename, int show, int page) { printf(PAGE_FMT "(%d %d R)\n", psobj[i].page, - fz_tonum(psobj[i].pageref), fz_togen(psobj[i].pageref), - fz_tonum(psobj[i].u.form.obj), fz_togen(psobj[i].u.form.obj)); + fz_to_num(psobj[i].pageref), fz_to_gen(psobj[i].pageref), + fz_to_num(psobj[i].u.form.obj), fz_to_gen(psobj[i].u.form.obj)); } printf("\n"); } @@ -981,14 +981,14 @@ int main(int argc, char **argv) filename = argv[fz_optind]; printf("%s:\n", filename); - error = pdf_openxref(&xref, filename, password); + error = pdf_open_xref(&xref, filename, password); if (error) die(fz_rethrow(error, "cannot open input file '%s'", filename)); - error = pdf_loadpagetree(xref); + error = pdf_load_page_tree(xref); if (error) die(fz_rethrow(error, "cannot load page tree: %s", filename)); - pagecount = pdf_getpagecount(xref); + pagecount = pdf_get_page_count(xref); showglobalinfo(); state = NO_INFO_GATHERED; diff --git a/apps/pdfshow.c b/apps/pdfshow.c index 4eda9b81..4c834035 100644 --- a/apps/pdfshow.c +++ b/apps/pdfshow.c @@ -5,7 +5,7 @@ #include "fitz.h" #include "mupdf.h" -static pdf_xref *xref = nil; +static pdf_xref *xref = NULL; static int showbinary = 0; static int showdecode = 1; static int showcolumn; @@ -14,7 +14,7 @@ void die(fz_error error) { fz_catch(error, "aborting"); if (xref) - pdf_freexref(xref); + pdf_free_xref(xref); exit(1); } @@ -32,7 +32,7 @@ static void showtrailer(void) if (!xref) die(fz_throw("no file specified")); printf("trailer\n"); - fz_debugobj(xref->trailer); + fz_debug_obj(xref->trailer); printf("\n"); } @@ -40,7 +40,7 @@ static void showxref(void) { if (!xref) die(fz_throw("no file specified")); - pdf_debugxref(xref); + pdf_debug_xref(xref); printf("\n"); } @@ -54,18 +54,18 @@ static void showpagetree(void) if (!xref) die(fz_throw("no file specified")); - if (!xref->pagelen) + if (!xref->page_len) { - error = pdf_loadpagetree(xref); + error = pdf_load_page_tree(xref); if (error) die(fz_rethrow(error, "cannot load page tree")); } - count = pdf_getpagecount(xref); + count = pdf_get_page_count(xref); for (i = 0; i < count; i++) { - ref = pdf_getpageref(xref, i + 1); - printf("page %d = %d %d R\n", i + 1, fz_tonum(ref), fz_togen(ref)); + ref = pdf_get_page_ref(xref, i + 1); + printf("page %d = %d %d R\n", i + 1, fz_to_num(ref), fz_to_gen(ref)); } printf("\n"); } @@ -103,9 +103,9 @@ static void showstream(int num, int gen) showcolumn = 0; if (showdecode) - error = pdf_openstream(&stm, xref, num, gen); + error = pdf_open_stream(&stm, xref, num, gen); else - error = pdf_openrawstream(&stm, xref, num, gen); + error = pdf_open_raw_stream(&stm, xref, num, gen); if (error) die(error); @@ -133,11 +133,11 @@ static void showobject(int num, int gen) if (!xref) die(fz_throw("no file specified")); - error = pdf_loadobject(&obj, xref, num, gen); + error = pdf_load_object(&obj, xref, num, gen); if (error) die(error); - if (pdf_isstream(xref, num, gen)) + if (pdf_is_stream(xref, num, gen)) { if (showbinary) { @@ -146,7 +146,7 @@ static void showobject(int num, int gen) else { printf("%d %d obj\n", num, gen); - fz_debugobj(obj); + fz_debug_obj(obj); printf("stream\n"); showstream(num, gen); printf("endstream\n"); @@ -156,11 +156,11 @@ static void showobject(int num, int gen) else { printf("%d %d obj\n", num, gen); - fz_debugobj(obj); + fz_debug_obj(obj); printf("endobj\n\n"); } - fz_dropobj(obj); + fz_drop_obj(obj); } static void showgrep(char *filename) @@ -173,26 +173,26 @@ static void showgrep(char *filename) { if (xref->table[i].type == 'n' || xref->table[i].type == 'o') { - error = pdf_loadobject(&obj, xref, i, 0); + error = pdf_load_object(&obj, xref, i, 0); if (error) die(error); - fz_sortdict(obj); + fz_sort_dict(obj); printf("%s:%d: ", filename, i); - fz_fprintobj(stdout, obj, 1); + fz_fprint_obj(stdout, obj, 1); - fz_dropobj(obj); + fz_drop_obj(obj); } } printf("%s:trailer: ", filename); - fz_fprintobj(stdout, xref->trailer, 1); + fz_fprint_obj(stdout, xref->trailer, 1); } int main(int argc, char **argv) { - char *password = nil; /* don't throw errors if encrypted */ + char *password = NULL; /* don't throw errors if encrypted */ char *filename; fz_error error; int c; @@ -212,7 +212,7 @@ int main(int argc, char **argv) usage(); filename = argv[fz_optind++]; - error = pdf_openxref(&xref, filename, password); + error = pdf_open_xref(&xref, filename, password); if (error) die(fz_rethrow(error, "cannot open document: %s", filename)); @@ -232,9 +232,9 @@ int main(int argc, char **argv) fz_optind++; } - pdf_freexref(xref); + pdf_free_xref(xref); - fz_flushwarnings(); + fz_flush_warnings(); return 0; } diff --git a/apps/win_main.c b/apps/win_main.c index ae62b62b..5e513c89 100644 --- a/apps/win_main.c +++ b/apps/win_main.c @@ -56,9 +56,9 @@ void winerror(pdfapp_t *app, fz_error error) fz_catch(error, "displaying error message to user"); fz_strlcpy(msgbuf, "An error has occurred.\n\n", sizeof msgbuf); - for (i = 0; i < fz_geterrorcount(); i++) + for (i = 0; i < fz_get_error_count(); i++) { - fz_strlcat(msgbuf, fz_geterrorline(i), sizeof msgbuf); + fz_strlcat(msgbuf, fz_get_error_line(i), sizeof msgbuf); fz_strlcat(msgbuf, "\n", sizeof msgbuf); } @@ -142,7 +142,7 @@ char *winpassword(pdfapp_t *app, char *filename) win32error("cannot create password dialog"); if (pd_okay) return pd_password; - return nil; + return NULL; } INT CALLBACK @@ -195,33 +195,33 @@ dloginfoproc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) SetDlgItemTextA(hwnd, 0x13, "n/a"); } - info = fz_dictgets(xref->trailer, "Info"); + info = fz_dict_gets(xref->trailer, "Info"); if (!info) return TRUE; #define SETUCS(ID) \ { \ unsigned short *ucs; \ - ucs = pdf_toucs2(obj); \ + ucs = pdf_to_ucs2(obj); \ SetDlgItemTextW(hwnd, ID, ucs); \ fz_free(ucs); \ } - if ((obj = fz_dictgets(info, "Title"))) + if ((obj = fz_dict_gets(info, "Title"))) SETUCS(0x20); - if ((obj = fz_dictgets(info, "Author"))) + if ((obj = fz_dict_gets(info, "Author"))) SETUCS(0x21); - if ((obj = fz_dictgets(info, "Subject"))) + if ((obj = fz_dict_gets(info, "Subject"))) SETUCS(0x22); - if ((obj = fz_dictgets(info, "Keywords"))) + if ((obj = fz_dict_gets(info, "Keywords"))) SETUCS(0x23); - if ((obj = fz_dictgets(info, "Creator"))) + if ((obj = fz_dict_gets(info, "Creator"))) SETUCS(0x24); - if ((obj = fz_dictgets(info, "Producer"))) + if ((obj = fz_dict_gets(info, "Producer"))) SETUCS(0x25); - if ((obj = fz_dictgets(info, "CreationDate"))) + if ((obj = fz_dict_gets(info, "CreationDate"))) SETUCS(0x26); - if ((obj = fz_dictgets(info, "ModDate"))) + if ((obj = fz_dict_gets(info, "ModDate"))) SETUCS(0x27); return TRUE; diff --git a/apps/x11_image.c b/apps/x11_image.c index 8a331c79..9383c545 100644 --- a/apps/x11_image.c +++ b/apps/x11_image.c @@ -104,7 +104,7 @@ createximage(Display *dpy, Visual *vis, XShmSegmentInfo *xsi, int depth, int w, if (!info.useshm) goto fallback; - img = XShmCreateImage(dpy, vis, depth, ZPixmap, nil, xsi, w, h); + img = XShmCreateImage(dpy, vis, depth, ZPixmap, NULL, xsi, w, h); if (!img) { fprintf(stderr, "warn: could not XShmCreateImage\n"); @@ -121,7 +121,7 @@ createximage(Display *dpy, Visual *vis, XShmSegmentInfo *xsi, int depth, int w, goto fallback; } - img->data = xsi->shmaddr = shmat(xsi->shmid, nil, 0); + img->data = xsi->shmaddr = shmat(xsi->shmid, NULL, 0); if (img->data == (char*)-1) { XDestroyImage(img); @@ -141,14 +141,14 @@ createximage(Display *dpy, Visual *vis, XShmSegmentInfo *xsi, int depth, int w, XSync(dpy, False); - shmctl(xsi->shmid, IPC_RMID, nil); + shmctl(xsi->shmid, IPC_RMID, NULL); return img; fallback: info.useshm = 0; - img = XCreateImage(dpy, vis, depth, ZPixmap, 0, nil, w, h, 32, 0); + img = XCreateImage(dpy, vis, depth, ZPixmap, 0, NULL, w, h, 32, 0); if (!img) { fprintf(stderr, "fail: could not XCreateImage"); @@ -212,7 +212,7 @@ select_mode(void) unsigned long rs, gs, bs; byteorder = ImageByteOrder(info.display); - if (fz_isbigendian()) + if (fz_is_big_endian()) byterev = byteorder != MSBFirst; else byterev = byteorder != LSBFirst; @@ -278,14 +278,14 @@ create_pool(void) info.lastused = 0; for (i = 0; i < POOLSIZE; i++) { - info.pool[i] = nil; + info.pool[i] = NULL; } for (i = 0; i < POOLSIZE; i++) { info.pool[i] = createximage(info.display, info.visual.visual, &info.shminfo[i], info.visual.depth, WIDTH, HEIGHT); - if (info.pool[i] == nil) { + if (info.pool[i] == NULL) { return 0; } } diff --git a/apps/x11_main.c b/apps/x11_main.c index 1e08368e..99343988 100644 --- a/apps/x11_main.c +++ b/apps/x11_main.c @@ -107,7 +107,7 @@ void winerror(pdfapp_t *app, fz_error error) char *winpassword(pdfapp_t *app, char *filename) { char *r = password; - password = nil; + password = NULL; return r; } @@ -120,7 +120,7 @@ static void winopen(void) XWMHints *wmhints; XClassHint *classhint; - xdpy = XOpenDisplay(nil); + xdpy = XOpenDisplay(NULL); if (!xdpy) winerror(&gapp, fz_throw("cannot open display")); @@ -154,7 +154,7 @@ static void winopen(void) InputOutput, ximage_get_visual(), 0, - nil); + NULL); if (xwin == None) winerror(&gapp, fz_throw("cannot create window")); @@ -165,7 +165,7 @@ static void winopen(void) mapped = 0; - xgc = XCreateGC(xdpy, xwin, 0, nil); + xgc = XCreateGC(xdpy, xwin, 0, NULL); XDefineCursor(xdpy, xwin, xcarrow); @@ -224,9 +224,9 @@ void wintitle(pdfapp_t *app, char *s) { XStoreName(xdpy, xwin, s); #ifdef X_HAVE_UTF8_STRING - Xutf8SetWMProperties(xdpy, xwin, s, s, nil, 0, nil, nil, nil); + Xutf8SetWMProperties(xdpy, xwin, s, s, NULL, 0, NULL, NULL, NULL); #else - XmbSetWMProperties(xdpy, xwin, s, s, nil, 0, nil, nil, nil); + XmbSetWMProperties(xdpy, xwin, s, s, NULL, 0, NULL, NULL, NULL); #endif } @@ -314,7 +314,7 @@ static void winblit(pdfapp_t *app) { int i = gapp.image->w*gapp.image->h; unsigned char *color = malloc(i*4); - if (color != nil) + if (color != NULL) { unsigned char *s = gapp.image->samples; unsigned char *d = color; @@ -533,9 +533,9 @@ static void winawaitevent(struct timeval *tmo, struct timeval *tmo_at) FD_ZERO(&fds); FD_SET(x11fd, &fds); - if (select(x11fd + 1, &fds, nil, nil, tmo)) + if (select(x11fd + 1, &fds, NULL, NULL, tmo)) { - gettimeofday(&now, nil); + gettimeofday(&now, NULL); timersub(tmo_at, &now, tmo); XNextEvent(xdpy, &xevt); } @@ -549,7 +549,7 @@ static void winsettmo(struct timeval *tmo, struct timeval *tmo_at) tmo->tv_sec = 2; tmo->tv_usec = 0; - gettimeofday(&now, nil); + gettimeofday(&now, NULL); timeradd(&now, tmo, tmo_at); } @@ -658,7 +658,7 @@ int main(int argc, char **argv) case KeyPress: wasshowingpage = isshowingpage; - len = XLookupString(&xevt.xkey, buf, sizeof buf, &keysym, nil); + len = XLookupString(&xevt.xkey, buf, sizeof buf, &keysym, NULL); switch (keysym) { diff --git a/apps/xpsdraw.c b/apps/xpsdraw.c index 2e30de9a..41d01c14 100644 --- a/apps/xpsdraw.c +++ b/apps/xpsdraw.c @@ -18,7 +18,7 @@ int savealpha = 0; int uselist = 1; fz_colorspace *colorspace; -fz_glyphcache *glyphcache; +fz_glyph_cache *glyphcache; char *filename; struct { @@ -81,13 +81,13 @@ xps_run_page(xps_context *ctx, xps_page *page, fz_device *dev, fz_matrix ctm) { ctx->dev = dev; xps_parse_fixed_page(ctx, ctm, page); - ctx->dev = nil; + ctx->dev = NULL; } static void drawpage(xps_context *ctx, int pagenum) { xps_page *page; - fz_displaylist *list; + fz_display_list *list; fz_device *dev; int start; @@ -100,44 +100,44 @@ static void drawpage(xps_context *ctx, int pagenum) if (!page) die(fz_throw("cannot load page %d in file '%s'", pagenum, filename)); - list = nil; + list = NULL; if (uselist) { - list = fz_newdisplaylist(); - dev = fz_newlistdevice(list); + list = fz_new_display_list(); + dev = fz_new_list_device(list); xps_run_page(ctx, page, dev, fz_identity); - fz_freedevice(dev); + fz_free_device(dev); } if (showxml) { - dev = fz_newtracedevice(); + dev = fz_new_trace_device(); printf("\n", pagenum); if (list) - fz_executedisplaylist(list, dev, fz_identity, fz_infinitebbox); + fz_execute_display_list(list, dev, fz_identity, fz_infinite_bbox); else xps_run_page(ctx, page, dev, fz_identity); printf("\n"); - fz_freedevice(dev); + fz_free_device(dev); } if (showtext) { - fz_textspan *text = fz_newtextspan(); - dev = fz_newtextdevice(text); + fz_text_span *text = fz_new_text_span(); + dev = fz_new_text_device(text); if (list) - fz_executedisplaylist(list, dev, fz_identity, fz_infinitebbox); + fz_execute_display_list(list, dev, fz_identity, fz_infinite_bbox); else xps_run_page(ctx, page, dev, fz_identity); - fz_freedevice(dev); + fz_free_device(dev); printf("[Page %d]\n", pagenum); if (showtext > 1) - fz_debugtextspanxml(text); + fz_debug_text_span_xml(text); else - fz_debugtextspan(text); + fz_debug_text_span(text); printf("\n"); - fz_freetextspan(text); + fz_free_text_span(text); } if (showmd5 || showtime) @@ -158,34 +158,34 @@ static void drawpage(xps_context *ctx, int pagenum) zoom = resolution / 96; ctm = fz_translate(0, -page->height); ctm = fz_concat(ctm, fz_scale(zoom, zoom)); - bbox = fz_roundrect(fz_transformrect(ctm, rect)); + bbox = fz_round_rect(fz_transform_rect(ctm, rect)); /* TODO: banded rendering and multi-page ppm */ - pix = fz_newpixmapwithrect(colorspace, bbox); + pix = fz_new_pixmap_with_rect(colorspace, bbox); if (savealpha) - fz_clearpixmap(pix); + fz_clear_pixmap(pix); else - fz_clearpixmapwithcolor(pix, 255); + fz_clear_pixmap_with_color(pix, 255); - dev = fz_newdrawdevice(glyphcache, pix); + dev = fz_new_draw_device(glyphcache, pix); if (list) - fz_executedisplaylist(list, dev, ctm, bbox); + fz_execute_display_list(list, dev, ctm, bbox); else xps_run_page(ctx, page, dev, ctm); - fz_freedevice(dev); + fz_free_device(dev); if (output) { char buf[512]; sprintf(buf, output, pagenum); if (strstr(output, ".pgm") || strstr(output, ".ppm") || strstr(output, ".pnm")) - fz_writepnm(pix, buf); + fz_write_pnm(pix, buf); else if (strstr(output, ".pam")) - fz_writepam(pix, buf, savealpha); + fz_write_pam(pix, buf, savealpha); else if (strstr(output, ".png")) - fz_writepng(pix, buf, savealpha); + fz_write_png(pix, buf, savealpha); } if (showmd5) @@ -194,20 +194,20 @@ static void drawpage(xps_context *ctx, int pagenum) unsigned char digest[16]; int i; - fz_md5init(&md5); - fz_md5update(&md5, pix->samples, pix->w * pix->h * pix->n); - fz_md5final(&md5, digest); + fz_md5_init(&md5); + fz_md5_update(&md5, pix->samples, pix->w * pix->h * pix->n); + fz_md5_final(&md5, digest); printf(" "); for (i = 0; i < 16; i++) printf("%02x", digest[i]); } - fz_droppixmap(pix); + fz_drop_pixmap(pix); } if (list) - fz_freedisplaylist(list); + fz_free_display_list(list); if (showtime) { @@ -234,7 +234,6 @@ static void drawpage(xps_context *ctx, int pagenum) printf("\n"); } - static void drawrange(xps_context *ctx, char *range) { int page, spage, epage; @@ -310,15 +309,15 @@ int main(int argc, char **argv) if (accelerate) fz_accelerate(); - glyphcache = fz_newglyphcache(); + glyphcache = fz_new_glyph_cache(); - colorspace = fz_devicergb; + colorspace = fz_device_rgb; if (grayscale) - colorspace = fz_devicegray; + colorspace = fz_device_gray; if (output && strstr(output, ".pgm")) - colorspace = fz_devicegray; + colorspace = fz_device_gray; if (output && strstr(output, ".ppm")) - colorspace = fz_devicergb; + colorspace = fz_device_rgb; timing.count = 0; timing.total = 0; @@ -361,7 +360,7 @@ int main(int argc, char **argv) printf("slowest page %d: %dms\n", timing.maxpage, timing.max); } - fz_freeglyphcache(glyphcache); + fz_free_glyph_cache(glyphcache); return 0; } diff --git a/draw/arch_arm.c b/draw/arch_arm.c index c601a70c..55016a8b 100644 --- a/draw/arch_arm.c +++ b/draw/arch_arm.c @@ -104,7 +104,7 @@ path_w4i1o4_arm(byte * restrict rgba, byte * restrict src, byte cov, int len, by ); } -static void loadtile8_arm(byte * restrict src, int sw, byte * restrict dst, int dw, int w, int h, int pad) +static void load_tile8_arm(byte * restrict src, int sw, byte * restrict dst, int dw, int w, int h, int pad) { if ((h == 0) || (w == 0)) return; @@ -221,10 +221,10 @@ static void loadtile8_arm(byte * restrict src, int sw, byte * restrict dst, int } void -fz_acceleratearch(void) +fz_accelerate_arch(void) { fz_path_w4i1o4 = path_w4i1o4_arm; - fz_loadtile8 = loadtile8_arm; + fz_loadtile8 = load_tile8_arm; fz_srow4 = fz_srow4_arm; fz_scol4 = fz_scol4_arm; } diff --git a/draw/arch_port.c b/draw/arch_port.c index c7be977a..fa5890b5 100644 --- a/draw/arch_port.c +++ b/draw/arch_port.c @@ -471,7 +471,7 @@ img_1o1_32bit(byte * restrict src, byte cov, int len, byte * restrict dst, void fz_accelerate(void) { - if (sizeof(int) == 4 && sizeof(unsigned int) == 4 && !fz_isbigendian()) + if (sizeof(int) == 4 && sizeof(unsigned int) == 4 && !fz_is_big_endian()) { // fz_path_w4i1o4 = path_w4i1o4_32bit; // fz_text_w4i1o4 = text_w4i1o4_32bit; @@ -481,6 +481,6 @@ void fz_accelerate(void) } #ifdef HAVE_CPUDEP - fz_acceleratearch(); + fz_accelerate_arch(); #endif } diff --git a/draw/draw_affine.c b/draw/draw_affine.c index 044b2938..dce2189d 100644 --- a/draw/draw_affine.c +++ b/draw/draw_affine.c @@ -17,7 +17,7 @@ static inline int bilerp(int a, int b, int c, int d, int u, int v) return lerp(lerp(a, b, u), lerp(c, d, u), v); } -static inline byte *samplenearest(byte *s, int w, int h, int n, int u, int v) +static inline byte *sample_nearest(byte *s, int w, int h, int n, int u, int v) { if (u < 0) u = 0; if (v < 0) v = 0; @@ -29,7 +29,7 @@ static inline byte *samplenearest(byte *s, int w, int h, int n, int u, int v) /* Blend premultiplied source image in constant alpha over destination */ static inline void -fz_paintaffinealphaNlerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, int alpha) +fz_paint_affine_alpha_N_lerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, int alpha) { int k; @@ -41,10 +41,10 @@ fz_paintaffinealphaNlerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int f { int uf = u & 0xffff; int vf = v & 0xffff; - byte *a = samplenearest(sp, sw, sh, n, ui, vi); - byte *b = samplenearest(sp, sw, sh, n, ui+1, vi); - byte *c = samplenearest(sp, sw, sh, n, ui, vi+1); - byte *d = samplenearest(sp, sw, sh, n, ui+1, vi+1); + byte *a = sample_nearest(sp, sw, sh, n, ui, vi); + byte *b = sample_nearest(sp, sw, sh, n, ui+1, vi); + byte *c = sample_nearest(sp, sw, sh, n, ui, vi+1); + byte *d = sample_nearest(sp, sw, sh, n, ui+1, vi+1); int x = bilerp(a[n-1], b[n-1], c[n-1], d[n-1], uf, vf); int t = 255 - fz_mul255(x, alpha); for (k = 0; k < n; k++) @@ -60,7 +60,7 @@ fz_paintaffinealphaNlerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int f } static inline void -fz_paintaffinealphaNnear(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, int alpha) +fz_paint_affine_alpha_N_near(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, int alpha) { int k; @@ -84,7 +84,7 @@ fz_paintaffinealphaNnear(byte *dp, byte *sp, int sw, int sh, int u, int v, int f /* Blend premultiplied source image over destination */ static inline void -fz_paintaffineNlerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n) +fz_paint_affine_N_lerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n) { int k; @@ -96,10 +96,10 @@ fz_paintaffineNlerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, in { int uf = u & 0xffff; int vf = v & 0xffff; - byte *a = samplenearest(sp, sw, sh, n, ui, vi); - byte *b = samplenearest(sp, sw, sh, n, ui+1, vi); - byte *c = samplenearest(sp, sw, sh, n, ui, vi+1); - byte *d = samplenearest(sp, sw, sh, n, ui+1, vi+1); + byte *a = sample_nearest(sp, sw, sh, n, ui, vi); + byte *b = sample_nearest(sp, sw, sh, n, ui+1, vi); + byte *c = sample_nearest(sp, sw, sh, n, ui, vi+1); + byte *d = sample_nearest(sp, sw, sh, n, ui+1, vi+1); int t = 255 - bilerp(a[n-1], b[n-1], c[n-1], d[n-1], uf, vf); for (k = 0; k < n; k++) { @@ -114,7 +114,7 @@ fz_paintaffineNlerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, in } static inline void -fz_paintaffineNnear(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n) +fz_paint_affine_N_near(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n) { int k; @@ -138,7 +138,7 @@ fz_paintaffineNnear(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, in /* Blend non-premultiplied color in source image mask over destination */ static inline void -fz_paintaffinecolorNlerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, byte *color) +fz_paint_affine_color_N_lerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, byte *color) { int sa = color[n-1]; int k; @@ -151,10 +151,10 @@ fz_paintaffinecolorNlerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int f { int uf = u & 0xffff; int vf = v & 0xffff; - byte *a = samplenearest(sp, sw, sh, 1, ui, vi); - byte *b = samplenearest(sp, sw, sh, 1, ui+1, vi); - byte *c = samplenearest(sp, sw, sh, 1, ui, vi+1); - byte *d = samplenearest(sp, sw, sh, 1, ui+1, vi+1); + byte *a = sample_nearest(sp, sw, sh, 1, ui, vi); + byte *b = sample_nearest(sp, sw, sh, 1, ui+1, vi); + byte *c = sample_nearest(sp, sw, sh, 1, ui, vi+1); + byte *d = sample_nearest(sp, sw, sh, 1, ui+1, vi+1); int ma = bilerp(a[0], b[0], c[0], d[0], uf, vf); int masa = FZ_COMBINE(FZ_EXPAND(ma), sa); for (k = 0; k < n - 1; k++) @@ -168,7 +168,7 @@ fz_paintaffinecolorNlerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int f } static inline void -fz_paintaffinecolorNnear(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, byte *color) +fz_paint_affine_color_N_near(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, byte *color) { int sa = color[n-1]; int k; @@ -192,81 +192,81 @@ fz_paintaffinecolorNnear(byte *dp, byte *sp, int sw, int sh, int u, int v, int f } static void -fz_paintaffinelerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, int alpha) +fz_paint_affine_lerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, int alpha) { if (alpha == 255) { switch (n) { - case 1: fz_paintaffineNlerp(dp, sp, sw, sh, u, v, fa, fb, w, 1); break; - case 2: fz_paintaffineNlerp(dp, sp, sw, sh, u, v, fa, fb, w, 2); break; - case 4: fz_paintaffineNlerp(dp, sp, sw, sh, u, v, fa, fb, w, 4); break; - default: fz_paintaffineNlerp(dp, sp, sw, sh, u, v, fa, fb, w, n); break; + case 1: fz_paint_affine_N_lerp(dp, sp, sw, sh, u, v, fa, fb, w, 1); break; + case 2: fz_paint_affine_N_lerp(dp, sp, sw, sh, u, v, fa, fb, w, 2); break; + case 4: fz_paint_affine_N_lerp(dp, sp, sw, sh, u, v, fa, fb, w, 4); break; + default: fz_paint_affine_N_lerp(dp, sp, sw, sh, u, v, fa, fb, w, n); break; } } else if (alpha > 0) { switch (n) { - case 1: fz_paintaffinealphaNlerp(dp, sp, sw, sh, u, v, fa, fb, w, 1, alpha); break; - case 2: fz_paintaffinealphaNlerp(dp, sp, sw, sh, u, v, fa, fb, w, 2, alpha); break; - case 4: fz_paintaffinealphaNlerp(dp, sp, sw, sh, u, v, fa, fb, w, 4, alpha); break; - default: fz_paintaffinealphaNlerp(dp, sp, sw, sh, u, v, fa, fb, w, n, alpha); break; + case 1: fz_paint_affine_alpha_N_lerp(dp, sp, sw, sh, u, v, fa, fb, w, 1, alpha); break; + case 2: fz_paint_affine_alpha_N_lerp(dp, sp, sw, sh, u, v, fa, fb, w, 2, alpha); break; + case 4: fz_paint_affine_alpha_N_lerp(dp, sp, sw, sh, u, v, fa, fb, w, 4, alpha); break; + default: fz_paint_affine_alpha_N_lerp(dp, sp, sw, sh, u, v, fa, fb, w, n, alpha); break; } } } static void -fz_paintaffinenear(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, int alpha) +fz_paint_affine_near(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, int alpha) { if (alpha == 255) { switch (n) { - case 1: fz_paintaffineNnear(dp, sp, sw, sh, u, v, fa, fb, w, 1); break; - case 2: fz_paintaffineNnear(dp, sp, sw, sh, u, v, fa, fb, w, 2); break; - case 4: fz_paintaffineNnear(dp, sp, sw, sh, u, v, fa, fb, w, 4); break; - default: fz_paintaffineNnear(dp, sp, sw, sh, u, v, fa, fb, w, n); break; + case 1: fz_paint_affine_N_near(dp, sp, sw, sh, u, v, fa, fb, w, 1); break; + case 2: fz_paint_affine_N_near(dp, sp, sw, sh, u, v, fa, fb, w, 2); break; + case 4: fz_paint_affine_N_near(dp, sp, sw, sh, u, v, fa, fb, w, 4); break; + default: fz_paint_affine_N_near(dp, sp, sw, sh, u, v, fa, fb, w, n); break; } } else if (alpha > 0) { switch (n) { - case 1: fz_paintaffinealphaNnear(dp, sp, sw, sh, u, v, fa, fb, w, 1, alpha); break; - case 2: fz_paintaffinealphaNnear(dp, sp, sw, sh, u, v, fa, fb, w, 2, alpha); break; - case 4: fz_paintaffinealphaNnear(dp, sp, sw, sh, u, v, fa, fb, w, 4, alpha); break; - default: fz_paintaffinealphaNnear(dp, sp, sw, sh, u, v, fa, fb, w, n, alpha); break; + case 1: fz_paint_affine_alpha_N_near(dp, sp, sw, sh, u, v, fa, fb, w, 1, alpha); break; + case 2: fz_paint_affine_alpha_N_near(dp, sp, sw, sh, u, v, fa, fb, w, 2, alpha); break; + case 4: fz_paint_affine_alpha_N_near(dp, sp, sw, sh, u, v, fa, fb, w, 4, alpha); break; + default: fz_paint_affine_alpha_N_near(dp, sp, sw, sh, u, v, fa, fb, w, n, alpha); break; } } } static void -fz_paintaffinecolorlerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, byte *color) +fz_paint_affine_color_lerp(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, byte *color) { switch (n) { - case 2: fz_paintaffinecolorNlerp(dp, sp, sw, sh, u, v, fa, fb, w, 2, color); break; - case 4: fz_paintaffinecolorNlerp(dp, sp, sw, sh, u, v, fa, fb, w, 4, color); break; - default: fz_paintaffinecolorNlerp(dp, sp, sw, sh, u, v, fa, fb, w, n, color); break; + case 2: fz_paint_affine_color_N_lerp(dp, sp, sw, sh, u, v, fa, fb, w, 2, color); break; + case 4: fz_paint_affine_color_N_lerp(dp, sp, sw, sh, u, v, fa, fb, w, 4, color); break; + default: fz_paint_affine_color_N_lerp(dp, sp, sw, sh, u, v, fa, fb, w, n, color); break; } } static void -fz_paintaffinecolornear(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, byte *color) +fz_paint_affine_color_near(byte *dp, byte *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, byte *color) { switch (n) { - case 2: fz_paintaffinecolorNnear(dp, sp, sw, sh, u, v, fa, fb, w, 2, color); break; - case 4: fz_paintaffinecolorNnear(dp, sp, sw, sh, u, v, fa, fb, w, 4, color); break; - default: fz_paintaffinecolorNnear(dp, sp, sw, sh, u, v, fa, fb, w, n, color); break; + case 2: fz_paint_affine_color_N_near(dp, sp, sw, sh, u, v, fa, fb, w, 2, color); break; + case 4: fz_paint_affine_color_N_near(dp, sp, sw, sh, u, v, fa, fb, w, 4, color); break; + default: fz_paint_affine_color_N_near(dp, sp, sw, sh, u, v, fa, fb, w, n, color); break; } } /* Draw an image with an affine transform on destination */ static void -fz_paintimageimp(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *img, fz_matrix ctm, byte *color, int alpha) +fz_paint_image_imp(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *img, fz_matrix ctm, byte *color, int alpha) { byte *dp, *sp; int u, v, fa, fb, fc, fd; @@ -277,7 +277,7 @@ fz_paintimageimp(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *img, fz_matrix ctm, int dolerp; /* grid fit the image */ - if (fz_isrectilinear(ctm)) + if (fz_is_rectilinear(ctm)) { ctm.a = roundup(ctm.a); ctm.b = roundup(ctm.b); @@ -289,7 +289,7 @@ fz_paintimageimp(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *img, fz_matrix ctm, /* turn on interpolation for upscaled and non-rectilinear transforms */ dolerp = 0; - if (!fz_isrectilinear(ctm)) + if (!fz_is_rectilinear(ctm)) dolerp = 1; if (sqrtf(ctm.a * ctm.a + ctm.b * ctm.b) > img->w) dolerp = 1; @@ -305,8 +305,8 @@ fz_paintimageimp(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *img, fz_matrix ctm, dolerp = 0; } - bbox = fz_roundrect(fz_transformrect(ctm, fz_unitrect)); - bbox = fz_intersectbbox(bbox, scissor); + bbox = fz_round_rect(fz_transform_rect(ctm, fz_unit_rect)); + bbox = fz_intersect_bbox(bbox, scissor); x = bbox.x0; y = bbox.y0; w = bbox.x1 - bbox.x0; @@ -316,7 +316,7 @@ fz_paintimageimp(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *img, fz_matrix ctm, inv = fz_scale(1.0f / img->w, -1.0f / img->h); inv = fz_concat(inv, fz_translate(0, 1)); inv = fz_concat(inv, ctm); - inv = fz_invertmatrix(inv); + inv = fz_invert_matrix(inv); fa = inv.a * 65536; fb = inv.b * 65536; @@ -333,23 +333,23 @@ fz_paintimageimp(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *img, fz_matrix ctm, sw = img->w; sh = img->h; - /* TODO: if (fb == 0 && fa == 1) call fz_paintspan */ + /* TODO: if (fb == 0 && fa == 1) call fz_paint_span */ while (h--) { if (dolerp) { if (color) - fz_paintaffinecolorlerp(dp, sp, sw, sh, u, v, fa, fb, w, n, color); + fz_paint_affine_color_lerp(dp, sp, sw, sh, u, v, fa, fb, w, n, color); else - fz_paintaffinelerp(dp, sp, sw, sh, u, v, fa, fb, w, n, alpha); + fz_paint_affine_lerp(dp, sp, sw, sh, u, v, fa, fb, w, n, alpha); } else { if (color) - fz_paintaffinecolornear(dp, sp, sw, sh, u, v, fa, fb, w, n, color); + fz_paint_affine_color_near(dp, sp, sw, sh, u, v, fa, fb, w, n, color); else - fz_paintaffinenear(dp, sp, sw, sh, u, v, fa, fb, w, n, alpha); + fz_paint_affine_near(dp, sp, sw, sh, u, v, fa, fb, w, n, alpha); } dp += dst->w * n; u += fc; @@ -358,15 +358,15 @@ fz_paintimageimp(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *img, fz_matrix ctm, } void -fz_paintimagecolor(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *img, fz_matrix ctm, byte *color) +fz_paint_image_with_color(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *img, fz_matrix ctm, byte *color) { assert(img->n == 1); - fz_paintimageimp(dst, scissor, img, ctm, color, 255); + fz_paint_image_imp(dst, scissor, img, ctm, color, 255); } void -fz_paintimage(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *img, fz_matrix ctm, int alpha) +fz_paint_image(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *img, fz_matrix ctm, int alpha) { assert(dst->n == img->n); - fz_paintimageimp(dst, scissor, img, ctm, nil, alpha); + fz_paint_image_imp(dst, scissor, img, ctm, NULL, alpha); } diff --git a/draw/draw_blend.c b/draw/draw_blend.c index ac2e6c27..5b4d8e83 100644 --- a/draw/draw_blend.c +++ b/draw/draw_blend.c @@ -4,7 +4,7 @@ typedef unsigned char byte; -const char *fz_blendnames[] = +const char *fz_blendmode_names[] = { "Normal", "Multiply", @@ -22,7 +22,7 @@ const char *fz_blendnames[] = "Saturation", "Color", "Luminosity", - nil + NULL }; /* Separable blend modes */ @@ -34,7 +34,7 @@ fz_screen_byte(int b, int s) } static inline int -fz_hardlight_byte(int b, int s) +fz_hard_light_byte(int b, int s) { int s2 = s << 1; if (s <= 127) @@ -46,7 +46,7 @@ fz_hardlight_byte(int b, int s) static inline int fz_overlay_byte(int b, int s) { - return fz_hardlight_byte(s, b); /* note swapped order */ + return fz_hard_light_byte(s, b); /* note swapped order */ } static inline int @@ -62,7 +62,7 @@ fz_lighten_byte(int b, int s) } static inline int -fz_colordodge_byte(int b, int s) +fz_color_dodge_byte(int b, int s) { s = 255 - s; if (b == 0) @@ -74,7 +74,7 @@ fz_colordodge_byte(int b, int s) } static inline int -fz_colorburn_byte(int b, int s) +fz_color_burn_byte(int b, int s) { b = 255 - b; if (b == 0) @@ -86,7 +86,7 @@ fz_colorburn_byte(int b, int s) } static inline int -fz_softlight_byte(int b, int s) +fz_soft_light_byte(int b, int s) { /* review this */ if (s < 128) { @@ -228,7 +228,7 @@ fz_hue_rgb(int *rr, int *rg, int *rb, int br, int bg, int bb, int sr, int sg, in /* Blending loops */ void -fz_blendseparable(byte * restrict bp, byte * restrict sp, int n, int w, fz_blendmode blendmode) +fz_blend_separable(byte * restrict bp, byte * restrict sp, int n, int w, fz_blendmode blendmode) { int k; int n1 = n - 1; @@ -251,18 +251,18 @@ fz_blendseparable(byte * restrict bp, byte * restrict sp, int n, int w, fz_blend switch (blendmode) { default: - case FZ_BNORMAL: rc = sc; break; - case FZ_BMULTIPLY: rc = fz_mul255(bc, sc); break; - case FZ_BSCREEN: rc = fz_screen_byte(bc, sc); break; - case FZ_BOVERLAY: rc = fz_overlay_byte(bc, sc); break; - case FZ_BDARKEN: rc = fz_darken_byte(bc, sc); break; - case FZ_BLIGHTEN: rc = fz_lighten_byte(bc, sc); break; - case FZ_BCOLORDODGE: rc = fz_colordodge_byte(bc, sc); break; - case FZ_BCOLORBURN: rc = fz_colorburn_byte(bc, sc); break; - case FZ_BHARDLIGHT: rc = fz_hardlight_byte(bc, sc); break; - case FZ_BSOFTLIGHT: rc = fz_softlight_byte(bc, sc); break; - case FZ_BDIFFERENCE: rc = fz_difference_byte(bc, sc); break; - case FZ_BEXCLUSION: rc = fz_exclusion_byte(bc, sc); break; + case FZ_BLEND_NORMAL: rc = sc; break; + case FZ_BLEND_MULTIPLY: rc = fz_mul255(bc, sc); break; + case FZ_BLEND_SCREEN: rc = fz_screen_byte(bc, sc); break; + case FZ_BLEND_OVERLAY: rc = fz_overlay_byte(bc, sc); break; + case FZ_BLEND_DARKEN: rc = fz_darken_byte(bc, sc); break; + case FZ_BLEND_LIGHTEN: rc = fz_lighten_byte(bc, sc); break; + case FZ_BLEND_COLOR_DODGE: rc = fz_color_dodge_byte(bc, sc); break; + case FZ_BLEND_COLOR_BURN: rc = fz_color_burn_byte(bc, sc); break; + case FZ_BLEND_HARD_LIGHT: rc = fz_hard_light_byte(bc, sc); break; + case FZ_BLEND_SOFT_LIGHT: rc = fz_soft_light_byte(bc, sc); break; + case FZ_BLEND_DIFFERENCE: rc = fz_difference_byte(bc, sc); break; + case FZ_BLEND_EXCLUSION: rc = fz_exclusion_byte(bc, sc); break; } bp[k] = fz_mul255(255 - sa, bp[k]) + fz_mul255(255 - ba, sp[k]) + fz_mul255(saba, rc); @@ -276,7 +276,7 @@ fz_blendseparable(byte * restrict bp, byte * restrict sp, int n, int w, fz_blend } void -fz_blendnonseparable(byte * restrict bp, byte * restrict sp, int w, fz_blendmode blendmode) +fz_blend_nonseparable(byte * restrict bp, byte * restrict sp, int w, fz_blendmode blendmode) { while (w--) { @@ -301,16 +301,16 @@ fz_blendnonseparable(byte * restrict bp, byte * restrict sp, int w, fz_blendmode switch (blendmode) { default: - case FZ_BHUE: + case FZ_BLEND_HUE: fz_hue_rgb(&rr, &rg, &rb, br, bg, bb, sr, sg, sb); break; - case FZ_BSATURATION: + case FZ_BLEND_SATURATION: fz_saturation_rgb(&rr, &rg, &rb, br, bg, bb, sr, sg, sb); break; - case FZ_BCOLOR: + case FZ_BLEND_COLOR: fz_color_rgb(&rr, &rg, &rb, br, bg, bb, sr, sg, sb); break; - case FZ_BLUMINOSITY: + case FZ_BLEND_LUMINOSITY: fz_luminosity_rgb(&rr, &rg, &rb, br, bg, bb, sr, sg, sb); break; } @@ -326,7 +326,7 @@ fz_blendnonseparable(byte * restrict bp, byte * restrict sp, int w, fz_blendmode } void -fz_blendpixmap(fz_pixmap *dst, fz_pixmap *src, int alpha, fz_blendmode blendmode) +fz_blend_pixmap(fz_pixmap *dst, fz_pixmap *src, int alpha, fz_blendmode blendmode) { unsigned char *sp, *dp; fz_bbox bbox; @@ -344,8 +344,8 @@ fz_blendpixmap(fz_pixmap *dst, fz_pixmap *src, int alpha, fz_blendmode blendmode } } - bbox = fz_boundpixmap(dst); - bbox = fz_intersectbbox(bbox, fz_boundpixmap(src)); + bbox = fz_bound_pixmap(dst); + bbox = fz_intersect_bbox(bbox, fz_bound_pixmap(src)); x = bbox.x0; y = bbox.y0; @@ -360,10 +360,10 @@ fz_blendpixmap(fz_pixmap *dst, fz_pixmap *src, int alpha, fz_blendmode blendmode while (h--) { - if (n == 4 && blendmode >= FZ_BHUE) - fz_blendnonseparable(dp, sp, w, blendmode); + if (n == 4 && blendmode >= FZ_BLEND_HUE) + fz_blend_nonseparable(dp, sp, w, blendmode); else - fz_blendseparable(dp, sp, n, w, blendmode); + fz_blend_separable(dp, sp, n, w, blendmode); sp += src->w * n; dp += dst->w * n; } diff --git a/draw/draw_edge.c b/draw/draw_edge.c index aa956077..9e916555 100644 --- a/draw/draw_edge.c +++ b/draw/draw_edge.c @@ -20,7 +20,7 @@ enum { HSCALE = 17, VSCALE = 15, SF = 1 }; */ fz_gel * -fz_newgel(void) +fz_new_gel(void) { fz_gel *gel; @@ -39,9 +39,9 @@ fz_newgel(void) } void -fz_resetgel(fz_gel *gel, fz_bbox clip) +fz_reset_gel(fz_gel *gel, fz_bbox clip) { - if (fz_isinfiniterect(clip)) + if (fz_is_infinite_rect(clip)) { gel->clip.x0 = gel->clip.y0 = BBOX_MAX; gel->clip.x1 = gel->clip.y1 = BBOX_MIN; @@ -60,18 +60,18 @@ fz_resetgel(fz_gel *gel, fz_bbox clip) } void -fz_freegel(fz_gel *gel) +fz_free_gel(fz_gel *gel) { fz_free(gel->edges); fz_free(gel); } fz_bbox -fz_boundgel(fz_gel *gel) +fz_bound_gel(fz_gel *gel) { fz_bbox bbox; if (gel->len == 0) - return fz_emptybbox; + return fz_empty_bbox; bbox.x0 = fz_idiv(gel->bbox.x0, HSCALE); bbox.y0 = fz_idiv(gel->bbox.y0, VSCALE); bbox.x1 = fz_idiv(gel->bbox.x1, HSCALE) + 1; @@ -81,10 +81,10 @@ fz_boundgel(fz_gel *gel) enum { INSIDE, OUTSIDE, LEAVE, ENTER }; -#define cliplerpy(v,m,x0,y0,x1,y1,t) cliplerpx(v,m,y0,x0,y1,x1,t) +#define clip_lerp_y(v,m,x0,y0,x1,y1,t) clip_lerp_x(v,m,y0,x0,y1,x1,t) static int -cliplerpx(int val, int m, int x0, int y0, int x1, int y1, int *out) +clip_lerp_x(int val, int m, int x0, int y0, int x1, int y1, int *out) { int v0out = m ? x0 > val : x0 < val; int v1out = m ? x1 > val : x1 < val; @@ -109,7 +109,7 @@ cliplerpx(int val, int m, int x0, int y0, int x1, int y1, int *out) } static void -fz_insertgelraw(fz_gel *gel, int x0, int y0, int x1, int y1) +fz_insert_gel_raw(fz_gel *gel, int x0, int y0, int x1, int y1) { fz_edge *edge; int dx, dy; @@ -152,7 +152,7 @@ fz_insertgelraw(fz_gel *gel, int x0, int y0, int x1, int y1) edge->x = x0; edge->y = y0; edge->h = dy; - edge->adjdown = dy; + edge->adj_down = dy; /* initial error term going l->r and r->l */ if (dx >= 0) @@ -163,18 +163,18 @@ fz_insertgelraw(fz_gel *gel, int x0, int y0, int x1, int y1) /* y-major edge */ if (dy >= width) { edge->xmove = 0; - edge->adjup = width; + edge->adj_up = width; } /* x-major edge */ else { edge->xmove = (width / dy) * edge->xdir; - edge->adjup = width % dy; + edge->adj_up = width % dy; } } void -fz_insertgel(fz_gel *gel, float fx0, float fy0, float fx1, float fy1) +fz_insert_gel(fz_gel *gel, float fx0, float fy0, float fx1, float fy1) { int x0, y0, x1, y1; int d, v; @@ -189,51 +189,51 @@ fz_insertgel(fz_gel *gel, float fx0, float fy0, float fx1, float fy1) x1 = CLAMP(fx1, BBOX_MIN, BBOX_MAX); y1 = CLAMP(fy1, BBOX_MIN, BBOX_MAX); - d = cliplerpy(gel->clip.y0, 0, x0, y0, x1, y1, &v); + d = clip_lerp_y(gel->clip.y0, 0, x0, y0, x1, y1, &v); if (d == OUTSIDE) return; if (d == LEAVE) { y1 = gel->clip.y0; x1 = v; } if (d == ENTER) { y0 = gel->clip.y0; x0 = v; } - d = cliplerpy(gel->clip.y1, 1, x0, y0, x1, y1, &v); + d = clip_lerp_y(gel->clip.y1, 1, x0, y0, x1, y1, &v); if (d == OUTSIDE) return; if (d == LEAVE) { y1 = gel->clip.y1; x1 = v; } if (d == ENTER) { y0 = gel->clip.y1; x0 = v; } - d = cliplerpx(gel->clip.x0, 0, x0, y0, x1, y1, &v); + d = clip_lerp_x(gel->clip.x0, 0, x0, y0, x1, y1, &v); if (d == OUTSIDE) { x0 = x1 = gel->clip.x0; } if (d == LEAVE) { - fz_insertgelraw(gel, gel->clip.x0, v, gel->clip.x0, y1); + fz_insert_gel_raw(gel, gel->clip.x0, v, gel->clip.x0, y1); x1 = gel->clip.x0; y1 = v; } if (d == ENTER) { - fz_insertgelraw(gel, gel->clip.x0, y0, gel->clip.x0, v); + fz_insert_gel_raw(gel, gel->clip.x0, y0, gel->clip.x0, v); x0 = gel->clip.x0; y0 = v; } - d = cliplerpx(gel->clip.x1, 1, x0, y0, x1, y1, &v); + d = clip_lerp_x(gel->clip.x1, 1, x0, y0, x1, y1, &v); if (d == OUTSIDE) { x0 = x1 = gel->clip.x1; } if (d == LEAVE) { - fz_insertgelraw(gel, gel->clip.x1, v, gel->clip.x1, y1); + fz_insert_gel_raw(gel, gel->clip.x1, v, gel->clip.x1, y1); x1 = gel->clip.x1; y1 = v; } if (d == ENTER) { - fz_insertgelraw(gel, gel->clip.x1, y0, gel->clip.x1, v); + fz_insert_gel_raw(gel, gel->clip.x1, y0, gel->clip.x1, v); x0 = gel->clip.x1; y0 = v; } - fz_insertgelraw(gel, x0, y0, x1, y1); + fz_insert_gel_raw(gel, x0, y0, x1, y1); } void -fz_sortgel(fz_gel *gel) +fz_sort_gel(fz_gel *gel) { fz_edge *a = gel->edges; int n = gel->len; @@ -270,7 +270,7 @@ fz_sortgel(fz_gel *gel) } int -fz_isrectgel(fz_gel *gel) +fz_is_rect_gel(fz_gel *gel) { /* a rectangular path is converted into two vertical edges of identical height */ if (gel->len == 2) @@ -278,8 +278,8 @@ fz_isrectgel(fz_gel *gel) fz_edge *a = gel->edges + 0; fz_edge *b = gel->edges + 1; return a->y == b->y && a->h == b->h && - a->xmove == 0 && a->adjup == 0 && - b->xmove == 0 && b->adjup == 0; + a->xmove == 0 && a->adj_up == 0 && + b->xmove == 0 && b->adj_up == 0; } return 0; } @@ -289,7 +289,7 @@ fz_isrectgel(fz_gel *gel) */ fz_ael * -fz_newael(void) +fz_new_ael(void) { fz_ael *ael; ael = fz_malloc(sizeof(fz_ael)); @@ -300,14 +300,14 @@ fz_newael(void) } void -fz_freeael(fz_ael *ael) +fz_free_ael(fz_ael *ael) { fz_free(ael->edges); fz_free(ael); } static inline void -sortael(fz_edge **a, int n) +sort_ael(fz_edge **a, int n) { int h, i, k; fz_edge *t; @@ -340,7 +340,7 @@ sortael(fz_edge **a, int n) } static fz_error -insertael(fz_ael *ael, fz_gel *gel, int y, int *e) +insert_ael(fz_ael *ael, fz_gel *gel, int y, int *e) { /* insert edges that start here */ while (*e < gel->len && gel->edges[*e].y == y) { @@ -354,13 +354,13 @@ insertael(fz_ael *ael, fz_gel *gel, int y, int *e) } /* shell-sort the edges by increasing x */ - sortael(ael->edges, ael->len); + sort_ael(ael->edges, ael->len); return fz_okay; } static void -advanceael(fz_ael *ael) +advance_ael(fz_ael *ael) { fz_edge *edge; int i = 0; @@ -378,10 +378,10 @@ advanceael(fz_ael *ael) else { edge->x += edge->xmove; - edge->e += edge->adjup; + edge->e += edge->adj_up; if (edge->e > 0) { edge->x += edge->xdir; - edge->e -= edge->adjdown; + edge->e -= edge->adj_down; } i ++; } @@ -393,7 +393,7 @@ advanceael(fz_ael *ael) */ static inline void -addspan(unsigned char *list, int x0, int x1, int xofs) +add_span(unsigned char *list, int x0, int x1, int xofs) { int x0pix, x0sub; int x1pix, x1sub; @@ -426,7 +426,7 @@ addspan(unsigned char *list, int x0, int x1, int xofs) } static inline void -nonzerowinding(fz_ael *ael, unsigned char *list, int xofs) +non_zero_winding(fz_ael *ael, unsigned char *list, int xofs) { int winding = 0; int x = 0; @@ -436,13 +436,13 @@ nonzerowinding(fz_ael *ael, unsigned char *list, int xofs) if (!winding && (winding + ael->edges[i]->ydir)) x = ael->edges[i]->x; if (winding && !(winding + ael->edges[i]->ydir)) - addspan(list, x, ael->edges[i]->x, xofs); + add_span(list, x, ael->edges[i]->x, xofs); winding += ael->edges[i]->ydir; } } static inline void -evenodd(fz_ael *ael, unsigned char *list, int xofs) +even_odd(fz_ael *ael, unsigned char *list, int xofs) { int even = 0; int x = 0; @@ -452,7 +452,7 @@ evenodd(fz_ael *ael, unsigned char *list, int xofs) if (!even) x = ael->edges[i]->x; else - addspan(list, x, ael->edges[i]->x, xofs); + add_span(list, x, ael->edges[i]->x, xofs); even = !even; } } @@ -476,13 +476,13 @@ blit(fz_pixmap *dest, int x, int y, unsigned char *mp, int w, unsigned char *col dp = dest->samples + ( (y - dest->y) * dest->w + (x - dest->x) ) * dest->n; if (color) - fz_paintspancolor(dp, mp, dest->n, w, color); + fz_paint_span_with_color(dp, mp, dest->n, w, color); else - fz_paintspan(dp, mp, 1, w, 255); + fz_paint_span(dp, mp, 1, w, 255); } fz_error -fz_scanconvert(fz_gel *gel, fz_ael *ael, int eofill, fz_bbox clip, +fz_scan_convert(fz_gel *gel, fz_ael *ael, int eofill, fz_bbox clip, fz_pixmap *dest, unsigned char *color) { fz_error error; @@ -526,7 +526,7 @@ fz_scanconvert(fz_gel *gel, fz_ael *ael, int eofill, fz_bbox clip, } yd = yc; - error = insertael(ael, gel, y, &e); + error = insert_ael(ael, gel, y, &e); if (error) { fz_free(deltas); return error; @@ -535,12 +535,12 @@ fz_scanconvert(fz_gel *gel, fz_ael *ael, int eofill, fz_bbox clip, if (yd >= clip.y0 && yd < clip.y1) { if (eofill) - evenodd(ael, deltas, xofs); + even_odd(ael, deltas, xofs); else - nonzerowinding(ael, deltas, xofs); + non_zero_winding(ael, deltas, xofs); } - advanceael(ael); + advance_ael(ael); if (ael->len > 0) y ++; diff --git a/draw/draw_glyph.c b/draw/draw_glyph.c index 15bb7cae..2a6ae616 100644 --- a/draw/draw_glyph.c +++ b/draw/draw_glyph.c @@ -1,18 +1,18 @@ #include "fitz.h" -#define MAXFONTSIZE 1000 -#define MAXGLYPHSIZE 256 -#define MAXCACHESIZE (1024*1024) +#define MAX_FONT_SIZE 1000 +#define MAX_GLYPH_SIZE 256 +#define MAX_CACHE_SIZE (1024*1024) -typedef struct fz_glyphkey_s fz_glyphkey; +typedef struct fz_glyph_key_s fz_glyph_key; -struct fz_glyphcache_s +struct fz_glyph_cache_s { - fz_hashtable *hash; + fz_hash_table *hash; int total; }; -struct fz_glyphkey_s +struct fz_glyph_key_s { fz_font *font; int a, b; @@ -21,68 +21,68 @@ struct fz_glyphkey_s unsigned char e, f; }; -fz_glyphcache * -fz_newglyphcache(void) +fz_glyph_cache * +fz_new_glyph_cache(void) { - fz_glyphcache *cache; + fz_glyph_cache *cache; - cache = fz_malloc(sizeof(fz_glyphcache)); - cache->hash = fz_newhash(509, sizeof(fz_glyphkey)); + cache = fz_malloc(sizeof(fz_glyph_cache)); + cache->hash = fz_new_hash_table(509, sizeof(fz_glyph_key)); cache->total = 0; return cache; } static void -fz_evictglyphcache(fz_glyphcache *cache) +fz_evict_glyph_cache(fz_glyph_cache *cache) { - fz_glyphkey *key; + fz_glyph_key *key; fz_pixmap *pixmap; int i; - for (i = 0; i < fz_hashlen(cache->hash); i++) + for (i = 0; i < fz_hash_len(cache->hash); i++) { - key = fz_hashgetkey(cache->hash, i); + key = fz_hash_get_key(cache->hash, i); if (key->font) - fz_dropfont(key->font); - pixmap = fz_hashgetval(cache->hash, i); + fz_drop_font(key->font); + pixmap = fz_hash_get_val(cache->hash, i); if (pixmap) - fz_droppixmap(pixmap); + fz_drop_pixmap(pixmap); } cache->total = 0; - fz_emptyhash(cache->hash); + fz_empty_hash(cache->hash); } void -fz_freeglyphcache(fz_glyphcache *cache) +fz_free_glyph_cache(fz_glyph_cache *cache) { - fz_evictglyphcache(cache); - fz_freehash(cache->hash); + fz_evict_glyph_cache(cache); + fz_free_hash(cache->hash); fz_free(cache); } fz_pixmap * -fz_renderstrokedglyph(fz_glyphcache *cache, fz_font *font, int cid, fz_matrix trm, fz_matrix ctm, fz_strokestate *stroke) +fz_render_stroked_glyph(fz_glyph_cache *cache, fz_font *font, int cid, fz_matrix trm, fz_matrix ctm, fz_stroke_state *stroke) { - if (font->ftface) - return fz_renderftstrokedglyph(font, cid, trm, ctm, stroke); - return fz_renderglyph(cache, font, cid, trm); + if (font->ft_face) + return fz_render_ft_stroked_glyph(font, cid, trm, ctm, stroke); + return fz_render_glyph(cache, font, cid, trm); } fz_pixmap * -fz_renderglyph(fz_glyphcache *cache, fz_font *font, int cid, fz_matrix ctm) +fz_render_glyph(fz_glyph_cache *cache, fz_font *font, int cid, fz_matrix ctm) { - fz_glyphkey key; + fz_glyph_key key; fz_pixmap *val; - float size = fz_matrixexpansion(ctm); + float size = fz_matrix_expansion(ctm); - if (size > MAXFONTSIZE) + if (size > MAX_FONT_SIZE) { /* TODO: this case should be handled by rendering glyph as a path fill */ fz_warn("font size too large (%g), not rendering glyph", size); - return nil; + return NULL; } memset(&key, 0, sizeof key); @@ -95,40 +95,40 @@ fz_renderglyph(fz_glyphcache *cache, fz_font *font, int cid, fz_matrix ctm) key.e = (ctm.e - floorf(ctm.e)) * 256; key.f = (ctm.f - floorf(ctm.f)) * 256; - val = fz_hashfind(cache->hash, &key); + val = fz_hash_find(cache->hash, &key); if (val) - return fz_keeppixmap(val); + return fz_keep_pixmap(val); ctm.e = floorf(ctm.e) + key.e / 256.0f; ctm.f = floorf(ctm.f) + key.f / 256.0f; - if (font->ftface) + if (font->ft_face) { - val = fz_renderftglyph(font, cid, ctm); + val = fz_render_ft_glyph(font, cid, ctm); } else if (font->t3procs) { - val = fz_rendert3glyph(font, cid, ctm); + val = fz_render_t3_glyph(font, cid, ctm); } else { fz_warn("assert: uninitialized font structure"); - return nil; + return NULL; } if (val) { - if (val->w < MAXGLYPHSIZE && val->h < MAXGLYPHSIZE) + if (val->w < MAX_GLYPH_SIZE && val->h < MAX_GLYPH_SIZE) { - if (cache->total + val->w * val->h > MAXCACHESIZE) - fz_evictglyphcache(cache); - fz_keepfont(key.font); - fz_hashinsert(cache->hash, &key, val); + if (cache->total + val->w * val->h > MAX_CACHE_SIZE) + fz_evict_glyph_cache(cache); + fz_keep_font(key.font); + fz_hash_insert(cache->hash, &key, val); cache->total += val->w * val->h; - return fz_keeppixmap(val); + return fz_keep_pixmap(val); } return val; } - return nil; + return NULL; } diff --git a/draw/draw_mesh.c b/draw/draw_mesh.c index 79437505..eeebf0a1 100644 --- a/draw/draw_mesh.c +++ b/draw/draw_mesh.c @@ -6,7 +6,7 @@ enum { IN, OUT, ENTER, LEAVE }; enum { MAXV = 3 + 4 }; -enum { MAXN = 2 + FZ_MAXCOLORS }; +enum { MAXN = 2 + FZ_MAX_COLORS }; static int clipx(float val, int ismax, float *v1, float *v2, int n) { @@ -68,13 +68,13 @@ static int clipy(float val, int ismax, float *v1, float *v2, int n) } } -static inline void copyvert(float *dst, float *src, int n) +static inline void copy_vert(float *dst, float *src, int n) { while (n--) *dst++ = *src++; } -static int clippoly(float src[MAXV][MAXN], +static int clip_poly(float src[MAXV][MAXN], float dst[MAXV][MAXN], int len, int n, float val, int isy, int ismax) { @@ -88,8 +88,8 @@ static int clippoly(float src[MAXV][MAXN], for (v2 = 0; v2 < len; v2++) { - copyvert(cv1, src[v1], n); - copyvert(cv2, src[v2], n); + copy_vert(cv1, src[v1], n); + copy_vert(cv2, src[v2], n); if (isy) r = clipy(val, ismax, cv1, cv2, n); @@ -99,16 +99,16 @@ static int clippoly(float src[MAXV][MAXN], switch (r) { case IN: - copyvert(dst[cp++], cv2, n); + copy_vert(dst[cp++], cv2, n); break; case OUT: break; case LEAVE: - copyvert(dst[cp++], cv2, n); + copy_vert(dst[cp++], cv2, n); break; case ENTER: - copyvert(dst[cp++], cv1, n); - copyvert(dst[cp++], cv2, n); + copy_vert(dst[cp++], cv1, n); + copy_vert(dst[cp++], cv2, n); break; } v1 = v2; @@ -122,11 +122,11 @@ static int clippoly(float src[MAXV][MAXN], */ static inline void -paintscan(fz_pixmap *pix, int y, int x1, int x2, int *v1, int *v2, int n) +paint_scan(fz_pixmap *pix, int y, int x1, int x2, int *v1, int *v2, int n) { unsigned char *p = pix->samples + ((y - pix->y) * pix->w + (x1 - pix->x)) * pix->n; - int v[FZ_MAXCOLORS]; - int dv[FZ_MAXCOLORS]; + int v[FZ_MAX_COLORS]; + int dv[FZ_MAX_COLORS]; int w = x2 - x1; int k; @@ -157,7 +157,7 @@ paintscan(fz_pixmap *pix, int y, int x1, int x2, int *v1, int *v2, int n) } static inline int -findnext(int gel[MAXV][MAXN], int len, int a, int *s, int *e, int d) +find_next(int gel[MAXV][MAXN], int len, int a, int *s, int *e, int d) { int b; @@ -187,7 +187,7 @@ findnext(int gel[MAXV][MAXN], int len, int a, int *s, int *e, int d) } static inline void -loadedge(int gel[MAXV][MAXN], int s, int e, int *ael, int *del, int n) +load_edge(int gel[MAXV][MAXN], int s, int e, int *ael, int *del, int n) { int swp, k, dy; @@ -208,7 +208,7 @@ loadedge(int gel[MAXV][MAXN], int s, int e, int *ael, int *del, int n) } static inline void -stepedge(int *ael, int *del, int n) +step_edge(int *ael, int *del, int n) { int k; ael[0] += del[0]; @@ -217,7 +217,7 @@ stepedge(int *ael, int *del, int n) } static void -fz_painttriangle(fz_pixmap *pix, float *av, float *bv, float *cv, int n, fz_bbox bbox) +fz_paint_triangle(fz_pixmap *pix, float *av, float *bv, float *cv, int n, fz_bbox bbox) { float poly[MAXV][MAXN]; float temp[MAXV][MAXN]; @@ -234,14 +234,14 @@ fz_painttriangle(fz_pixmap *pix, float *av, float *bv, float *cv, int n, fz_bbox int i, k; - copyvert(poly[0], av, n); - copyvert(poly[1], bv, n); - copyvert(poly[2], cv, n); + copy_vert(poly[0], av, n); + copy_vert(poly[1], bv, n); + copy_vert(poly[2], cv, n); - len = clippoly(poly, temp, 3, n, cx0, 0, 0); - len = clippoly(temp, poly, len, n, cx1, 0, 1); - len = clippoly(poly, temp, len, n, cy0, 1, 0); - len = clippoly(temp, poly, len, n, cy1, 1, 1); + len = clip_poly(poly, temp, 3, n, cx0, 0, 0); + len = clip_poly(temp, poly, len, n, cx1, 0, 1); + len = clip_poly(poly, temp, len, n, cy0, 1, 0); + len = clip_poly(temp, poly, len, n, cy1, 1, 1); if (len < 3) return; @@ -268,13 +268,13 @@ fz_painttriangle(fz_pixmap *pix, float *av, float *bv, float *cv, int n, fz_bbox y = gel[top][1]; - if (findnext(gel, len, top, &s0, &e0, 1)) + if (find_next(gel, len, top, &s0, &e0, 1)) return; - if (findnext(gel, len, top, &s1, &e1, -1)) + if (find_next(gel, len, top, &s1, &e1, -1)) return; - loadedge(gel, s0, e0, ael[0], del[0], n); - loadedge(gel, s1, e1, ael[1], del[1], n); + load_edge(gel, s0, e0, ael[0], del[0], n); + load_edge(gel, s1, e1, ael[1], del[1], n); while (1) { @@ -282,32 +282,32 @@ fz_painttriangle(fz_pixmap *pix, float *av, float *bv, float *cv, int n, fz_bbox int x1 = ael[1][0] >> 16; if (ael[0][0] < ael[1][0]) - paintscan(pix, y, x0, x1, ael[0]+2, ael[1]+2, n-2); + paint_scan(pix, y, x0, x1, ael[0]+2, ael[1]+2, n-2); else - paintscan(pix, y, x1, x0, ael[1]+2, ael[0]+2, n-2); + paint_scan(pix, y, x1, x0, ael[1]+2, ael[0]+2, n-2); - stepedge(ael[0], del[0], n); - stepedge(ael[1], del[1], n); + step_edge(ael[0], del[0], n); + step_edge(ael[1], del[1], n); y ++; if (y >= gel[e0][1]) { - if (findnext(gel, len, e0, &s0, &e0, 1)) + if (find_next(gel, len, e0, &s0, &e0, 1)) return; - loadedge(gel, s0, e0, ael[0], del[0], n); + load_edge(gel, s0, e0, ael[0], del[0], n); } if (y >= gel[e1][1]) { - if (findnext(gel, len, e1, &s1, &e1, -1)) + if (find_next(gel, len, e1, &s1, &e1, -1)) return; - loadedge(gel, s1, e1, ael[1], del[1], n); + load_edge(gel, s1, e1, ael[1], del[1], n); } } } static void -fz_paintquad(fz_pixmap *pix, +fz_paint_quad(fz_pixmap *pix, fz_point p0, fz_point p1, fz_point p2, fz_point p3, float c0, float c1, float c2, float c3, int n, fz_bbox bbox) @@ -330,8 +330,8 @@ fz_paintquad(fz_pixmap *pix, v[3][1] = p3.y; v[3][2] = c3; - fz_painttriangle(pix, v[0], v[2], v[3], n, bbox); - fz_painttriangle(pix, v[0], v[3], v[1], n, bbox); + fz_paint_triangle(pix, v[0], v[2], v[3], n, bbox); + fz_paint_triangle(pix, v[0], v[3], v[1], n, bbox); } /* @@ -342,7 +342,7 @@ fz_paintquad(fz_pixmap *pix, #define RADSEGS 32 /* how many segments to generate for radial meshes */ static fz_point -fz_pointoncircle(fz_point p, float r, float theta) +fz_point_on_circle(fz_point p, float r, float theta) { p.x = p.x + cosf(theta) * r; p.y = p.y + sinf(theta) * r; @@ -351,7 +351,7 @@ fz_pointoncircle(fz_point p, float r, float theta) } static void -fz_paintlinear(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) +fz_paint_linear(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) { fz_point p0, p1; fz_point v0, v1, v2, v3; @@ -360,21 +360,21 @@ fz_paintlinear(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) p0.x = shade->mesh[0]; p0.y = shade->mesh[1]; - p0 = fz_transformpoint(ctm, p0); + p0 = fz_transform_point(ctm, p0); p1.x = shade->mesh[3]; p1.y = shade->mesh[4]; - p1 = fz_transformpoint(ctm, p1); + p1 = fz_transform_point(ctm, p1); theta = atan2f(p1.y - p0.y, p1.x - p0.x); theta += (float)M_PI * 0.5f; - v0 = fz_pointoncircle(p0, HUGENUM, theta); - v1 = fz_pointoncircle(p1, HUGENUM, theta); - v2 = fz_pointoncircle(p0, -HUGENUM, theta); - v3 = fz_pointoncircle(p1, -HUGENUM, theta); + v0 = fz_point_on_circle(p0, HUGENUM, theta); + v1 = fz_point_on_circle(p1, HUGENUM, theta); + v2 = fz_point_on_circle(p0, -HUGENUM, theta); + v3 = fz_point_on_circle(p1, -HUGENUM, theta); - fz_paintquad(dest, v0, v1, v2, v3, 0, 255, 0, 255, 3, bbox); + fz_paint_quad(dest, v0, v1, v2, v3, 0, 255, 0, 255, 3, bbox); if (shade->extend[0]) { @@ -384,7 +384,7 @@ fz_paintlinear(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) e1.x = v2.x - (p1.x - p0.x) * HUGENUM; e1.y = v2.y - (p1.y - p0.y) * HUGENUM; - fz_paintquad(dest, e0, e1, v0, v2, 0, 0, 0, 0, 3, bbox); + fz_paint_quad(dest, e0, e1, v0, v2, 0, 0, 0, 0, 3, bbox); } if (shade->extend[1]) @@ -395,12 +395,12 @@ fz_paintlinear(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) e1.x = v3.x + (p1.x - p0.x) * HUGENUM; e1.y = v3.y + (p1.y - p0.y) * HUGENUM; - fz_paintquad(dest, e0, e1, v1, v3, 255, 255, 255, 255, 3, bbox); + fz_paint_quad(dest, e0, e1, v1, v3, 255, 255, 255, 255, 3, bbox); } } static void -fz_paintannulus(fz_matrix ctm, +fz_paint_annulus(fz_matrix ctm, fz_point p0, float r0, float c0, fz_point p1, float r1, float c1, fz_pixmap *dest, fz_bbox bbox) @@ -414,31 +414,31 @@ fz_paintannulus(fz_matrix ctm, for (i = 0; i < RADSEGS / 2; i++) { - t0 = fz_pointoncircle(p0, r0, theta + i * step); - t1 = fz_pointoncircle(p0, r0, theta + i * step + step); - t2 = fz_pointoncircle(p1, r1, theta + i * step); - t3 = fz_pointoncircle(p1, r1, theta + i * step + step); - b0 = fz_pointoncircle(p0, r0, theta - i * step); - b1 = fz_pointoncircle(p0, r0, theta - i * step - step); - b2 = fz_pointoncircle(p1, r1, theta - i * step); - b3 = fz_pointoncircle(p1, r1, theta - i * step - step); - - t0 = fz_transformpoint(ctm, t0); - t1 = fz_transformpoint(ctm, t1); - t2 = fz_transformpoint(ctm, t2); - t3 = fz_transformpoint(ctm, t3); - b0 = fz_transformpoint(ctm, b0); - b1 = fz_transformpoint(ctm, b1); - b2 = fz_transformpoint(ctm, b2); - b3 = fz_transformpoint(ctm, b3); - - fz_paintquad(dest, t0, t1, t2, t3, c0, c0, c1, c1, 3, bbox); - fz_paintquad(dest, b0, b1, b2, b3, c0, c0, c1, c1, 3, bbox); + t0 = fz_point_on_circle(p0, r0, theta + i * step); + t1 = fz_point_on_circle(p0, r0, theta + i * step + step); + t2 = fz_point_on_circle(p1, r1, theta + i * step); + t3 = fz_point_on_circle(p1, r1, theta + i * step + step); + b0 = fz_point_on_circle(p0, r0, theta - i * step); + b1 = fz_point_on_circle(p0, r0, theta - i * step - step); + b2 = fz_point_on_circle(p1, r1, theta - i * step); + b3 = fz_point_on_circle(p1, r1, theta - i * step - step); + + t0 = fz_transform_point(ctm, t0); + t1 = fz_transform_point(ctm, t1); + t2 = fz_transform_point(ctm, t2); + t3 = fz_transform_point(ctm, t3); + b0 = fz_transform_point(ctm, b0); + b1 = fz_transform_point(ctm, b1); + b2 = fz_transform_point(ctm, b2); + b3 = fz_transform_point(ctm, b3); + + fz_paint_quad(dest, t0, t1, t2, t3, c0, c0, c1, c1, 3, bbox); + fz_paint_quad(dest, b0, b1, b2, b3, c0, c0, c1, c1, 3, bbox); } } static void -fz_paintradial(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) +fz_paint_radial(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) { fz_point p0, p1; float r0, r1; @@ -464,10 +464,10 @@ fz_paintradial(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) e.y = p0.y + (p1.y - p0.y) * rs; er = r0 + (r1 - r0) * rs; - fz_paintannulus(ctm, e, er, 0, p0, r0, 0, dest, bbox); + fz_paint_annulus(ctm, e, er, 0, p0, r0, 0, dest, bbox); } - fz_paintannulus(ctm, p0, r0, 0, p1, r1, 255, dest, bbox); + fz_paint_annulus(ctm, p0, r0, 0, p1, r1, 255, dest, bbox); if (shade->extend[1]) { @@ -480,12 +480,12 @@ fz_paintradial(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) e.y = p1.y + (p0.y - p1.y) * rs; er = r1 + (r0 - r1) * rs; - fz_paintannulus(ctm, p1, r1, 255, e, er, 255, dest, bbox); + fz_paint_annulus(ctm, p1, r1, 255, e, er, 255, dest, bbox); } } static void -fz_paintmesh(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) +fz_paint_mesh(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) { float tri[3][MAXN]; fz_point p; @@ -495,10 +495,10 @@ fz_paintmesh(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) mesh = shade->mesh; - if (shade->usefunction) - ntris = shade->meshlen / 9; + if (shade->use_function) + ntris = shade->mesh_len / 9; else - ntris = shade->meshlen / ((2 + shade->colorspace->n) * 3); + ntris = shade->mesh_len / ((2 + shade->colorspace->n) * 3); while (ntris--) { @@ -506,45 +506,45 @@ fz_paintmesh(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) { p.x = *mesh++; p.y = *mesh++; - p = fz_transformpoint(ctm, p); + p = fz_transform_point(ctm, p); tri[k][0] = p.x; tri[k][1] = p.y; - if (shade->usefunction) + if (shade->use_function) tri[k][2] = *mesh++ * 255; else { - fz_convertcolor(shade->colorspace, mesh, dest->colorspace, tri[k] + 2); + fz_convert_color(shade->colorspace, mesh, dest->colorspace, tri[k] + 2); for (i = 0; i < dest->colorspace->n; i++) tri[k][i + 2] *= 255; mesh += shade->colorspace->n; } } - fz_painttriangle(dest, tri[0], tri[1], tri[2], 2 + dest->colorspace->n, bbox); + fz_paint_triangle(dest, tri[0], tri[1], tri[2], 2 + dest->colorspace->n, bbox); } } void -fz_paintshade(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) +fz_paint_shade(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) { - unsigned char clut[256][FZ_MAXCOLORS]; + unsigned char clut[256][FZ_MAX_COLORS]; fz_pixmap *temp, *conv; - float color[FZ_MAXCOLORS]; + float color[FZ_MAX_COLORS]; int i, k; ctm = fz_concat(shade->matrix, ctm); - if (shade->usefunction) + if (shade->use_function) { for (i = 0; i < 256; i++) { - fz_convertcolor(shade->colorspace, shade->function[i], dest->colorspace, color); + fz_convert_color(shade->colorspace, shade->function[i], dest->colorspace, color); for (k = 0; k < dest->colorspace->n; k++) clut[i][k] = color[k] * 255; clut[i][k] = shade->function[i][shade->colorspace->n] * 255; } - conv = fz_newpixmapwithrect(dest->colorspace, bbox); - temp = fz_newpixmapwithrect(fz_devicegray, bbox); - fz_clearpixmap(temp); + conv = fz_new_pixmap_with_rect(dest->colorspace, bbox); + temp = fz_new_pixmap_with_rect(fz_device_gray, bbox); + fz_clear_pixmap(temp); } else { @@ -553,12 +553,12 @@ fz_paintshade(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) switch (shade->type) { - case FZ_LINEAR: fz_paintlinear(shade, ctm, temp, bbox); break; - case FZ_RADIAL: fz_paintradial(shade, ctm, temp, bbox); break; - case FZ_MESH: fz_paintmesh(shade, ctm, temp, bbox); break; + case FZ_LINEAR: fz_paint_linear(shade, ctm, temp, bbox); break; + case FZ_RADIAL: fz_paint_radial(shade, ctm, temp, bbox); break; + case FZ_MESH: fz_paint_mesh(shade, ctm, temp, bbox); break; } - if (shade->usefunction) + if (shade->use_function) { unsigned char *s = temp->samples; unsigned char *d = conv->samples; @@ -571,9 +571,8 @@ fz_paintshade(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox) *d++ = fz_mul255(clut[v][k], a); *d++ = a; } - fz_paintpixmap(dest, conv, 255); - fz_droppixmap(conv); - fz_droppixmap(temp); + fz_paint_pixmap(dest, conv, 255); + fz_drop_pixmap(conv); + fz_drop_pixmap(temp); } } - diff --git a/draw/draw_paint.c b/draw/draw_paint.c index 69df467a..00e6405d 100644 --- a/draw/draw_paint.c +++ b/draw/draw_paint.c @@ -75,7 +75,7 @@ typedef unsigned char byte; /* Blend a non-premultiplied color in mask over destination */ static inline void -fz_paintspancolor2(byte * restrict dp, byte * restrict mp, int w, byte *color) +fz_paint_span_with_color_2(byte * restrict dp, byte * restrict mp, int w, byte *color) { int sa = FZ_EXPAND(color[1]); int g = color[0]; @@ -90,7 +90,7 @@ fz_paintspancolor2(byte * restrict dp, byte * restrict mp, int w, byte *color) } static inline void -fz_paintspancolor4(byte * restrict dp, byte * restrict mp, int w, byte *color) +fz_paint_span_with_color_4(byte * restrict dp, byte * restrict mp, int w, byte *color) { int sa = FZ_EXPAND(color[3]); int r = color[0]; @@ -109,7 +109,7 @@ fz_paintspancolor4(byte * restrict dp, byte * restrict mp, int w, byte *color) } static inline void -fz_paintspancolorN(byte * restrict dp, byte * restrict mp, int n, int w, byte *color) +fz_paint_span_with_color_N(byte * restrict dp, byte * restrict mp, int n, int w, byte *color) { int sa = FZ_EXPAND(color[n-1]); int k; @@ -126,20 +126,20 @@ fz_paintspancolorN(byte * restrict dp, byte * restrict mp, int n, int w, byte *c } void -fz_paintspancolor(byte * restrict dp, byte * restrict mp, int n, int w, byte *color) +fz_paint_span_with_color(byte * restrict dp, byte * restrict mp, int n, int w, byte *color) { switch (n) { - case 2: fz_paintspancolor2(dp, mp, w, color); break; - case 4: fz_paintspancolor4(dp, mp, w, color); break; - default: fz_paintspancolorN(dp, mp, n, w, color); break; + case 2: fz_paint_span_with_color_2(dp, mp, w, color); break; + case 4: fz_paint_span_with_color_4(dp, mp, w, color); break; + default: fz_paint_span_with_color_N(dp, mp, n, w, color); break; } } /* Blend source in mask over destination */ static inline void -fz_paintspanmask2(byte * restrict dp, byte * restrict sp, byte * restrict mp, int w) +fz_paint_span_with_mask_2(byte * restrict dp, byte * restrict sp, byte * restrict mp, int w) { while (w--) { @@ -157,7 +157,7 @@ fz_paintspanmask2(byte * restrict dp, byte * restrict sp, byte * restrict mp, in } static inline void -fz_paintspanmask4(byte * restrict dp, byte * restrict sp, byte * restrict mp, int w) +fz_paint_span_with_mask_4(byte * restrict dp, byte * restrict sp, byte * restrict mp, int w) { while (w--) { @@ -179,7 +179,7 @@ fz_paintspanmask4(byte * restrict dp, byte * restrict sp, byte * restrict mp, in } static inline void -fz_paintspanmaskN(byte * restrict dp, byte * restrict sp, byte * restrict mp, int n, int w) +fz_paint_span_with_mask_N(byte * restrict dp, byte * restrict sp, byte * restrict mp, int n, int w) { n--; while (w--) @@ -200,20 +200,20 @@ fz_paintspanmaskN(byte * restrict dp, byte * restrict sp, byte * restrict mp, in } static void -fz_paintspanmask(byte * restrict dp, byte * restrict sp, byte * restrict mp, int n, int w) +fz_paint_span_with_mask(byte * restrict dp, byte * restrict sp, byte * restrict mp, int n, int w) { switch (n) { - case 2: fz_paintspanmask2(dp, sp, mp, w); break; - case 4: fz_paintspanmask4(dp, sp, mp, w); break; - default: fz_paintspanmaskN(dp, sp, mp, n, w); break; + case 2: fz_paint_span_with_mask_2(dp, sp, mp, w); break; + case 4: fz_paint_span_with_mask_4(dp, sp, mp, w); break; + default: fz_paint_span_with_mask_N(dp, sp, mp, n, w); break; } } /* Blend source in constant alpha over destination */ static inline void -fz_paintspan2alpha(byte * restrict dp, byte * restrict sp, int w, int alpha) +fz_paint_span_2_with_alpha(byte * restrict dp, byte * restrict sp, int w, int alpha) { alpha = FZ_EXPAND(alpha); while (w--) @@ -227,7 +227,7 @@ fz_paintspan2alpha(byte * restrict dp, byte * restrict sp, int w, int alpha) } static inline void -fz_paintspan4alpha(byte * restrict dp, byte * restrict sp, int w, int alpha) +fz_paint_span_4_with_alpha(byte * restrict dp, byte * restrict sp, int w, int alpha) { alpha = FZ_EXPAND(alpha); while (w--) @@ -245,7 +245,7 @@ fz_paintspan4alpha(byte * restrict dp, byte * restrict sp, int w, int alpha) } static inline void -fz_paintspanNalpha(byte * restrict dp, byte * restrict sp, int n, int w, int alpha) +fz_paint_span_N_with_alpha(byte * restrict dp, byte * restrict sp, int n, int w, int alpha) { alpha = FZ_EXPAND(alpha); while (w--) @@ -263,7 +263,7 @@ fz_paintspanNalpha(byte * restrict dp, byte * restrict sp, int n, int w, int alp /* Blend source over destination */ static inline void -fz_paintspan1(byte * restrict dp, byte * restrict sp, int w) +fz_paint_span_1(byte * restrict dp, byte * restrict sp, int w) { while (w--) { @@ -274,7 +274,7 @@ fz_paintspan1(byte * restrict dp, byte * restrict sp, int w) } static inline void -fz_paintspan2(byte * restrict dp, byte * restrict sp, int w) +fz_paint_span_2(byte * restrict dp, byte * restrict sp, int w) { while (w--) { @@ -287,7 +287,7 @@ fz_paintspan2(byte * restrict dp, byte * restrict sp, int w) } static inline void -fz_paintspan4(byte * restrict dp, byte * restrict sp, int w) +fz_paint_span_4(byte * restrict dp, byte * restrict sp, int w) { while (w--) { @@ -304,7 +304,7 @@ fz_paintspan4(byte * restrict dp, byte * restrict sp, int w) } static inline void -fz_paintspanN(byte * restrict dp, byte * restrict sp, int n, int w) +fz_paint_span_N(byte * restrict dp, byte * restrict sp, int n, int w) { while (w--) { @@ -319,25 +319,25 @@ fz_paintspanN(byte * restrict dp, byte * restrict sp, int n, int w) } void -fz_paintspan(byte * restrict dp, byte * restrict sp, int n, int w, int alpha) +fz_paint_span(byte * restrict dp, byte * restrict sp, int n, int w, int alpha) { if (alpha == 255) { switch (n) { - case 1: fz_paintspan1(dp, sp, w); break; - case 2: fz_paintspan2(dp, sp, w); break; - case 4: fz_paintspan4(dp, sp, w); break; - default: fz_paintspanN(dp, sp, n, w); break; + case 1: fz_paint_span_1(dp, sp, w); break; + case 2: fz_paint_span_2(dp, sp, w); break; + case 4: fz_paint_span_4(dp, sp, w); break; + default: fz_paint_span_N(dp, sp, n, w); break; } } else if (alpha > 0) { switch (n) { - case 2: fz_paintspan2alpha(dp, sp, w, alpha); break; - case 4: fz_paintspan4alpha(dp, sp, w, alpha); break; - default: fz_paintspanNalpha(dp, sp, n, w, alpha); break; + case 2: fz_paint_span_2_with_alpha(dp, sp, w, alpha); break; + case 4: fz_paint_span_4_with_alpha(dp, sp, w, alpha); break; + default: fz_paint_span_N_with_alpha(dp, sp, n, w, alpha); break; } } } @@ -347,15 +347,15 @@ fz_paintspan(byte * restrict dp, byte * restrict sp, int n, int w, int alpha) */ void -fz_paintpixmapbbox(fz_pixmap *dst, fz_pixmap *src, int alpha, fz_bbox bbox) +fz_paint_pixmap_with_rect(fz_pixmap *dst, fz_pixmap *src, int alpha, fz_bbox bbox) { unsigned char *sp, *dp; int x, y, w, h, n; assert(dst->n == src->n); - bbox = fz_intersectbbox(bbox, fz_boundpixmap(dst)); - bbox = fz_intersectbbox(bbox, fz_boundpixmap(src)); + bbox = fz_intersect_bbox(bbox, fz_bound_pixmap(dst)); + bbox = fz_intersect_bbox(bbox, fz_bound_pixmap(src)); x = bbox.x0; y = bbox.y0; @@ -370,14 +370,14 @@ fz_paintpixmapbbox(fz_pixmap *dst, fz_pixmap *src, int alpha, fz_bbox bbox) while (h--) { - fz_paintspan(dp, sp, n, w, alpha); + fz_paint_span(dp, sp, n, w, alpha); sp += src->w * n; dp += dst->w * n; } } void -fz_paintpixmap(fz_pixmap *dst, fz_pixmap *src, int alpha) +fz_paint_pixmap(fz_pixmap *dst, fz_pixmap *src, int alpha) { unsigned char *sp, *dp; fz_bbox bbox; @@ -385,8 +385,8 @@ fz_paintpixmap(fz_pixmap *dst, fz_pixmap *src, int alpha) assert(dst->n == src->n); - bbox = fz_boundpixmap(dst); - bbox = fz_intersectbbox(bbox, fz_boundpixmap(src)); + bbox = fz_bound_pixmap(dst); + bbox = fz_intersect_bbox(bbox, fz_bound_pixmap(src)); x = bbox.x0; y = bbox.y0; @@ -401,14 +401,14 @@ fz_paintpixmap(fz_pixmap *dst, fz_pixmap *src, int alpha) while (h--) { - fz_paintspan(dp, sp, n, w, alpha); + fz_paint_span(dp, sp, n, w, alpha); sp += src->w * n; dp += dst->w * n; } } void -fz_paintpixmapmask(fz_pixmap *dst, fz_pixmap *src, fz_pixmap *msk) +fz_paint_pixmap_with_mask(fz_pixmap *dst, fz_pixmap *src, fz_pixmap *msk) { unsigned char *sp, *dp, *mp; fz_bbox bbox; @@ -417,9 +417,9 @@ fz_paintpixmapmask(fz_pixmap *dst, fz_pixmap *src, fz_pixmap *msk) assert(dst->n == src->n); assert(msk->n == 1); - bbox = fz_boundpixmap(dst); - bbox = fz_intersectbbox(bbox, fz_boundpixmap(src)); - bbox = fz_intersectbbox(bbox, fz_boundpixmap(msk)); + bbox = fz_bound_pixmap(dst); + bbox = fz_intersect_bbox(bbox, fz_bound_pixmap(src)); + bbox = fz_intersect_bbox(bbox, fz_bound_pixmap(msk)); x = bbox.x0; y = bbox.y0; @@ -435,7 +435,7 @@ fz_paintpixmapmask(fz_pixmap *dst, fz_pixmap *src, fz_pixmap *msk) while (h--) { - fz_paintspanmask(dp, sp, mp, n, w); + fz_paint_span_with_mask(dp, sp, mp, n, w); sp += src->w * n; dp += dst->w * n; mp += msk->w; diff --git a/draw/draw_path.c b/draw/draw_path.c index 23ea3515..55e070c9 100644 --- a/draw/draw_path.c +++ b/draw/draw_path.c @@ -1,6 +1,6 @@ #include "fitz.h" -#define MAXDEPTH 8 +#define MAX_DEPTH 8 enum { BUTT = 0, ROUND = 1, SQUARE = 2, MITER = 0, BEVEL = 2 }; @@ -11,7 +11,7 @@ line(fz_gel *gel, fz_matrix *ctm, float x0, float y0, float x1, float y1) float ty0 = ctm->b * x0 + ctm->d * y0 + ctm->f; float tx1 = ctm->a * x1 + ctm->c * y1 + ctm->e; float ty1 = ctm->b * x1 + ctm->d * y1 + ctm->f; - fz_insertgel(gel, tx0, ty0, tx1, ty1); + fz_insert_gel(gel, tx0, ty0, tx1, ty1); } static void @@ -34,7 +34,7 @@ bezier(fz_gel *gel, fz_matrix *ctm, float flatness, dmax = MAX(dmax, ABS(ya - yb)); dmax = MAX(dmax, ABS(xd - xc)); dmax = MAX(dmax, ABS(yd - yc)); - if (dmax < flatness || depth >= MAXDEPTH) + if (dmax < flatness || depth >= MAX_DEPTH) { line(gel, ctm, xa, ya, xd, yd); return; @@ -69,7 +69,7 @@ bezier(fz_gel *gel, fz_matrix *ctm, float flatness, } void -fz_fillpath(fz_gel *gel, fz_path *path, fz_matrix ctm, float flatness) +fz_fill_path(fz_gel *gel, fz_path *path, fz_matrix ctm, float flatness) { float x1, y1, x2, y2, x3, y3; float cx = 0; @@ -80,39 +80,39 @@ fz_fillpath(fz_gel *gel, fz_path *path, fz_matrix ctm, float flatness) while (i < path->len) { - switch (path->els[i++].k) + switch (path->items[i++].k) { case FZ_MOVETO: /* implicit closepath before moveto */ if (i && (cx != bx || cy != by)) line(gel, &ctm, cx, cy, bx, by); - x1 = path->els[i++].v; - y1 = path->els[i++].v; + x1 = path->items[i++].v; + y1 = path->items[i++].v; cx = bx = x1; cy = by = y1; break; case FZ_LINETO: - x1 = path->els[i++].v; - y1 = path->els[i++].v; + x1 = path->items[i++].v; + y1 = path->items[i++].v; line(gel, &ctm, cx, cy, x1, y1); cx = x1; cy = y1; break; case FZ_CURVETO: - x1 = path->els[i++].v; - y1 = path->els[i++].v; - x2 = path->els[i++].v; - y2 = path->els[i++].v; - x3 = path->els[i++].v; - y3 = path->els[i++].v; + x1 = path->items[i++].v; + y1 = path->items[i++].v; + x2 = path->items[i++].v; + y2 = path->items[i++].v; + x3 = path->items[i++].v; + y3 = path->items[i++].v; bezier(gel, &ctm, flatness, cx, cy, x1, y1, x2, y2, x3, y3, 0); cx = x3; cy = y3; break; - case FZ_CLOSEPATH: + case FZ_CLOSE_PATH: line(gel, &ctm, cx, cy, bx, by); cx = bx; cy = by; @@ -139,9 +139,9 @@ struct sctx int sn, bn; int dot; - float *dashlist; - float dashphase; - int dashlen; + float *dash_list; + float dash_phase; + int dash_len; int toggle; int offset; float phase; @@ -149,17 +149,17 @@ struct sctx }; static void -fz_addline(struct sctx *s, float x0, float y0, float x1, float y1) +fz_add_line(struct sctx *s, float x0, float y0, float x1, float y1) { float tx0 = s->ctm->a * x0 + s->ctm->c * y0 + s->ctm->e; float ty0 = s->ctm->b * x0 + s->ctm->d * y0 + s->ctm->f; float tx1 = s->ctm->a * x1 + s->ctm->c * y1 + s->ctm->e; float ty1 = s->ctm->b * x1 + s->ctm->d * y1 + s->ctm->f; - fz_insertgel(s->gel, tx0, ty0, tx1, ty1); + fz_insert_gel(s->gel, tx0, ty0, tx1, ty1); } static void -fz_addarc(struct sctx *s, +fz_add_arc(struct sctx *s, float xc, float yc, float x0, float y0, float x1, float y1) @@ -194,12 +194,12 @@ fz_addarc(struct sctx *s, theta = th0 + (th1 - th0) * i / n; nx = cosf(theta) * r; ny = sinf(theta) * r; - fz_addline(s, xc + ox, yc + oy, xc + nx, yc + ny); + fz_add_line(s, xc + ox, yc + oy, xc + nx, yc + ny); ox = nx; oy = ny; } - fz_addline(s, xc + ox, yc + oy, xc + x1, yc + y1); + fz_add_line(s, xc + ox, yc + oy, xc + x1, yc + y1); } static void @@ -210,8 +210,8 @@ fz_linestroke(struct sctx *s, fz_point a, fz_point b) float scale = s->linewidth / sqrtf(dx * dx + dy * dy); float dlx = dy * scale; float dly = -dx * scale; - fz_addline(s, a.x - dlx, a.y - dly, b.x - dlx, b.y - dly); - fz_addline(s, b.x + dlx, b.y + dly, a.x + dlx, a.y + dly); + fz_add_line(s, a.x - dlx, a.y - dly, b.x - dlx, b.y - dly); + fz_add_line(s, b.x + dlx, b.y + dly, a.x + dlx, a.y + dly); } static void @@ -263,8 +263,8 @@ fz_linejoin(struct sctx *s, fz_point a, fz_point b, fz_point c) if (linejoin == BEVEL) { - fz_addline(s, b.x - dlx0, b.y - dly0, b.x - dlx1, b.y - dly1); - fz_addline(s, b.x + dlx1, b.y + dly1, b.x + dlx0, b.y + dly0); + fz_add_line(s, b.x - dlx0, b.y - dly0, b.x - dlx1, b.y - dly1); + fz_add_line(s, b.x + dlx1, b.y + dly1, b.x + dlx0, b.y + dly0); } if (linejoin == MITER) @@ -275,15 +275,15 @@ fz_linejoin(struct sctx *s, fz_point a, fz_point b, fz_point c) if (cross < 0) { - fz_addline(s, b.x - dlx0, b.y - dly0, b.x - dlx1, b.y - dly1); - fz_addline(s, b.x + dlx1, b.y + dly1, b.x + dmx, b.y + dmy); - fz_addline(s, b.x + dmx, b.y + dmy, b.x + dlx0, b.y + dly0); + fz_add_line(s, b.x - dlx0, b.y - dly0, b.x - dlx1, b.y - dly1); + fz_add_line(s, b.x + dlx1, b.y + dly1, b.x + dmx, b.y + dmy); + fz_add_line(s, b.x + dmx, b.y + dmy, b.x + dlx0, b.y + dly0); } else { - fz_addline(s, b.x + dlx1, b.y + dly1, b.x + dlx0, b.y + dly0); - fz_addline(s, b.x - dlx0, b.y - dly0, b.x - dmx, b.y - dmy); - fz_addline(s, b.x - dmx, b.y - dmy, b.x - dlx1, b.y - dly1); + fz_add_line(s, b.x + dlx1, b.y + dly1, b.x + dlx0, b.y + dly0); + fz_add_line(s, b.x - dlx0, b.y - dly0, b.x - dmx, b.y - dmy); + fz_add_line(s, b.x - dmx, b.y - dmy, b.x - dlx1, b.y - dly1); } } @@ -291,13 +291,13 @@ fz_linejoin(struct sctx *s, fz_point a, fz_point b, fz_point c) { if (cross < 0) { - fz_addline(s, b.x - dlx0, b.y - dly0, b.x - dlx1, b.y - dly1); - fz_addarc(s, b.x, b.y, dlx1, dly1, dlx0, dly0); + fz_add_line(s, b.x - dlx0, b.y - dly0, b.x - dlx1, b.y - dly1); + fz_add_arc(s, b.x, b.y, dlx1, dly1, dlx0, dly0); } else { - fz_addline(s, b.x + dlx1, b.y + dly1, b.x + dlx0, b.y + dly0); - fz_addarc(s, b.x, b.y, -dlx0, -dly0, -dlx1, -dly1); + fz_add_line(s, b.x + dlx1, b.y + dly1, b.x + dlx0, b.y + dly0); + fz_add_arc(s, b.x, b.y, -dlx0, -dly0, -dlx1, -dly1); } } } @@ -317,7 +317,7 @@ fz_linecap(struct sctx *s, fz_point a, fz_point b) float dly = -dx * scale; if (linecap == BUTT) - fz_addline(s, b.x - dlx, b.y - dly, b.x + dlx, b.y + dly); + fz_add_line(s, b.x - dlx, b.y - dly, b.x + dlx, b.y + dly); if (linecap == ROUND) { @@ -332,23 +332,23 @@ fz_linecap(struct sctx *s, fz_point a, fz_point b) float sth = sinf(theta); float nx = b.x - dlx * cth - dly * sth; float ny = b.y - dly * cth + dlx * sth; - fz_addline(s, ox, oy, nx, ny); + fz_add_line(s, ox, oy, nx, ny); ox = nx; oy = ny; } - fz_addline(s, ox, oy, b.x + dlx, b.y + dly); + fz_add_line(s, ox, oy, b.x + dlx, b.y + dly); } if (linecap == SQUARE) { - fz_addline(s, b.x - dlx, b.y - dly, + fz_add_line(s, b.x - dlx, b.y - dly, b.x - dlx - dly, b.y - dly + dlx); - fz_addline(s, b.x - dlx - dly, + fz_add_line(s, b.x - dlx - dly, b.y - dly + dlx, b.x + dlx - dly, b.y + dly + dlx); - fz_addline(s, b.x + dlx - dly, + fz_add_line(s, b.x + dlx - dly, b.y + dly + dlx, b.x + dlx, b.y + dly); } @@ -371,16 +371,16 @@ fz_linedot(struct sctx *s, fz_point a) float sth = sinf(theta); float nx = a.x - cth * linewidth; float ny = a.y + sth * linewidth; - fz_addline(s, ox, oy, nx, ny); + fz_add_line(s, ox, oy, nx, ny); ox = nx; oy = ny; } - fz_addline(s, ox, oy, a.x - linewidth, a.y); + fz_add_line(s, ox, oy, a.x - linewidth, a.y); } static void -fz_strokeflush(struct sctx *s) +fz_stroke_flush(struct sctx *s) { if (s->sn == 2) { @@ -394,9 +394,9 @@ fz_strokeflush(struct sctx *s) } static void -fz_strokemoveto(struct sctx *s, fz_point cur) +fz_stroke_moveto(struct sctx *s, fz_point cur) { - fz_strokeflush(s); + fz_stroke_flush(s); s->seg[0] = cur; s->beg[0] = cur; s->sn = 1; @@ -405,7 +405,7 @@ fz_strokemoveto(struct sctx *s, fz_point cur) } static void -fz_strokelineto(struct sctx *s, fz_point cur) +fz_stroke_lineto(struct sctx *s, fz_point cur) { float dx = cur.x - s->seg[s->sn-1].x; float dy = cur.y - s->seg[s->sn-1].y; @@ -432,11 +432,11 @@ fz_strokelineto(struct sctx *s, fz_point cur) } static void -fz_strokeclosepath(struct sctx *s) +fz_stroke_closepath(struct sctx *s) { if (s->sn == 2) { - fz_strokelineto(s, s->beg[0]); + fz_stroke_lineto(s, s->beg[0]); if (s->seg[1].x == s->beg[0].x && s->seg[1].y == s->beg[0].y) fz_linejoin(s, s->seg[0], s->beg[0], s->beg[1]); else @@ -454,7 +454,7 @@ fz_strokeclosepath(struct sctx *s) } static void -fz_strokebezier(struct sctx *s, +fz_stroke_bezier(struct sctx *s, float xa, float ya, float xb, float yb, float xc, float yc, @@ -473,12 +473,12 @@ fz_strokebezier(struct sctx *s, dmax = MAX(dmax, ABS(ya - yb)); dmax = MAX(dmax, ABS(xd - xc)); dmax = MAX(dmax, ABS(yd - yc)); - if (dmax < s->flatness || depth >= MAXDEPTH) + if (dmax < s->flatness || depth >= MAX_DEPTH) { fz_point p; p.x = xd; p.y = yd; - fz_strokelineto(s, p); + fz_stroke_lineto(s, p); return; } @@ -506,12 +506,12 @@ fz_strokebezier(struct sctx *s, xabcd *= 0.125f; yabcd *= 0.125f; - fz_strokebezier(s, xa, ya, xab, yab, xabc, yabc, xabcd, yabcd, depth + 1); - fz_strokebezier(s, xabcd, yabcd, xbcd, ybcd, xcd, ycd, xd, yd, depth + 1); + fz_stroke_bezier(s, xa, ya, xab, yab, xabc, yabc, xabcd, yabcd, depth + 1); + fz_stroke_bezier(s, xabcd, yabcd, xbcd, ybcd, xcd, ycd, xd, yd, depth + 1); } void -fz_strokepath(fz_gel *gel, fz_path *path, fz_strokestate *stroke, fz_matrix ctm, float flatness, float linewidth) +fz_stroke_path(fz_gel *gel, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm, float flatness, float linewidth) { struct sctx s; fz_point p0, p1, p2, p3; @@ -531,7 +531,7 @@ fz_strokepath(fz_gel *gel, fz_path *path, fz_strokestate *stroke, fz_matrix ctm, i = 0; - if (path->len > 0 && path->els[0].k != FZ_MOVETO) + if (path->len > 0 && path->items[0].k != FZ_MOVETO) { fz_warn("assert: path must begin with moveto"); return; @@ -541,66 +541,66 @@ fz_strokepath(fz_gel *gel, fz_path *path, fz_strokestate *stroke, fz_matrix ctm, while (i < path->len) { - switch (path->els[i++].k) + switch (path->items[i++].k) { case FZ_MOVETO: - p1.x = path->els[i++].v; - p1.y = path->els[i++].v; - fz_strokemoveto(&s, p1); + p1.x = path->items[i++].v; + p1.y = path->items[i++].v; + fz_stroke_moveto(&s, p1); p0 = p1; break; case FZ_LINETO: - p1.x = path->els[i++].v; - p1.y = path->els[i++].v; - fz_strokelineto(&s, p1); + p1.x = path->items[i++].v; + p1.y = path->items[i++].v; + fz_stroke_lineto(&s, p1); p0 = p1; break; case FZ_CURVETO: - p1.x = path->els[i++].v; - p1.y = path->els[i++].v; - p2.x = path->els[i++].v; - p2.y = path->els[i++].v; - p3.x = path->els[i++].v; - p3.y = path->els[i++].v; - fz_strokebezier(&s, p0.x, p0.y, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, 0); + p1.x = path->items[i++].v; + p1.y = path->items[i++].v; + p2.x = path->items[i++].v; + p2.y = path->items[i++].v; + p3.x = path->items[i++].v; + p3.y = path->items[i++].v; + fz_stroke_bezier(&s, p0.x, p0.y, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, 0); p0 = p3; break; - case FZ_CLOSEPATH: - fz_strokeclosepath(&s); + case FZ_CLOSE_PATH: + fz_stroke_closepath(&s); break; } } - fz_strokeflush(&s); + fz_stroke_flush(&s); } static void -fz_dashmoveto(struct sctx *s, fz_point a) +fz_dash_moveto(struct sctx *s, fz_point a) { s->toggle = 1; s->offset = 0; - s->phase = s->dashphase; + s->phase = s->dash_phase; - while (s->phase >= s->dashlist[s->offset]) + while (s->phase >= s->dash_list[s->offset]) { s->toggle = !s->toggle; - s->phase -= s->dashlist[s->offset]; + s->phase -= s->dash_list[s->offset]; s->offset ++; - if (s->offset == s->dashlen) + if (s->offset == s->dash_len) s->offset = 0; } s->cur = a; if (s->toggle) - fz_strokemoveto(s, a); + fz_stroke_moveto(s, a); } static void -fz_dashlineto(struct sctx *s, fz_point b) +fz_dash_lineto(struct sctx *s, fz_point b) { float dx, dy; float total, used, ratio; @@ -613,22 +613,22 @@ fz_dashlineto(struct sctx *s, fz_point b) total = sqrtf(dx * dx + dy * dy); used = 0; - while (total - used > s->dashlist[s->offset] - s->phase) + while (total - used > s->dash_list[s->offset] - s->phase) { - used += s->dashlist[s->offset] - s->phase; + used += s->dash_list[s->offset] - s->phase; ratio = used / total; m.x = a.x + ratio * dx; m.y = a.y + ratio * dy; if (s->toggle) - fz_strokelineto(s, m); + fz_stroke_lineto(s, m); else - fz_strokemoveto(s, m); + fz_stroke_moveto(s, m); s->toggle = !s->toggle; s->phase = 0; s->offset ++; - if (s->offset == s->dashlen) + if (s->offset == s->dash_len) s->offset = 0; } @@ -637,11 +637,11 @@ fz_dashlineto(struct sctx *s, fz_point b) s->cur = b; if (s->toggle) - fz_strokelineto(s, b); + fz_stroke_lineto(s, b); } static void -fz_dashbezier(struct sctx *s, +fz_dash_bezier(struct sctx *s, float xa, float ya, float xb, float yb, float xc, float yc, @@ -660,12 +660,12 @@ fz_dashbezier(struct sctx *s, dmax = MAX(dmax, ABS(ya - yb)); dmax = MAX(dmax, ABS(xd - xc)); dmax = MAX(dmax, ABS(yd - yc)); - if (dmax < s->flatness || depth >= MAXDEPTH) + if (dmax < s->flatness || depth >= MAX_DEPTH) { fz_point p; p.x = xd; p.y = yd; - fz_dashlineto(s, p); + fz_dash_lineto(s, p); return; } @@ -693,12 +693,12 @@ fz_dashbezier(struct sctx *s, xabcd *= 0.125f; yabcd *= 0.125f; - fz_dashbezier(s, xa, ya, xab, yab, xabc, yabc, xabcd, yabcd, depth + 1); - fz_dashbezier(s, xabcd, yabcd, xbcd, ybcd, xcd, ycd, xd, yd, depth + 1); + fz_dash_bezier(s, xa, ya, xab, yab, xabc, yabc, xabcd, yabcd, depth + 1); + fz_dash_bezier(s, xabcd, yabcd, xbcd, ybcd, xcd, ycd, xd, yd, depth + 1); } void -fz_dashpath(fz_gel *gel, fz_path *path, fz_strokestate *stroke, fz_matrix ctm, float flatness, float linewidth) +fz_dash_path(fz_gel *gel, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm, float flatness, float linewidth) { struct sctx s; fz_point p0, p1, p2, p3, beg; @@ -716,16 +716,16 @@ fz_dashpath(fz_gel *gel, fz_path *path, fz_strokestate *stroke, fz_matrix ctm, f s.bn = 0; s.dot = 0; - s.dashlist = stroke->dashlist; - s.dashphase = stroke->dashphase; - s.dashlen = stroke->dashlen; + s.dash_list = stroke->dash_list; + s.dash_phase = stroke->dash_phase; + s.dash_len = stroke->dash_len; s.toggle = 0; s.offset = 0; s.phase = 0; i = 0; - if (path->len > 0 && path->els[0].k != FZ_MOVETO) + if (path->len > 0 && path->items[0].k != FZ_MOVETO) { fz_warn("assert: path must begin with moveto"); return; @@ -735,39 +735,39 @@ fz_dashpath(fz_gel *gel, fz_path *path, fz_strokestate *stroke, fz_matrix ctm, f while (i < path->len) { - switch (path->els[i++].k) + switch (path->items[i++].k) { case FZ_MOVETO: - p1.x = path->els[i++].v; - p1.y = path->els[i++].v; - fz_dashmoveto(&s, p1); + p1.x = path->items[i++].v; + p1.y = path->items[i++].v; + fz_dash_moveto(&s, p1); beg = p0 = p1; break; case FZ_LINETO: - p1.x = path->els[i++].v; - p1.y = path->els[i++].v; - fz_dashlineto(&s, p1); + p1.x = path->items[i++].v; + p1.y = path->items[i++].v; + fz_dash_lineto(&s, p1); p0 = p1; break; case FZ_CURVETO: - p1.x = path->els[i++].v; - p1.y = path->els[i++].v; - p2.x = path->els[i++].v; - p2.y = path->els[i++].v; - p3.x = path->els[i++].v; - p3.y = path->els[i++].v; - fz_dashbezier(&s, p0.x, p0.y, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, 0); + p1.x = path->items[i++].v; + p1.y = path->items[i++].v; + p2.x = path->items[i++].v; + p2.y = path->items[i++].v; + p3.x = path->items[i++].v; + p3.y = path->items[i++].v; + fz_dash_bezier(&s, p0.x, p0.y, p1.x, p1.y, p2.x, p2.y, p3.x, p3.y, 0); p0 = p3; break; - case FZ_CLOSEPATH: - fz_dashlineto(&s, beg); + case FZ_CLOSE_PATH: + fz_dash_lineto(&s, beg); p0 = p1 = beg; break; } } - fz_strokeflush(&s); + fz_stroke_flush(&s); } diff --git a/draw/draw_scale.c b/draw/draw_scale.c index 6254e3e4..f66974d3 100644 --- a/draw/draw_scale.c +++ b/draw/draw_scale.c @@ -77,18 +77,18 @@ dst[j] = SUM(filter(dist[j,i] * F) * F * src[i]) */ -typedef struct fz_scalefilter_s fz_scalefilter; +typedef struct fz_scale_filter_s fz_scale_filter; -struct fz_scalefilter_s +struct fz_scale_filter_s { int width; - float (*fn)(fz_scalefilter *, float); + float (*fn)(fz_scale_filter *, float); }; /* Image scale filters */ static float -triangle(fz_scalefilter *filter, float f) +triangle(fz_scale_filter *filter, float f) { if (f >= 1) return 0; @@ -96,7 +96,7 @@ triangle(fz_scalefilter *filter, float f) } static float -box(fz_scalefilter *filter, float f) +box(fz_scale_filter *filter, float f) { if (f >= 0.5f) return 0; @@ -104,7 +104,7 @@ box(fz_scalefilter *filter, float f) } static float -simple(fz_scalefilter *filter, float x) +simple(fz_scale_filter *filter, float x) { if (x >= 1) return 0; @@ -112,7 +112,7 @@ simple(fz_scalefilter *filter, float x) } static float -lanczos2(fz_scalefilter *filter, float x) +lanczos2(fz_scale_filter *filter, float x) { if (x >= 2) return 0; @@ -120,7 +120,7 @@ lanczos2(fz_scalefilter *filter, float x) } static float -lanczos3(fz_scalefilter *filter, float f) +lanczos3(fz_scale_filter *filter, float f) { if (f >= 3) return 0; @@ -147,7 +147,7 @@ The literature suggests that B=1/3, C=1/3 is best. */ static float -mitchell(fz_scalefilter *filter, float x) +mitchell(fz_scale_filter *filter, float x) { if (x >= 2) return 0; @@ -156,12 +156,12 @@ mitchell(fz_scalefilter *filter, float x) return (16 + x*x*(-36 + 21*x))/18; } -fz_scalefilter fz_scalefilter_box = { 1, box }; -fz_scalefilter fz_scalefilter_triangle = { 1, triangle }; -fz_scalefilter fz_scalefilter_simple = { 1, simple }; -fz_scalefilter fz_scalefilter_lanczos2 = { 2, lanczos2 }; -fz_scalefilter fz_scalefilter_lanczos3 = { 3, lanczos3 }; -fz_scalefilter fz_scalefilter_mitchell = { 2, mitchell }; +fz_scale_filter fz_scale_filter_box = { 1, box }; +fz_scale_filter fz_scale_filter_triangle = { 1, triangle }; +fz_scale_filter fz_scale_filter_simple = { 1, simple }; +fz_scale_filter fz_scale_filter_lanczos2 = { 2, lanczos2 }; +fz_scale_filter fz_scale_filter_lanczos3 = { 3, lanczos3 }; +fz_scale_filter fz_scale_filter_mitchell = { 2, mitchell }; /* We build ourselves a set of tables to contain the precalculated weights @@ -256,7 +256,7 @@ struct fz_weights_s }; static fz_weights * -newweights(fz_scalefilter *filter, int src_w, float dst_w, int dst_w_i, int n, int flip) +new_weights(fz_scale_filter *filter, int src_w, float dst_w, int dst_w_i, int n, int flip) { int max_len; fz_weights *weights; @@ -314,7 +314,7 @@ init_weights(fz_weights *weights, int j) } static void -add_weight(fz_weights *weights, int j, int i, fz_scalefilter *filter, +add_weight(fz_weights *weights, int j, int i, fz_scale_filter *filter, float x, float F, float G, int src_w, float dst_w) { float dist = j - x + 0.5f - ((i + 0.5f)*dst_w/src_w); @@ -474,7 +474,7 @@ check_weights(fz_weights *weights, int j, int w) } static fz_weights * -make_weights(int src_w, float x, float dst_w, fz_scalefilter *filter, int vertical, int dst_w_int, int n, int flip) +make_weights(int src_w, float x, float dst_w, fz_scale_filter *filter, int vertical, int dst_w_int, int n, int flip) { fz_weights *weights; float F, G; @@ -495,7 +495,7 @@ make_weights(int src_w, float x, float dst_w, fz_scalefilter *filter, int vertic } window = filter->width / F; DBUG(("make_weights src_w=%d x=%g dst_w=%g dst_w_int=%d F=%g window=%g\n", src_w, x, dst_w, dst_w_int, F, window)); - weights = newweights(filter, src_w, dst_w, dst_w_int, n, flip); + weights = new_weights(filter, src_w, dst_w, dst_w_int, n, flip); if (weights == NULL) return NULL; for (j = 0; j < dst_w_int; j++) @@ -841,7 +841,7 @@ scale_single_row(unsigned char *dst, unsigned char *src, fz_weights *weights, in { int *contrib = &weights->index[weights->index[0]]; int min, len, i, j, val, n; - int tmp[FZ_MAXCOLORS]; + int tmp[FZ_MAX_COLORS]; n = weights->n; /* Scale a single row */ @@ -914,7 +914,7 @@ scale_single_col(unsigned char *dst, unsigned char *src, fz_weights *weights, in { int *contrib = &weights->index[weights->index[0]]; int min, len, i, j, val; - int tmp[FZ_MAXCOLORS]; + int tmp[FZ_MAX_COLORS]; if (flip_y) { @@ -989,9 +989,9 @@ scale_single_col(unsigned char *dst, unsigned char *src, fz_weights *weights, in #endif /* SINGLE_PIXEL_SPECIALS */ fz_pixmap * -fz_scalepixmap(fz_pixmap *src, float x, float y, float w, float h) +fz_scale_pixmap(fz_pixmap *src, float x, float y, float w, float h) { - fz_scalefilter *filter = &fz_scalefilter_simple; + fz_scale_filter *filter = &fz_scale_filter_simple; fz_weights *contrib_rows = NULL; fz_weights *contrib_cols = NULL; fz_pixmap *output = NULL; @@ -1090,7 +1090,7 @@ fz_scalepixmap(fz_pixmap *src, float x, float y, float w, float h) assert(contrib_cols == NULL || contrib_cols->count == dst_w_int); assert(contrib_rows == NULL || contrib_rows->count == dst_h_int); - output = fz_newpixmap(src->colorspace, dst_x_int, dst_y_int, dst_w_int, dst_h_int); + output = fz_new_pixmap(src->colorspace, dst_x_int, dst_y_int, dst_w_int, dst_h_int); if (output == NULL) goto cleanup; diff --git a/draw/draw_unpack.c b/draw/draw_unpack.c index 2c7cb452..b60de3b8 100644 --- a/draw/draw_unpack.c +++ b/draw/draw_unpack.c @@ -8,13 +8,13 @@ #define get8(buf,x) (buf[x]) #define get16(buf,x) (buf[x << 1]) -static unsigned char get1tab1[256][8]; -static unsigned char get1tab1p[256][16]; -static unsigned char get1tab255[256][8]; -static unsigned char get1tab255p[256][16]; +static unsigned char get1_tab_1[256][8]; +static unsigned char get1_tab_1p[256][16]; +static unsigned char get1_tab_255[256][8]; +static unsigned char get1_tab_255p[256][16]; static void -initget1tables(void) +init_get1_tables(void) { static int once = 0; unsigned char bits[1]; @@ -32,13 +32,13 @@ initget1tables(void) { x = get1(bits, k); - get1tab1[i][k] = x; - get1tab1p[i][k * 2] = x; - get1tab1p[i][k * 2 + 1] = 255; + get1_tab_1[i][k] = x; + get1_tab_1p[i][k * 2] = x; + get1_tab_1p[i][k * 2 + 1] = 255; - get1tab255[i][k] = x * 255; - get1tab255p[i][k * 2] = x * 255; - get1tab255p[i][k * 2 + 1] = 255; + get1_tab_255[i][k] = x * 255; + get1_tab_255p[i][k * 2] = x * 255; + get1_tab_255p[i][k * 2 + 1] = 255; } } @@ -46,7 +46,7 @@ initget1tables(void) } void -fz_unpacktile(fz_pixmap *dst, unsigned char * restrict src, int n, int depth, int stride, int scale) +fz_unpack_tile(fz_pixmap *dst, unsigned char * restrict src, int n, int depth, int stride, int scale) { int pad, x, y, k; int w = dst->w; @@ -56,7 +56,7 @@ fz_unpacktile(fz_pixmap *dst, unsigned char * restrict src, int n, int depth, in pad = 255; if (depth == 1) - initget1tables(); + init_get1_tables(); if (scale == 0) { @@ -80,12 +80,12 @@ fz_unpacktile(fz_pixmap *dst, unsigned char * restrict src, int n, int depth, in int w3 = w >> 3; for (x = 0; x < w3; x++) { - memcpy(dp, get1tab1[*sp++], 8); + memcpy(dp, get1_tab_1[*sp++], 8); dp += 8; } x = x << 3; if (x < w) - memcpy(dp, get1tab1[*sp], w - x); + memcpy(dp, get1_tab_1[*sp], w - x); } else if (n == 1 && depth == 1 && scale == 255 && !pad) @@ -93,12 +93,12 @@ fz_unpacktile(fz_pixmap *dst, unsigned char * restrict src, int n, int depth, in int w3 = w >> 3; for (x = 0; x < w3; x++) { - memcpy(dp, get1tab255[*sp++], 8); + memcpy(dp, get1_tab_255[*sp++], 8); dp += 8; } x = x << 3; if (x < w) - memcpy(dp, get1tab255[*sp], w - x); + memcpy(dp, get1_tab_255[*sp], w - x); } else if (n == 1 && depth == 1 && scale == 1 && pad) @@ -106,12 +106,12 @@ fz_unpacktile(fz_pixmap *dst, unsigned char * restrict src, int n, int depth, in int w3 = w >> 3; for (x = 0; x < w3; x++) { - memcpy(dp, get1tab1p[*sp++], 16); + memcpy(dp, get1_tab_1p[*sp++], 16); dp += 16; } x = x << 3; if (x < w) - memcpy(dp, get1tab1p[*sp], (w - x) << 1); + memcpy(dp, get1_tab_1p[*sp], (w - x) << 1); } else if (n == 1 && depth == 1 && scale == 255 && pad) @@ -119,12 +119,12 @@ fz_unpacktile(fz_pixmap *dst, unsigned char * restrict src, int n, int depth, in int w3 = w >> 3; for (x = 0; x < w3; x++) { - memcpy(dp, get1tab255p[*sp++], 16); + memcpy(dp, get1_tab_255p[*sp++], 16); dp += 16; } x = x << 3; if (x < w) - memcpy(dp, get1tab255p[*sp], (w - x) << 1); + memcpy(dp, get1_tab_255p[*sp], (w - x) << 1); } else if (depth == 8 && !pad) @@ -171,10 +171,10 @@ fz_unpacktile(fz_pixmap *dst, unsigned char * restrict src, int n, int depth, in /* Apply decode array */ void -fz_decodeindexedtile(fz_pixmap *pix, float *decode, int maxval) +fz_decode_indexed_tile(fz_pixmap *pix, float *decode, int maxval) { - int add[FZ_MAXCOLORS]; - int mul[FZ_MAXCOLORS]; + int add[FZ_MAX_COLORS]; + int mul[FZ_MAX_COLORS]; unsigned char *p = pix->samples; int len = pix->w * pix->h; int n = pix->n - 1; @@ -203,10 +203,10 @@ fz_decodeindexedtile(fz_pixmap *pix, float *decode, int maxval) } void -fz_decodetile(fz_pixmap *pix, float *decode) +fz_decode_tile(fz_pixmap *pix, float *decode) { - int add[FZ_MAXCOLORS]; - int mul[FZ_MAXCOLORS]; + int add[FZ_MAX_COLORS]; + int mul[FZ_MAX_COLORS]; unsigned char *p = pix->samples; int len = pix->w * pix->h; int n = MAX(1, pix->n - 1); diff --git a/fitz/base_error.c b/fitz/base_error.c index 7b21d691..a0efa290 100644 --- a/fitz/base_error.c +++ b/fitz/base_error.c @@ -1,159 +1,159 @@ #include "fitz.h" -enum { LINELEN = 160, LINECOUNT = 25 }; +enum { LINE_LEN = 160, LINE_COUNT = 25 }; -static char warnmessage[LINELEN] = ""; -static int warncount = 0; +static char warn_message[LINE_LEN] = ""; +static int warn_count = 0; -void fz_flushwarnings(void) +void fz_flush_warnings(void) { - if (warncount > 1) - fprintf(stderr, "warning: ... repeated %d times ...\n", warncount); - warnmessage[0] = 0; - warncount = 0; + if (warn_count > 1) + fprintf(stderr, "warning: ... repeated %d times ...\n", warn_count); + warn_message[0] = 0; + warn_count = 0; } void fz_warn(char *fmt, ...) { va_list ap; - char buf[LINELEN]; + char buf[LINE_LEN]; va_start(ap, fmt); vsnprintf(buf, sizeof buf, fmt, ap); va_end(ap); - if (!strcmp(buf, warnmessage)) + if (!strcmp(buf, warn_message)) { - warncount++; + warn_count++; } else { - fz_flushwarnings(); + fz_flush_warnings(); fprintf(stderr, "warning: %s\n", buf); - fz_strlcpy(warnmessage, buf, sizeof warnmessage); - warncount = 1; + fz_strlcpy(warn_message, buf, sizeof warn_message); + warn_count = 1; } } -static char errormessage[LINECOUNT][LINELEN]; -static int errorcount = 0; +static char error_message[LINE_COUNT][LINE_LEN]; +static int error_count = 0; static void -fz_emiterror(char what, char *location, char *message) +fz_emit_error(char what, char *location, char *message) { - fz_flushwarnings(); + fz_flush_warnings(); fprintf(stderr, "%c %s%s\n", what, location, message); - if (errorcount < LINECOUNT) + if (error_count < LINE_COUNT) { - fz_strlcpy(errormessage[errorcount], location, LINELEN); - fz_strlcat(errormessage[errorcount], message, LINELEN); - errorcount++; + fz_strlcpy(error_message[error_count], location, LINE_LEN); + fz_strlcat(error_message[error_count], message, LINE_LEN); + error_count++; } } int -fz_geterrorcount(void) +fz_get_error_count(void) { - return errorcount; + return error_count; } char * -fz_geterrorline(int n) +fz_get_error_line(int n) { - return errormessage[n]; + return error_message[n]; } fz_error -fz_throwimp(const char *file, int line, const char *func, char *fmt, ...) +fz_throw_imp(const char *file, int line, const char *func, char *fmt, ...) { va_list ap; - char one[LINELEN], two[LINELEN]; + char one[LINE_LEN], two[LINE_LEN]; - errorcount = 0; + error_count = 0; snprintf(one, sizeof one, "%s:%d: %s(): ", file, line, func); va_start(ap, fmt); vsnprintf(two, sizeof two, fmt, ap); va_end(ap); - fz_emiterror('+', one, two); + fz_emit_error('+', one, two); return -1; } fz_error -fz_rethrowimp(const char *file, int line, const char *func, fz_error cause, char *fmt, ...) +fz_rethrow_imp(const char *file, int line, const char *func, fz_error cause, char *fmt, ...) { va_list ap; - char one[LINELEN], two[LINELEN]; + char one[LINE_LEN], two[LINE_LEN]; snprintf(one, sizeof one, "%s:%d: %s(): ", file, line, func); va_start(ap, fmt); vsnprintf(two, sizeof two, fmt, ap); va_end(ap); - fz_emiterror('|', one, two); + fz_emit_error('|', one, two); return cause; } void -fz_catchimp(const char *file, int line, const char *func, fz_error cause, char *fmt, ...) +fz_catch_imp(const char *file, int line, const char *func, fz_error cause, char *fmt, ...) { va_list ap; - char one[LINELEN], two[LINELEN]; + char one[LINE_LEN], two[LINE_LEN]; snprintf(one, sizeof one, "%s:%d: %s(): ", file, line, func); va_start(ap, fmt); vsnprintf(two, sizeof two, fmt, ap); va_end(ap); - fz_emiterror('\\', one, two); + fz_emit_error('\\', one, two); } fz_error -fz_throwimpx(char *fmt, ...) +fz_throw_impx(char *fmt, ...) { va_list ap; - char buf[LINELEN]; + char buf[LINE_LEN]; - errorcount = 0; + error_count = 0; va_start(ap, fmt); vsnprintf(buf, sizeof buf, fmt, ap); va_end(ap); - fz_emiterror('+', "", buf); + fz_emit_error('+', "", buf); return -1; } fz_error -fz_rethrowimpx(fz_error cause, char *fmt, ...) +fz_rethrow_impx(fz_error cause, char *fmt, ...) { va_list ap; - char buf[LINELEN]; + char buf[LINE_LEN]; va_start(ap, fmt); vsnprintf(buf, sizeof buf, fmt, ap); va_end(ap); - fz_emiterror('|', "", buf); + fz_emit_error('|', "", buf); return cause; } void -fz_catchimpx(fz_error cause, char *fmt, ...) +fz_catch_impx(fz_error cause, char *fmt, ...) { va_list ap; - char buf[LINELEN]; + char buf[LINE_LEN]; va_start(ap, fmt); vsnprintf(buf, sizeof buf, fmt, ap); va_end(ap); - fz_emiterror('\\', "", buf); + fz_emit_error('\\', "", buf); } diff --git a/fitz/base_geometry.c b/fitz/base_geometry.c index 311221e0..bd333dfa 100644 --- a/fitz/base_geometry.c +++ b/fitz/base_geometry.c @@ -85,7 +85,7 @@ fz_translate(float tx, float ty) } fz_matrix -fz_invertmatrix(fz_matrix src) +fz_invert_matrix(fz_matrix src) { fz_matrix dst; float rdet = 1 / (src.a * src.d - src.b * src.c); @@ -99,20 +99,20 @@ fz_invertmatrix(fz_matrix src) } int -fz_isrectilinear(fz_matrix m) +fz_is_rectilinear(fz_matrix m) { return (fabsf(m.b) < FLT_EPSILON && fabsf(m.c) < FLT_EPSILON) || (fabsf(m.a) < FLT_EPSILON && fabsf(m.d) < FLT_EPSILON); } float -fz_matrixexpansion(fz_matrix m) +fz_matrix_expansion(fz_matrix m) { return sqrtf(fabsf(m.a * m.d - m.b * m.c)); } fz_point -fz_transformpoint(fz_matrix m, fz_point p) +fz_transform_point(fz_matrix m, fz_point p) { fz_point t; t.x = p.x * m.a + p.y * m.c + m.e; @@ -121,7 +121,7 @@ fz_transformpoint(fz_matrix m, fz_point p) } fz_point -fz_transformvector(fz_matrix m, fz_point p) +fz_transform_vector(fz_matrix m, fz_point p) { fz_point t; t.x = p.x * m.a + p.y * m.c; @@ -131,16 +131,16 @@ fz_transformvector(fz_matrix m, fz_point p) /* Rectangles and bounding boxes */ -const fz_rect fz_infiniterect = { 1, 1, -1, -1 }; -const fz_rect fz_emptyrect = { 0, 0, 0, 0 }; -const fz_rect fz_unitrect = { 0, 0, 1, 1 }; +const fz_rect fz_infinite_rect = { 1, 1, -1, -1 }; +const fz_rect fz_empty_rect = { 0, 0, 0, 0 }; +const fz_rect fz_unit_rect = { 0, 0, 1, 1 }; -const fz_bbox fz_infinitebbox = { 1, 1, -1, -1 }; -const fz_bbox fz_emptybbox = { 0, 0, 0, 0 }; -const fz_bbox fz_unitbbox = { 0, 0, 1, 1 }; +const fz_bbox fz_infinite_bbox = { 1, 1, -1, -1 }; +const fz_bbox fz_empty_bbox = { 0, 0, 0, 0 }; +const fz_bbox fz_unit_bbox = { 0, 0, 1, 1 }; fz_bbox -fz_roundrect(fz_rect f) +fz_round_rect(fz_rect f) { fz_bbox i; i.x0 = floorf(f.x0 + 0.001f); /* adjust by 0.001 to compensate for precision errors */ @@ -151,28 +151,28 @@ fz_roundrect(fz_rect f) } fz_bbox -fz_intersectbbox(fz_bbox a, fz_bbox b) +fz_intersect_bbox(fz_bbox a, fz_bbox b) { fz_bbox r; - if (fz_isinfiniterect(a)) return b; - if (fz_isinfiniterect(b)) return a; - if (fz_isemptyrect(a)) return fz_emptybbox; - if (fz_isemptyrect(b)) return fz_emptybbox; + if (fz_is_infinite_rect(a)) return b; + if (fz_is_infinite_rect(b)) return a; + if (fz_is_empty_rect(a)) return fz_empty_bbox; + if (fz_is_empty_rect(b)) return fz_empty_bbox; r.x0 = MAX(a.x0, b.x0); r.y0 = MAX(a.y0, b.y0); r.x1 = MIN(a.x1, b.x1); r.y1 = MIN(a.y1, b.y1); - return (r.x1 < r.x0 || r.y1 < r.y0) ? fz_emptybbox : r; + return (r.x1 < r.x0 || r.y1 < r.y0) ? fz_empty_bbox : r; } fz_bbox -fz_unionbbox(fz_bbox a, fz_bbox b) +fz_union_bbox(fz_bbox a, fz_bbox b) { fz_bbox r; - if (fz_isinfiniterect(a)) return a; - if (fz_isinfiniterect(b)) return b; - if (fz_isemptyrect(a)) return b; - if (fz_isemptyrect(b)) return a; + if (fz_is_infinite_rect(a)) return a; + if (fz_is_infinite_rect(b)) return b; + if (fz_is_empty_rect(a)) return b; + if (fz_is_empty_rect(b)) return a; r.x0 = MIN(a.x0, b.x0); r.y0 = MIN(a.y0, b.y0); r.x1 = MAX(a.x1, b.x1); @@ -181,21 +181,21 @@ fz_unionbbox(fz_bbox a, fz_bbox b) } fz_rect -fz_transformrect(fz_matrix m, fz_rect r) +fz_transform_rect(fz_matrix m, fz_rect r) { fz_point s, t, u, v; - if (fz_isinfiniterect(r)) + if (fz_is_infinite_rect(r)) return r; s.x = r.x0; s.y = r.y0; t.x = r.x0; t.y = r.y1; u.x = r.x1; u.y = r.y1; v.x = r.x1; v.y = r.y0; - s = fz_transformpoint(m, s); - t = fz_transformpoint(m, t); - u = fz_transformpoint(m, u); - v = fz_transformpoint(m, v); + s = fz_transform_point(m, s); + t = fz_transform_point(m, t); + u = fz_transform_point(m, u); + v = fz_transform_point(m, v); r.x0 = MIN4(s.x, t.x, u.x, v.x); r.y0 = MIN4(s.y, t.y, u.y, v.y); r.x1 = MAX4(s.x, t.x, u.x, v.x); @@ -204,21 +204,21 @@ fz_transformrect(fz_matrix m, fz_rect r) } fz_bbox -fz_transformbbox(fz_matrix m, fz_bbox b) +fz_transform_bbox(fz_matrix m, fz_bbox b) { fz_point s, t, u, v; - if (fz_isinfinitebbox(b)) + if (fz_is_infinite_bbox(b)) return b; s.x = b.x0; s.y = b.y0; t.x = b.x0; t.y = b.y1; u.x = b.x1; u.y = b.y1; v.x = b.x1; v.y = b.y0; - s = fz_transformpoint(m, s); - t = fz_transformpoint(m, t); - u = fz_transformpoint(m, u); - v = fz_transformpoint(m, v); + s = fz_transform_point(m, s); + t = fz_transform_point(m, t); + u = fz_transform_point(m, u); + v = fz_transform_point(m, v); b.x0 = MIN4(s.x, t.x, u.x, v.x); b.y0 = MIN4(s.y, t.y, u.y, v.y); b.x1 = MAX4(s.x, t.x, u.x, v.x); diff --git a/fitz/base_hash.c b/fitz/base_hash.c index e2bf6b04..fcfc1f61 100644 --- a/fitz/base_hash.c +++ b/fitz/base_hash.c @@ -8,21 +8,21 @@ exhibiting bad behaviour if entries are inserted and removed frequently. */ -enum { MAXKEYLEN = 48 }; -typedef struct fz_hashentry_s fz_hashentry; +enum { MAX_KEY_LEN = 48 }; +typedef struct fz_hash_entry_s fz_hash_entry; -struct fz_hashentry_s +struct fz_hash_entry_s { - unsigned char key[MAXKEYLEN]; + unsigned char key[MAX_KEY_LEN]; void *val; }; -struct fz_hashtable_s +struct fz_hash_table_s { int keylen; int size; int load; - fz_hashentry *ents; + fz_hash_entry *ents; }; static unsigned hash(unsigned char *s, int len) @@ -41,59 +41,59 @@ static unsigned hash(unsigned char *s, int len) return val; } -fz_hashtable * -fz_newhash(int initialsize, int keylen) +fz_hash_table * +fz_new_hash_table(int initialsize, int keylen) { - fz_hashtable *table; + fz_hash_table *table; - assert(keylen <= MAXKEYLEN); + assert(keylen <= MAX_KEY_LEN); - table = fz_malloc(sizeof(fz_hashtable)); + table = fz_malloc(sizeof(fz_hash_table)); table->keylen = keylen; table->size = initialsize; table->load = 0; - table->ents = fz_calloc(table->size, sizeof(fz_hashentry)); - memset(table->ents, 0, sizeof(fz_hashentry) * table->size); + table->ents = fz_calloc(table->size, sizeof(fz_hash_entry)); + memset(table->ents, 0, sizeof(fz_hash_entry) * table->size); return table; } void -fz_emptyhash(fz_hashtable *table) +fz_empty_hash(fz_hash_table *table) { table->load = 0; - memset(table->ents, 0, sizeof(fz_hashentry) * table->size); + memset(table->ents, 0, sizeof(fz_hash_entry) * table->size); } int -fz_hashlen(fz_hashtable *table) +fz_hash_len(fz_hash_table *table) { return table->size; } void * -fz_hashgetkey(fz_hashtable *table, int idx) +fz_hash_get_key(fz_hash_table *table, int idx) { return table->ents[idx].key; } void * -fz_hashgetval(fz_hashtable *table, int idx) +fz_hash_get_val(fz_hash_table *table, int idx) { return table->ents[idx].val; } void -fz_freehash(fz_hashtable *table) +fz_free_hash(fz_hash_table *table) { fz_free(table->ents); fz_free(table); } static void -fz_resizehash(fz_hashtable *table, int newsize) +fz_resize_hash(fz_hash_table *table, int newsize) { - fz_hashentry *oldents = table->ents; + fz_hash_entry *oldents = table->ents; int oldsize = table->size; int oldload = table->load; int i; @@ -104,8 +104,8 @@ fz_resizehash(fz_hashtable *table, int newsize) return; } - table->ents = fz_calloc(newsize, sizeof(fz_hashentry)); - memset(table->ents, 0, sizeof(fz_hashentry) * newsize); + table->ents = fz_calloc(newsize, sizeof(fz_hash_entry)); + memset(table->ents, 0, sizeof(fz_hash_entry) * newsize); table->size = newsize; table->load = 0; @@ -113,7 +113,7 @@ fz_resizehash(fz_hashtable *table, int newsize) { if (oldents[i].val) { - fz_hashinsert(table, oldents[i].key, oldents[i].val); + fz_hash_insert(table, oldents[i].key, oldents[i].val); } } @@ -121,16 +121,16 @@ fz_resizehash(fz_hashtable *table, int newsize) } void * -fz_hashfind(fz_hashtable *table, void *key) +fz_hash_find(fz_hash_table *table, void *key) { - fz_hashentry *ents = table->ents; + fz_hash_entry *ents = table->ents; unsigned size = table->size; unsigned pos = hash(key, table->keylen) % size; while (1) { if (!ents[pos].val) - return nil; + return NULL; if (memcmp(key, ents[pos].key, table->keylen) == 0) return ents[pos].val; @@ -140,15 +140,15 @@ fz_hashfind(fz_hashtable *table, void *key) } void -fz_hashinsert(fz_hashtable *table, void *key, void *val) +fz_hash_insert(fz_hash_table *table, void *key, void *val) { - fz_hashentry *ents; + fz_hash_entry *ents; unsigned size; unsigned pos; if (table->load > table->size * 8 / 10) { - fz_resizehash(table, table->size * 2); + fz_resize_hash(table, table->size * 2); } ents = table->ents; @@ -173,9 +173,9 @@ fz_hashinsert(fz_hashtable *table, void *key, void *val) } void -fz_hashremove(fz_hashtable *table, void *key) +fz_hash_remove(fz_hash_table *table, void *key) { - fz_hashentry *ents = table->ents; + fz_hash_entry *ents = table->ents; unsigned size = table->size; unsigned pos = hash(key, table->keylen) % size; unsigned hole, look, code; @@ -190,7 +190,7 @@ fz_hashremove(fz_hashtable *table, void *key) if (memcmp(key, ents[pos].key, table->keylen) == 0) { - ents[pos].val = nil; + ents[pos].val = NULL; hole = pos; look = (hole + 1) % size; @@ -203,7 +203,7 @@ fz_hashremove(fz_hashtable *table, void *key) (hole < look && look < code)) { ents[hole] = ents[look]; - ents[look].val = nil; + ents[look].val = NULL; hole = look; } @@ -220,7 +220,7 @@ fz_hashremove(fz_hashtable *table, void *key) } void -fz_debughash(fz_hashtable *table) +fz_debug_hash(fz_hash_table *table) { int i, k; @@ -233,7 +233,7 @@ fz_debughash(fz_hashtable *table) else { printf("table % 4d: key=", i); - for (k = 0; k < MAXKEYLEN; k++) + for (k = 0; k < MAX_KEY_LEN; k++) printf("%02x", ((char*)table->ents[i].key)[k]); printf(" val=$%p\n", table->ents[i].val); } diff --git a/fitz/base_memory.c b/fitz/base_memory.c index caeee451..f1b668eb 100644 --- a/fitz/base_memory.c +++ b/fitz/base_memory.c @@ -53,7 +53,7 @@ fz_realloc(void *p, int count, int size) } np = realloc(p, count * size); - if (np == nil) + if (np == NULL) { fprintf(stderr, "fatal error: out of memory\n"); abort(); diff --git a/fitz/base_string.c b/fitz/base_string.c index 30d544d5..72a7a556 100644 --- a/fitz/base_string.c +++ b/fitz/base_string.c @@ -1,7 +1,7 @@ #include "fitz.h" int -fz_isbigendian(void) +fz_is_big_endian(void) { static const int one = 1; return *(char*)&one == 0; @@ -11,8 +11,8 @@ char * fz_strsep(char **stringp, const char *delim) { char *ret = *stringp; - if (ret == nil) return nil; - if ((*stringp = strpbrk(*stringp, delim)) != nil) + if (ret == NULL) return NULL; + if ((*stringp = strpbrk(*stringp, delim)) != NULL) *((*stringp)++) = '\0'; return ret; } diff --git a/fitz/crypt_arc4.c b/fitz/crypt_arc4.c index 1db8a132..72871386 100644 --- a/fitz/crypt_arc4.c +++ b/fitz/crypt_arc4.c @@ -24,7 +24,7 @@ #include "fitz.h" void -fz_arc4init(fz_arc4 *arc4, const unsigned char *key, const unsigned keylen) +fz_arc4_init(fz_arc4 *arc4, const unsigned char *key, const unsigned keylen) { unsigned int t, u; unsigned int keyindex; @@ -62,7 +62,7 @@ fz_arc4init(fz_arc4 *arc4, const unsigned char *key, const unsigned keylen) } static unsigned char -fz_arc4next(fz_arc4 *arc4) +fz_arc4_next(fz_arc4 *arc4) { unsigned int x; unsigned int y; @@ -86,13 +86,13 @@ fz_arc4next(fz_arc4 *arc4) } void -fz_arc4encrypt(fz_arc4 *arc4, unsigned char *dest, const unsigned char *src, const unsigned len) +fz_arc4_encrypt(fz_arc4 *arc4, unsigned char *dest, const unsigned char *src, const unsigned len) { unsigned int i; for (i = 0; i < len; i++) { unsigned char x; - x = fz_arc4next(arc4); + x = fz_arc4_next(arc4); dest[i] = src[i] ^ x; } } diff --git a/fitz/crypt_md5.c b/fitz/crypt_md5.c index 6e38f416..ba2571c4 100644 --- a/fitz/crypt_md5.c +++ b/fitz/crypt_md5.c @@ -196,7 +196,7 @@ static void transform(unsigned int state[4], const unsigned char block[64]) } /* MD5 initialization. Begins an MD5 operation, writing a new context. */ -void fz_md5init(fz_md5 *context) +void fz_md5_init(fz_md5 *context) { context->count[0] = context->count[1] = 0; @@ -210,7 +210,7 @@ void fz_md5init(fz_md5 *context) /* MD5 block update operation. Continues an MD5 message-digest operation, * processing another message block, and updating the context. */ -void fz_md5update(fz_md5 *context, const unsigned char *input, const unsigned inlen) +void fz_md5_update(fz_md5 *context, const unsigned char *input, const unsigned inlen) { unsigned i, index, partlen; @@ -248,7 +248,7 @@ void fz_md5update(fz_md5 *context, const unsigned char *input, const unsigned in /* MD5 finalization. Ends an MD5 message-digest operation, writing the * the message digest and zeroizing the context. */ -void fz_md5final(fz_md5 *context, unsigned char digest[16]) +void fz_md5_final(fz_md5 *context, unsigned char digest[16]) { unsigned char bits[8]; unsigned index, padlen; @@ -259,10 +259,10 @@ void fz_md5final(fz_md5 *context, unsigned char digest[16]) /* Pad out to 56 mod 64 */ index = (unsigned)((context->count[0] >> 3) & 0x3f); padlen = index < 56 ? 56 - index : 120 - index; - fz_md5update(context, padding, padlen); + fz_md5_update(context, padding, padlen); /* Append length (before padding) */ - fz_md5update(context, bits, 8); + fz_md5_update(context, bits, 8); /* Store state in digest */ encode(digest, context->state, 16); diff --git a/fitz/crypt_sha2.c b/fitz/crypt_sha2.c index 6796c5ab..f17146c6 100644 --- a/fitz/crypt_sha2.c +++ b/fitz/crypt_sha2.c @@ -110,7 +110,7 @@ transform(unsigned int state[8], const unsigned int data_xe[16]) state[7] += h(0); } -void fz_sha256init(fz_sha256 *context) +void fz_sha256_init(fz_sha256 *context) { context->count[0] = context->count[1] = 0; @@ -124,7 +124,7 @@ void fz_sha256init(fz_sha256 *context) context->state[7] = 0x5BE0CD19; } -void fz_sha256update(fz_sha256 *context, const unsigned char *input, unsigned int inlen) +void fz_sha256_update(fz_sha256 *context, const unsigned char *input, unsigned int inlen) { /* Copy the input data into a properly aligned temporary buffer. * This way we can be called with arbitrarily sized buffers @@ -151,7 +151,7 @@ void fz_sha256update(fz_sha256 *context, const unsigned char *input, unsigned in } } -void fz_sha256final(fz_sha256 *context, unsigned char digest[32]) +void fz_sha256_final(fz_sha256 *context, unsigned char digest[32]) { /* Add padding as described in RFC 3174 (it describes SHA-1 but * the same padding style is used for SHA-256 too). */ diff --git a/fitz/dev_bbox.c b/fitz/dev_bbox.c index f6028f44..0f2f3cfe 100644 --- a/fitz/dev_bbox.c +++ b/fitz/dev_bbox.c @@ -2,95 +2,95 @@ /* TODO: add clip stack and use to intersect bboxes */ -typedef struct fz_bboxdevice_s fz_bboxdevice; +typedef struct fz_bbox_device_s fz_bbox_device; -struct fz_bboxdevice_s +struct fz_bbox_device_s { fz_bbox *bbox; }; static void -fz_bboxfillpath(void *user, fz_path *path, int evenodd, fz_matrix ctm, +fz_bbox_fill_path(void *user, fz_path *path, int even_odd, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { - fz_bboxdevice *bdev = user; - fz_bbox bbox = fz_roundrect(fz_boundpath(path, nil, ctm)); - *bdev->bbox = fz_unionbbox(*bdev->bbox, bbox); + fz_bbox_device *bdev = user; + fz_bbox bbox = fz_round_rect(fz_bound_path(path, NULL, ctm)); + *bdev->bbox = fz_union_bbox(*bdev->bbox, bbox); } static void -fz_bboxstrokepath(void *user, fz_path *path, fz_strokestate *stroke, fz_matrix ctm, +fz_bbox_stroke_path(void *user, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { - fz_bboxdevice *bdev = user; - fz_bbox bbox = fz_roundrect(fz_boundpath(path, stroke, ctm)); - *bdev->bbox = fz_unionbbox(*bdev->bbox, bbox); + fz_bbox_device *bdev = user; + fz_bbox bbox = fz_round_rect(fz_bound_path(path, stroke, ctm)); + *bdev->bbox = fz_union_bbox(*bdev->bbox, bbox); } static void -fz_bboxfilltext(void *user, fz_text *text, fz_matrix ctm, +fz_bbox_fill_text(void *user, fz_text *text, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { - fz_bboxdevice *bdev = user; - fz_bbox bbox = fz_roundrect(fz_boundtext(text, ctm)); - *bdev->bbox = fz_unionbbox(*bdev->bbox, bbox); + fz_bbox_device *bdev = user; + fz_bbox bbox = fz_round_rect(fz_bound_text(text, ctm)); + *bdev->bbox = fz_union_bbox(*bdev->bbox, bbox); } static void -fz_bboxstroketext(void *user, fz_text *text, fz_strokestate *stroke, fz_matrix ctm, +fz_bbox_stroke_text(void *user, fz_text *text, fz_stroke_state *stroke, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { - fz_bboxdevice *bdev = user; - fz_bbox bbox = fz_roundrect(fz_boundtext(text, ctm)); - *bdev->bbox = fz_unionbbox(*bdev->bbox, bbox); + fz_bbox_device *bdev = user; + fz_bbox bbox = fz_round_rect(fz_bound_text(text, ctm)); + *bdev->bbox = fz_union_bbox(*bdev->bbox, bbox); } static void -fz_bboxfillshade(void *user, fz_shade *shade, fz_matrix ctm, float alpha) +fz_bbox_fill_shade(void *user, fz_shade *shade, fz_matrix ctm, float alpha) { - fz_bboxdevice *bdev = user; - fz_bbox bbox = fz_roundrect(fz_boundshade(shade, ctm)); - *bdev->bbox = fz_unionbbox(*bdev->bbox, bbox); + fz_bbox_device *bdev = user; + fz_bbox bbox = fz_round_rect(fz_bound_shade(shade, ctm)); + *bdev->bbox = fz_union_bbox(*bdev->bbox, bbox); } static void -fz_bboxfillimage(void *user, fz_pixmap *image, fz_matrix ctm, float alpha) +fz_bbox_fill_image(void *user, fz_pixmap *image, fz_matrix ctm, float alpha) { - fz_bboxdevice *bdev = user; - fz_bbox bbox = fz_roundrect(fz_transformrect(ctm, fz_unitrect)); - *bdev->bbox = fz_unionbbox(*bdev->bbox, bbox); + fz_bbox_device *bdev = user; + fz_bbox bbox = fz_round_rect(fz_transform_rect(ctm, fz_unit_rect)); + *bdev->bbox = fz_union_bbox(*bdev->bbox, bbox); } static void -fz_bboxfillimagemask(void *user, fz_pixmap *image, fz_matrix ctm, +fz_bbox_fill_image_mask(void *user, fz_pixmap *image, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { - fz_bboxfillimage(user, image, ctm, alpha); + fz_bbox_fill_image(user, image, ctm, alpha); } static void -fz_bboxfreeuser(void *user) +fz_bbox_free_user(void *user) { - fz_bboxdevice *bdev = user; + fz_bbox_device *bdev = user; fz_free(bdev); } fz_device * -fz_newbboxdevice(fz_bbox *bboxp) +fz_new_bbox_device(fz_bbox *bboxp) { fz_device *dev; - fz_bboxdevice *bdev = fz_malloc(sizeof(fz_bboxdevice)); + fz_bbox_device *bdev = fz_malloc(sizeof(fz_bbox_device)); bdev->bbox = bboxp; - *bdev->bbox = fz_emptybbox; + *bdev->bbox = fz_empty_bbox; - dev = fz_newdevice(bdev); - dev->freeuser = fz_bboxfreeuser; - dev->fillpath = fz_bboxfillpath; - dev->strokepath = fz_bboxstrokepath; - dev->filltext = fz_bboxfilltext; - dev->stroketext = fz_bboxstroketext; - dev->fillshade = fz_bboxfillshade; - dev->fillimage = fz_bboxfillimage; - dev->fillimagemask = fz_bboxfillimagemask; + dev = fz_new_device(bdev); + dev->free_user = fz_bbox_free_user; + dev->fill_path = fz_bbox_fill_path; + dev->stroke_path = fz_bbox_stroke_path; + dev->fill_text = fz_bbox_fill_text; + dev->stroke_text = fz_bbox_stroke_text; + dev->fill_shade = fz_bbox_fill_shade; + dev->fill_image = fz_bbox_fill_image; + dev->fill_image_mask = fz_bbox_fill_image_mask; return dev; } diff --git a/fitz/dev_draw.c b/fitz/dev_draw.c index ee74033d..e5078f49 100644 --- a/fitz/dev_draw.c +++ b/fitz/dev_draw.c @@ -4,13 +4,13 @@ #define HSUBPIX 5.0 #define VSUBPIX 5.0 -#define STACKSIZE 96 +#define STACK_SIZE 96 -typedef struct fz_drawdevice_s fz_drawdevice; +typedef struct fz_draw_device_s fz_draw_device; -struct fz_drawdevice_s +struct fz_draw_device_s { - fz_glyphcache *cache; + fz_glyph_cache *cache; fz_gel *gel; fz_ael *ael; @@ -28,118 +28,118 @@ struct fz_drawdevice_s fz_matrix ctm; float xstep, ystep; fz_rect area; - } stack[STACKSIZE]; + } stack[STACK_SIZE]; }; static void -fz_drawfillpath(void *user, fz_path *path, int evenodd, fz_matrix ctm, +fz_draw_fill_path(void *user, fz_path *path, int even_odd, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { - fz_drawdevice *dev = user; + fz_draw_device *dev = user; fz_colorspace *model = dev->dest->colorspace; - float expansion = fz_matrixexpansion(ctm); + float expansion = fz_matrix_expansion(ctm); float flatness = 0.3f / expansion; - unsigned char colorbv[FZ_MAXCOLORS + 1]; - float colorfv[FZ_MAXCOLORS]; + unsigned char colorbv[FZ_MAX_COLORS + 1]; + float colorfv[FZ_MAX_COLORS]; fz_bbox bbox; int i; - fz_resetgel(dev->gel, dev->scissor); - fz_fillpath(dev->gel, path, ctm, flatness); - fz_sortgel(dev->gel); + fz_reset_gel(dev->gel, dev->scissor); + fz_fill_path(dev->gel, path, ctm, flatness); + fz_sort_gel(dev->gel); - bbox = fz_boundgel(dev->gel); - bbox = fz_intersectbbox(bbox, dev->scissor); + bbox = fz_bound_gel(dev->gel); + bbox = fz_intersect_bbox(bbox, dev->scissor); - if (fz_isemptyrect(bbox)) + if (fz_is_empty_rect(bbox)) return; - fz_convertcolor(colorspace, color, model, colorfv); + fz_convert_color(colorspace, color, model, colorfv); for (i = 0; i < model->n; i++) colorbv[i] = colorfv[i] * 255; colorbv[i] = alpha * 255; - fz_scanconvert(dev->gel, dev->ael, evenodd, bbox, dev->dest, colorbv); + fz_scan_convert(dev->gel, dev->ael, even_odd, bbox, dev->dest, colorbv); } static void -fz_drawstrokepath(void *user, fz_path *path, fz_strokestate *stroke, fz_matrix ctm, +fz_draw_stroke_path(void *user, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { - fz_drawdevice *dev = user; + fz_draw_device *dev = user; fz_colorspace *model = dev->dest->colorspace; - float expansion = fz_matrixexpansion(ctm); + float expansion = fz_matrix_expansion(ctm); float flatness = 0.3f / expansion; float linewidth = stroke->linewidth; - unsigned char colorbv[FZ_MAXCOLORS + 1]; - float colorfv[FZ_MAXCOLORS]; + unsigned char colorbv[FZ_MAX_COLORS + 1]; + float colorfv[FZ_MAX_COLORS]; fz_bbox bbox; int i; if (linewidth * expansion < 0.1f) linewidth = 1 / expansion; - fz_resetgel(dev->gel, dev->scissor); - if (stroke->dashlen > 0) - fz_dashpath(dev->gel, path, stroke, ctm, flatness, linewidth); + fz_reset_gel(dev->gel, dev->scissor); + if (stroke->dash_len > 0) + fz_dash_path(dev->gel, path, stroke, ctm, flatness, linewidth); else - fz_strokepath(dev->gel, path, stroke, ctm, flatness, linewidth); - fz_sortgel(dev->gel); + fz_stroke_path(dev->gel, path, stroke, ctm, flatness, linewidth); + fz_sort_gel(dev->gel); - bbox = fz_boundgel(dev->gel); - bbox = fz_intersectbbox(bbox, dev->scissor); + bbox = fz_bound_gel(dev->gel); + bbox = fz_intersect_bbox(bbox, dev->scissor); - if (fz_isemptyrect(bbox)) + if (fz_is_empty_rect(bbox)) return; - fz_convertcolor(colorspace, color, model, colorfv); + fz_convert_color(colorspace, color, model, colorfv); for (i = 0; i < model->n; i++) colorbv[i] = colorfv[i] * 255; colorbv[i] = alpha * 255; - fz_scanconvert(dev->gel, dev->ael, 0, bbox, dev->dest, colorbv); + fz_scan_convert(dev->gel, dev->ael, 0, bbox, dev->dest, colorbv); } static void -fz_drawclippath(void *user, fz_path *path, int evenodd, fz_matrix ctm) +fz_draw_clip_path(void *user, fz_path *path, int even_odd, fz_matrix ctm) { - fz_drawdevice *dev = user; + fz_draw_device *dev = user; fz_colorspace *model = dev->dest->colorspace; - float expansion = fz_matrixexpansion(ctm); + float expansion = fz_matrix_expansion(ctm); float flatness = 0.3f / expansion; fz_pixmap *mask, *dest; fz_bbox bbox; - if (dev->top == STACKSIZE) + if (dev->top == STACK_SIZE) { fz_warn("assert: too many buffers on stack"); return; } - fz_resetgel(dev->gel, dev->scissor); - fz_fillpath(dev->gel, path, ctm, flatness); - fz_sortgel(dev->gel); + fz_reset_gel(dev->gel, dev->scissor); + fz_fill_path(dev->gel, path, ctm, flatness); + fz_sort_gel(dev->gel); - bbox = fz_boundgel(dev->gel); - bbox = fz_intersectbbox(bbox, dev->scissor); + bbox = fz_bound_gel(dev->gel); + bbox = fz_intersect_bbox(bbox, dev->scissor); - if (fz_isemptyrect(bbox) || fz_isrectgel(dev->gel)) + if (fz_is_empty_rect(bbox) || fz_is_rect_gel(dev->gel)) { dev->stack[dev->top].scissor = dev->scissor; - dev->stack[dev->top].mask = nil; - dev->stack[dev->top].dest = nil; + dev->stack[dev->top].mask = NULL; + dev->stack[dev->top].dest = NULL; dev->scissor = bbox; dev->top++; return; } - mask = fz_newpixmapwithrect(nil, bbox); - dest = fz_newpixmapwithrect(model, bbox); + mask = fz_new_pixmap_with_rect(NULL, bbox); + dest = fz_new_pixmap_with_rect(model, bbox); - fz_clearpixmap(mask); - fz_clearpixmap(dest); + fz_clear_pixmap(mask); + fz_clear_pixmap(dest); - fz_scanconvert(dev->gel, dev->ael, evenodd, bbox, mask, nil); + fz_scan_convert(dev->gel, dev->ael, even_odd, bbox, mask, NULL); dev->stack[dev->top].scissor = dev->scissor; dev->stack[dev->top].mask = mask; @@ -150,17 +150,17 @@ fz_drawclippath(void *user, fz_path *path, int evenodd, fz_matrix ctm) } static void -fz_drawclipstrokepath(void *user, fz_path *path, fz_strokestate *stroke, fz_matrix ctm) +fz_draw_clip_stroke_path(void *user, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm) { - fz_drawdevice *dev = user; + fz_draw_device *dev = user; fz_colorspace *model = dev->dest->colorspace; - float expansion = fz_matrixexpansion(ctm); + float expansion = fz_matrix_expansion(ctm); float flatness = 0.3f / expansion; float linewidth = stroke->linewidth; fz_pixmap *mask, *dest; fz_bbox bbox; - if (dev->top == STACKSIZE) + if (dev->top == STACK_SIZE) { fz_warn("assert: too many buffers on stack"); return; @@ -169,24 +169,24 @@ fz_drawclipstrokepath(void *user, fz_path *path, fz_strokestate *stroke, fz_matr if (linewidth * expansion < 0.1f) linewidth = 1 / expansion; - fz_resetgel(dev->gel, dev->scissor); - if (stroke->dashlen > 0) - fz_dashpath(dev->gel, path, stroke, ctm, flatness, linewidth); + fz_reset_gel(dev->gel, dev->scissor); + if (stroke->dash_len > 0) + fz_dash_path(dev->gel, path, stroke, ctm, flatness, linewidth); else - fz_strokepath(dev->gel, path, stroke, ctm, flatness, linewidth); - fz_sortgel(dev->gel); + fz_stroke_path(dev->gel, path, stroke, ctm, flatness, linewidth); + fz_sort_gel(dev->gel); - bbox = fz_boundgel(dev->gel); - bbox = fz_intersectbbox(bbox, dev->scissor); + bbox = fz_bound_gel(dev->gel); + bbox = fz_intersect_bbox(bbox, dev->scissor); - mask = fz_newpixmapwithrect(nil, bbox); - dest = fz_newpixmapwithrect(model, bbox); + mask = fz_new_pixmap_with_rect(NULL, bbox); + dest = fz_new_pixmap_with_rect(model, bbox); - fz_clearpixmap(mask); - fz_clearpixmap(dest); + fz_clear_pixmap(mask); + fz_clear_pixmap(dest); - if (!fz_isemptyrect(bbox)) - fz_scanconvert(dev->gel, dev->ael, 0, bbox, mask, nil); + if (!fz_is_empty_rect(bbox)) + fz_scan_convert(dev->gel, dev->ael, 0, bbox, mask, NULL); dev->stack[dev->top].scissor = dev->scissor; dev->stack[dev->top].mask = mask; @@ -197,20 +197,20 @@ fz_drawclipstrokepath(void *user, fz_path *path, fz_strokestate *stroke, fz_matr } static void -drawglyph(unsigned char *colorbv, fz_pixmap *dst, fz_pixmap *msk, +draw_glyph(unsigned char *colorbv, fz_pixmap *dst, fz_pixmap *msk, int xorig, int yorig, fz_bbox scissor) { unsigned char *dp, *mp; fz_bbox bbox; int x, y, w, h; - bbox = fz_boundpixmap(msk); + bbox = fz_bound_pixmap(msk); bbox.x0 += xorig; bbox.y0 += yorig; bbox.x1 += xorig; bbox.y1 += yorig; - bbox = fz_intersectbbox(bbox, scissor); /* scissor < dst */ + bbox = fz_intersect_bbox(bbox, scissor); /* scissor < dst */ x = bbox.x0; y = bbox.y0; w = bbox.x1 - bbox.x0; @@ -224,27 +224,27 @@ drawglyph(unsigned char *colorbv, fz_pixmap *dst, fz_pixmap *msk, while (h--) { if (dst->colorspace) - fz_paintspancolor(dp, mp, dst->n, w, colorbv); + fz_paint_span_with_color(dp, mp, dst->n, w, colorbv); else - fz_paintspan(dp, mp, 1, w, 255); + fz_paint_span(dp, mp, 1, w, 255); dp += dst->w * dst->n; mp += msk->w; } } static void -fz_drawfilltext(void *user, fz_text *text, fz_matrix ctm, +fz_draw_fill_text(void *user, fz_text *text, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { - fz_drawdevice *dev = user; + fz_draw_device *dev = user; fz_colorspace *model = dev->dest->colorspace; - unsigned char colorbv[FZ_MAXCOLORS + 1]; - float colorfv[FZ_MAXCOLORS]; + unsigned char colorbv[FZ_MAX_COLORS + 1]; + float colorfv[FZ_MAX_COLORS]; fz_matrix tm, trm; fz_pixmap *glyph; int i, x, y, gid; - fz_convertcolor(colorspace, color, model, colorfv); + fz_convert_color(colorspace, color, model, colorfv); for (i = 0; i < model->n; i++) colorbv[i] = colorfv[i] * 255; colorbv[i] = alpha * 255; @@ -253,40 +253,40 @@ fz_drawfilltext(void *user, fz_text *text, fz_matrix ctm, for (i = 0; i < text->len; i++) { - gid = text->els[i].gid; + gid = text->items[i].gid; if (gid < 0) continue; - tm.e = text->els[i].x; - tm.f = text->els[i].y; + tm.e = text->items[i].x; + tm.f = text->items[i].y; trm = fz_concat(tm, ctm); x = floorf(trm.e); y = floorf(trm.f); trm.e = QUANT(trm.e - floorf(trm.e), HSUBPIX); trm.f = QUANT(trm.f - floorf(trm.f), VSUBPIX); - glyph = fz_renderglyph(dev->cache, text->font, gid, trm); + glyph = fz_render_glyph(dev->cache, text->font, gid, trm); if (glyph) { - drawglyph(colorbv, dev->dest, glyph, x, y, dev->scissor); - fz_droppixmap(glyph); + draw_glyph(colorbv, dev->dest, glyph, x, y, dev->scissor); + fz_drop_pixmap(glyph); } } } static void -fz_drawstroketext(void *user, fz_text *text, fz_strokestate *stroke, fz_matrix ctm, +fz_draw_stroke_text(void *user, fz_text *text, fz_stroke_state *stroke, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { - fz_drawdevice *dev = user; + fz_draw_device *dev = user; fz_colorspace *model = dev->dest->colorspace; - unsigned char colorbv[FZ_MAXCOLORS + 1]; - float colorfv[FZ_MAXCOLORS]; + unsigned char colorbv[FZ_MAX_COLORS + 1]; + float colorfv[FZ_MAX_COLORS]; fz_matrix tm, trm; fz_pixmap *glyph; int i, x, y, gid; - fz_convertcolor(colorspace, color, model, colorfv); + fz_convert_color(colorspace, color, model, colorfv); for (i = 0; i < model->n; i++) colorbv[i] = colorfv[i] * 255; colorbv[i] = alpha * 255; @@ -295,31 +295,31 @@ fz_drawstroketext(void *user, fz_text *text, fz_strokestate *stroke, fz_matrix c for (i = 0; i < text->len; i++) { - gid = text->els[i].gid; + gid = text->items[i].gid; if (gid < 0) continue; - tm.e = text->els[i].x; - tm.f = text->els[i].y; + tm.e = text->items[i].x; + tm.f = text->items[i].y; trm = fz_concat(tm, ctm); x = floorf(trm.e); y = floorf(trm.f); trm.e = QUANT(trm.e - floorf(trm.e), HSUBPIX); trm.f = QUANT(trm.f - floorf(trm.f), VSUBPIX); - glyph = fz_renderstrokedglyph(dev->cache, text->font, gid, trm, ctm, stroke); + glyph = fz_render_stroked_glyph(dev->cache, text->font, gid, trm, ctm, stroke); if (glyph) { - drawglyph(colorbv, dev->dest, glyph, x, y, dev->scissor); - fz_droppixmap(glyph); + draw_glyph(colorbv, dev->dest, glyph, x, y, dev->scissor); + fz_drop_pixmap(glyph); } } } static void -fz_drawcliptext(void *user, fz_text *text, fz_matrix ctm, int accumulate) +fz_draw_clip_text(void *user, fz_text *text, fz_matrix ctm, int accumulate) { - fz_drawdevice *dev = user; + fz_draw_device *dev = user; fz_colorspace *model = dev->dest->colorspace; fz_bbox bbox; fz_pixmap *mask, *dest; @@ -331,7 +331,7 @@ fz_drawcliptext(void *user, fz_text *text, fz_matrix ctm, int accumulate) /* If accumulate == 1 then this text object is the first (or only) in a sequence */ /* If accumulate == 2 then this text object is a continuation */ - if (dev->top == STACKSIZE) + if (dev->top == STACK_SIZE) { fz_warn("assert: too many buffers on stack"); return; @@ -340,8 +340,8 @@ fz_drawcliptext(void *user, fz_text *text, fz_matrix ctm, int accumulate) if (accumulate == 0) { /* make the mask the exact size needed */ - bbox = fz_roundrect(fz_boundtext(text, ctm)); - bbox = fz_intersectbbox(bbox, dev->scissor); + bbox = fz_round_rect(fz_bound_text(text, ctm)); + bbox = fz_intersect_bbox(bbox, dev->scissor); } else { @@ -351,11 +351,11 @@ fz_drawcliptext(void *user, fz_text *text, fz_matrix ctm, int accumulate) if (accumulate == 0 || accumulate == 1) { - mask = fz_newpixmapwithrect(nil, bbox); - dest = fz_newpixmapwithrect(model, bbox); + mask = fz_new_pixmap_with_rect(NULL, bbox); + dest = fz_new_pixmap_with_rect(model, bbox); - fz_clearpixmap(mask); - fz_clearpixmap(dest); + fz_clear_pixmap(mask); + fz_clear_pixmap(dest); dev->stack[dev->top].scissor = dev->scissor; dev->stack[dev->top].mask = mask; @@ -369,38 +369,38 @@ fz_drawcliptext(void *user, fz_text *text, fz_matrix ctm, int accumulate) mask = dev->stack[dev->top-1].mask; } - if (!fz_isemptyrect(bbox)) + if (!fz_is_empty_rect(bbox)) { tm = text->trm; for (i = 0; i < text->len; i++) { - gid = text->els[i].gid; + gid = text->items[i].gid; if (gid < 0) continue; - tm.e = text->els[i].x; - tm.f = text->els[i].y; + tm.e = text->items[i].x; + tm.f = text->items[i].y; trm = fz_concat(tm, ctm); x = floorf(trm.e); y = floorf(trm.f); trm.e = QUANT(trm.e - floorf(trm.e), HSUBPIX); trm.f = QUANT(trm.f - floorf(trm.f), VSUBPIX); - glyph = fz_renderglyph(dev->cache, text->font, gid, trm); + glyph = fz_render_glyph(dev->cache, text->font, gid, trm); if (glyph) { - drawglyph(nil, mask, glyph, x, y, bbox); - fz_droppixmap(glyph); + draw_glyph(NULL, mask, glyph, x, y, bbox); + fz_drop_pixmap(glyph); } } } } static void -fz_drawclipstroketext(void *user, fz_text *text, fz_strokestate *stroke, fz_matrix ctm) +fz_draw_clip_stroke_text(void *user, fz_text *text, fz_stroke_state *stroke, fz_matrix ctm) { - fz_drawdevice *dev = user; + fz_draw_device *dev = user; fz_colorspace *model = dev->dest->colorspace; fz_bbox bbox; fz_pixmap *mask, *dest; @@ -408,21 +408,21 @@ fz_drawclipstroketext(void *user, fz_text *text, fz_strokestate *stroke, fz_matr fz_pixmap *glyph; int i, x, y, gid; - if (dev->top == STACKSIZE) + if (dev->top == STACK_SIZE) { fz_warn("assert: too many buffers on stack"); return; } /* make the mask the exact size needed */ - bbox = fz_roundrect(fz_boundtext(text, ctm)); - bbox = fz_intersectbbox(bbox, dev->scissor); + bbox = fz_round_rect(fz_bound_text(text, ctm)); + bbox = fz_intersect_bbox(bbox, dev->scissor); - mask = fz_newpixmapwithrect(nil, bbox); - dest = fz_newpixmapwithrect(model, bbox); + mask = fz_new_pixmap_with_rect(NULL, bbox); + dest = fz_new_pixmap_with_rect(model, bbox); - fz_clearpixmap(mask); - fz_clearpixmap(dest); + fz_clear_pixmap(mask); + fz_clear_pixmap(dest); dev->stack[dev->top].scissor = dev->scissor; dev->stack[dev->top].mask = mask; @@ -431,57 +431,57 @@ fz_drawclipstroketext(void *user, fz_text *text, fz_strokestate *stroke, fz_matr dev->dest = dest; dev->top++; - if (!fz_isemptyrect(bbox)) + if (!fz_is_empty_rect(bbox)) { tm = text->trm; for (i = 0; i < text->len; i++) { - gid = text->els[i].gid; + gid = text->items[i].gid; if (gid < 0) continue; - tm.e = text->els[i].x; - tm.f = text->els[i].y; + tm.e = text->items[i].x; + tm.f = text->items[i].y; trm = fz_concat(tm, ctm); x = floorf(trm.e); y = floorf(trm.f); trm.e = QUANT(trm.e - floorf(trm.e), HSUBPIX); trm.f = QUANT(trm.f - floorf(trm.f), VSUBPIX); - glyph = fz_renderstrokedglyph(dev->cache, text->font, gid, trm, ctm, stroke); + glyph = fz_render_stroked_glyph(dev->cache, text->font, gid, trm, ctm, stroke); if (glyph) { - drawglyph(nil, mask, glyph, x, y, bbox); - fz_droppixmap(glyph); + draw_glyph(NULL, mask, glyph, x, y, bbox); + fz_drop_pixmap(glyph); } } } } static void -fz_drawignoretext(void *user, fz_text *text, fz_matrix ctm) +fz_draw_ignore_text(void *user, fz_text *text, fz_matrix ctm) { } static void -fz_drawfillshade(void *user, fz_shade *shade, fz_matrix ctm, float alpha) +fz_draw_fill_shade(void *user, fz_shade *shade, fz_matrix ctm, float alpha) { - fz_drawdevice *dev = user; + fz_draw_device *dev = user; fz_colorspace *model = dev->dest->colorspace; fz_pixmap *dest = dev->dest; fz_rect bounds; fz_bbox bbox, scissor; - float colorfv[FZ_MAXCOLORS]; - unsigned char colorbv[FZ_MAXCOLORS + 1]; + float colorfv[FZ_MAX_COLORS]; + unsigned char colorbv[FZ_MAX_COLORS + 1]; - bounds = fz_boundshade(shade, ctm); - bbox = fz_intersectbbox(fz_roundrect(bounds), dev->scissor); + bounds = fz_bound_shade(shade, ctm); + bbox = fz_intersect_bbox(fz_round_rect(bounds), dev->scissor); scissor = dev->scissor; // TODO: proper clip by shade->bbox - if (fz_isemptyrect(bbox)) + if (fz_is_empty_rect(bbox)) return; if (!model) @@ -492,15 +492,15 @@ fz_drawfillshade(void *user, fz_shade *shade, fz_matrix ctm, float alpha) if (alpha < 1) { - dest = fz_newpixmapwithrect(dev->dest->colorspace, bbox); - fz_clearpixmap(dest); + dest = fz_new_pixmap_with_rect(dev->dest->colorspace, bbox); + fz_clear_pixmap(dest); } - if (shade->usebackground) + if (shade->use_background) { unsigned char *s; int x, y, n, i; - fz_convertcolor(shade->colorspace, shade->background, model, colorfv); + fz_convert_color(shade->colorspace, shade->background, model, colorfv); for (i = 0; i < model->n; i++) colorbv[i] = colorfv[i] * 255; colorbv[i] = 255; @@ -517,26 +517,26 @@ fz_drawfillshade(void *user, fz_shade *shade, fz_matrix ctm, float alpha) } } - fz_paintshade(shade, ctm, dest, bbox); + fz_paint_shade(shade, ctm, dest, bbox); if (alpha < 1) { - fz_paintpixmap(dev->dest, dest, alpha * 255); - fz_droppixmap(dest); + fz_paint_pixmap(dev->dest, dest, alpha * 255); + fz_drop_pixmap(dest); } } static fz_pixmap * -fz_transformpixmap(fz_pixmap *image, fz_matrix *ctm, int x, int y, int dx, int dy) +fz_transform_pixmap(fz_pixmap *image, fz_matrix *ctm, int x, int y, int dx, int dy) { fz_pixmap *scaled; if ((ctm->a != 0) && (ctm->b == 0) && (ctm->c == 0) && (ctm->d != 0)) { /* Unrotated or X flip or Yflip or XYflip */ - scaled = fz_scalepixmap(image, ctm->e, ctm->f, ctm->a, ctm->d); - if (scaled == nil) - return nil; + scaled = fz_scale_pixmap(image, ctm->e, ctm->f, ctm->a, ctm->d); + if (scaled == NULL) + return NULL; ctm->a = scaled->w; ctm->d = scaled->h; ctm->e = scaled->x; @@ -546,9 +546,9 @@ fz_transformpixmap(fz_pixmap *image, fz_matrix *ctm, int x, int y, int dx, int d if ((ctm->a == 0) && (ctm->b != 0) && (ctm->c != 0) && (ctm->d == 0)) { /* Other orthogonal flip/rotation cases */ - scaled = fz_scalepixmap(image, ctm->f, ctm->e, ctm->b, ctm->c); - if (scaled == nil) - return nil; + scaled = fz_scale_pixmap(image, ctm->f, ctm->e, ctm->b, ctm->c); + if (scaled == NULL) + return NULL; ctm->b = scaled->w; ctm->c = scaled->h; ctm->f = scaled->x; @@ -558,19 +558,19 @@ fz_transformpixmap(fz_pixmap *image, fz_matrix *ctm, int x, int y, int dx, int d /* Downscale, non rectilinear case */ if ((dx > 0) && (dy > 0)) { - scaled = fz_scalepixmap(image, 0, 0, (float)dx, (float)dy); + scaled = fz_scale_pixmap(image, 0, 0, (float)dx, (float)dy); return scaled; } - return nil; + return NULL; } static void -fz_drawfillimage(void *user, fz_pixmap *image, fz_matrix ctm, float alpha) +fz_draw_fill_image(void *user, fz_pixmap *image, fz_matrix ctm, float alpha) { - fz_drawdevice *dev = user; + fz_draw_device *dev = user; fz_colorspace *model = dev->dest->colorspace; - fz_pixmap *converted = nil; - fz_pixmap *scaled = nil; + fz_pixmap *converted = NULL; + fz_pixmap *scaled = NULL; int after; int dx, dy; @@ -588,13 +588,13 @@ fz_drawfillimage(void *user, fz_pixmap *image, fz_matrix ctm, float alpha) /* convert images with expensive colorspace transforms after scaling */ after = 0; - if (image->colorspace == fz_devicegray) + if (image->colorspace == fz_device_gray) after = 1; if (image->colorspace != model && !after) { - converted = fz_newpixmap(model, image->x, image->y, image->w, image->h); - fz_convertpixmap(image, converted); + converted = fz_new_pixmap(model, image->x, image->y, image->w, image->h); + fz_convert_pixmap(image, converted); image = converted; } @@ -602,43 +602,43 @@ fz_drawfillimage(void *user, fz_pixmap *image, fz_matrix ctm, float alpha) dy = sqrtf(ctm.c * ctm.c + ctm.d * ctm.d); if (dx < image->w && dy < image->h) { - scaled = fz_transformpixmap(image, &ctm, dev->dest->x, dev->dest->y, dx, dy); - if (scaled == nil) + scaled = fz_transform_pixmap(image, &ctm, dev->dest->x, dev->dest->y, dx, dy); + if (scaled == NULL) { if (dx < 1) dx = 1; if (dy < 1) dy = 1; - scaled = fz_scalepixmap(image, image->x, image->y, dx, dy); + scaled = fz_scale_pixmap(image, image->x, image->y, dx, dy); } - if (scaled != nil) + if (scaled != NULL) image = scaled; } if (image->colorspace != model && after) { - converted = fz_newpixmap(model, image->x, image->y, image->w, image->h); - fz_convertpixmap(image, converted); + converted = fz_new_pixmap(model, image->x, image->y, image->w, image->h); + fz_convert_pixmap(image, converted); image = converted; } - fz_paintimage(dev->dest, dev->scissor, image, ctm, alpha * 255); + fz_paint_image(dev->dest, dev->scissor, image, ctm, alpha * 255); if (scaled) - fz_droppixmap(scaled); + fz_drop_pixmap(scaled); if (converted) - fz_droppixmap(converted); + fz_drop_pixmap(converted); } static void -fz_drawfillimagemask(void *user, fz_pixmap *image, fz_matrix ctm, +fz_draw_fill_image_mask(void *user, fz_pixmap *image, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { - fz_drawdevice *dev = user; + fz_draw_device *dev = user; fz_colorspace *model = dev->dest->colorspace; - unsigned char colorbv[FZ_MAXCOLORS + 1]; - float colorfv[FZ_MAXCOLORS]; - fz_pixmap *scaled = nil; + unsigned char colorbv[FZ_MAX_COLORS + 1]; + float colorfv[FZ_MAX_COLORS]; + fz_pixmap *scaled = NULL; int dx, dy; int i; @@ -649,41 +649,41 @@ fz_drawfillimagemask(void *user, fz_pixmap *image, fz_matrix ctm, dy = sqrtf(ctm.c * ctm.c + ctm.d * ctm.d); if (dx < image->w && dy < image->h) { - scaled = fz_transformpixmap(image, &ctm, dev->dest->x, dev->dest->y, dx, dy); - if (scaled == nil) + scaled = fz_transform_pixmap(image, &ctm, dev->dest->x, dev->dest->y, dx, dy); + if (scaled == NULL) { if (dx < 1) dx = 1; if (dy < 1) dy = 1; - scaled = fz_scalepixmap(image, image->x, image->y, dx, dy); + scaled = fz_scale_pixmap(image, image->x, image->y, dx, dy); } - if (scaled != nil) + if (scaled != NULL) image = scaled; } - fz_convertcolor(colorspace, color, model, colorfv); + fz_convert_color(colorspace, color, model, colorfv); for (i = 0; i < model->n; i++) colorbv[i] = colorfv[i] * 255; colorbv[i] = alpha * 255; - fz_paintimagecolor(dev->dest, dev->scissor, image, ctm, colorbv); + fz_paint_image_with_color(dev->dest, dev->scissor, image, ctm, colorbv); if (scaled) - fz_droppixmap(scaled); + fz_drop_pixmap(scaled); } static void -fz_drawclipimagemask(void *user, fz_pixmap *image, fz_matrix ctm) +fz_draw_clip_image_mask(void *user, fz_pixmap *image, fz_matrix ctm) { - fz_drawdevice *dev = user; + fz_draw_device *dev = user; fz_colorspace *model = dev->dest->colorspace; fz_bbox bbox; fz_pixmap *mask, *dest; - fz_pixmap *scaled = nil; + fz_pixmap *scaled = NULL; int dx, dy; - if (dev->top == STACKSIZE) + if (dev->top == STACK_SIZE) { fz_warn("assert: too many buffers on stack"); return; @@ -692,43 +692,43 @@ fz_drawclipimagemask(void *user, fz_pixmap *image, fz_matrix ctm) if (image->w == 0 || image->h == 0) { dev->stack[dev->top].scissor = dev->scissor; - dev->stack[dev->top].mask = nil; - dev->stack[dev->top].dest = nil; - dev->scissor = fz_emptybbox; + dev->stack[dev->top].mask = NULL; + dev->stack[dev->top].dest = NULL; + dev->scissor = fz_empty_bbox; dev->top++; return; } - bbox = fz_roundrect(fz_transformrect(ctm, fz_unitrect)); - bbox = fz_intersectbbox(bbox, dev->scissor); + bbox = fz_round_rect(fz_transform_rect(ctm, fz_unit_rect)); + bbox = fz_intersect_bbox(bbox, dev->scissor); - mask = fz_newpixmapwithrect(nil, bbox); - dest = fz_newpixmapwithrect(model, bbox); + mask = fz_new_pixmap_with_rect(NULL, bbox); + dest = fz_new_pixmap_with_rect(model, bbox); - fz_clearpixmap(mask); - fz_clearpixmap(dest); + fz_clear_pixmap(mask); + fz_clear_pixmap(dest); dx = sqrtf(ctm.a * ctm.a + ctm.b * ctm.b); dy = sqrtf(ctm.c * ctm.c + ctm.d * ctm.d); if (dx < image->w && dy < image->h) { - scaled = fz_transformpixmap(image, &ctm, dev->dest->x, dev->dest->y, dx, dy); - if (scaled == nil) + scaled = fz_transform_pixmap(image, &ctm, dev->dest->x, dev->dest->y, dx, dy); + if (scaled == NULL) { if (dx < 1) dx = 1; if (dy < 1) dy = 1; - scaled = fz_scalepixmap(image, image->x, image->y, dx, dy); + scaled = fz_scale_pixmap(image, image->x, image->y, dx, dy); } - if (scaled != nil) + if (scaled != NULL) image = scaled; } - fz_paintimage(mask, bbox, image, ctm, 255); + fz_paint_image(mask, bbox, image, ctm, 255); if (scaled) - fz_droppixmap(scaled); + fz_drop_pixmap(scaled); dev->stack[dev->top].scissor = dev->scissor; dev->stack[dev->top].mask = mask; @@ -739,9 +739,9 @@ fz_drawclipimagemask(void *user, fz_pixmap *image, fz_matrix ctm) } static void -fz_drawpopclip(void *user) +fz_draw_pop_clip(void *user) { - fz_drawdevice *dev = user; + fz_draw_device *dev = user; fz_pixmap *mask, *dest; if (dev->top > 0) { @@ -752,41 +752,41 @@ fz_drawpopclip(void *user) if (mask && dest) { fz_pixmap *scratch = dev->dest; - fz_paintpixmapmask(dest, scratch, mask); - fz_droppixmap(mask); - fz_droppixmap(scratch); + fz_paint_pixmap_with_mask(dest, scratch, mask); + fz_drop_pixmap(mask); + fz_drop_pixmap(scratch); dev->dest = dest; } } } static void -fz_drawbeginmask(void *user, fz_rect rect, int luminosity, fz_colorspace *colorspace, float *colorfv) +fz_draw_begin_mask(void *user, fz_rect rect, int luminosity, fz_colorspace *colorspace, float *colorfv) { - fz_drawdevice *dev = user; + fz_draw_device *dev = user; fz_pixmap *dest; fz_bbox bbox; - if (dev->top == STACKSIZE) + if (dev->top == STACK_SIZE) { fz_warn("assert: too many buffers on stack"); return; } - bbox = fz_roundrect(rect); - bbox = fz_intersectbbox(bbox, dev->scissor); - dest = fz_newpixmapwithrect(fz_devicegray, bbox); + bbox = fz_round_rect(rect); + bbox = fz_intersect_bbox(bbox, dev->scissor); + dest = fz_new_pixmap_with_rect(fz_device_gray, bbox); if (luminosity) { float bc; if (!colorspace) - colorspace = fz_devicegray; - fz_convertcolor(colorspace, colorfv, fz_devicegray, &bc); - fz_clearpixmapwithcolor(dest, bc * 255); + colorspace = fz_device_gray; + fz_convert_color(colorspace, colorfv, fz_device_gray, &bc); + fz_clear_pixmap_with_color(dest, bc * 255); } else - fz_clearpixmap(dest); + fz_clear_pixmap(dest); dev->stack[dev->top].scissor = dev->scissor; dev->stack[dev->top].dest = dev->dest; @@ -798,15 +798,15 @@ fz_drawbeginmask(void *user, fz_rect rect, int luminosity, fz_colorspace *colors } static void -fz_drawendmask(void *user) +fz_draw_end_mask(void *user) { - fz_drawdevice *dev = user; + fz_draw_device *dev = user; fz_pixmap *mask = dev->dest; fz_pixmap *temp, *dest; fz_bbox bbox; int luminosity; - if (dev->top == STACKSIZE) + if (dev->top == STACK_SIZE) { fz_warn("assert: too many buffers on stack"); return; @@ -821,13 +821,13 @@ fz_drawendmask(void *user) dev->dest = dev->stack[dev->top].dest; /* convert to alpha mask */ - temp = fz_alphafromgray(mask, luminosity); - fz_droppixmap(mask); + temp = fz_alpha_from_gray(mask, luminosity); + fz_drop_pixmap(mask); /* create new dest scratch buffer */ - bbox = fz_boundpixmap(temp); - dest = fz_newpixmapwithrect(dev->dest->colorspace, bbox); - fz_clearpixmap(dest); + bbox = fz_bound_pixmap(temp); + dest = fz_new_pixmap_with_rect(dev->dest->colorspace, bbox); + fz_clear_pixmap(dest); /* push soft mask as clip mask */ dev->stack[dev->top].scissor = dev->scissor; @@ -840,24 +840,24 @@ fz_drawendmask(void *user) } static void -fz_drawbegingroup(void *user, fz_rect rect, int isolated, int knockout, fz_blendmode blendmode, float alpha) +fz_draw_begin_group(void *user, fz_rect rect, int isolated, int knockout, fz_blendmode blendmode, float alpha) { - fz_drawdevice *dev = user; + fz_draw_device *dev = user; fz_colorspace *model = dev->dest->colorspace; fz_bbox bbox; fz_pixmap *dest; - if (dev->top == STACKSIZE) + if (dev->top == STACK_SIZE) { fz_warn("assert: too many buffers on stack"); return; } - bbox = fz_roundrect(rect); - bbox = fz_intersectbbox(bbox, dev->scissor); - dest = fz_newpixmapwithrect(model, bbox); + bbox = fz_round_rect(rect); + bbox = fz_intersect_bbox(bbox, dev->scissor); + dest = fz_new_pixmap_with_rect(model, bbox); - fz_clearpixmap(dest); + fz_clear_pixmap(dest); dev->stack[dev->top].alpha = alpha; dev->stack[dev->top].blendmode = blendmode; @@ -870,9 +870,9 @@ fz_drawbegingroup(void *user, fz_rect rect, int isolated, int knockout, fz_blend } static void -fz_drawendgroup(void *user) +fz_draw_end_group(void *user) { - fz_drawdevice *dev = user; + fz_draw_device *dev = user; fz_pixmap *group = dev->dest; fz_blendmode blendmode; float alpha; @@ -885,19 +885,19 @@ fz_drawendgroup(void *user) dev->dest = dev->stack[dev->top].dest; dev->scissor = dev->stack[dev->top].scissor; - if (blendmode == FZ_BNORMAL) - fz_paintpixmap(dev->dest, group, alpha * 255); + if (blendmode == FZ_BLEND_NORMAL) + fz_paint_pixmap(dev->dest, group, alpha * 255); else - fz_blendpixmap(dev->dest, group, alpha * 255, blendmode); + fz_blend_pixmap(dev->dest, group, alpha * 255, blendmode); - fz_droppixmap(group); + fz_drop_pixmap(group); } } static void -fz_drawbegintile(void *user, fz_rect area, fz_rect view, float xstep, float ystep, fz_matrix ctm) +fz_draw_begin_tile(void *user, fz_rect area, fz_rect view, float xstep, float ystep, fz_matrix ctm) { - fz_drawdevice *dev = user; + fz_draw_device *dev = user; fz_colorspace *model = dev->dest->colorspace; fz_pixmap *dest; fz_bbox bbox; @@ -905,15 +905,15 @@ fz_drawbegintile(void *user, fz_rect area, fz_rect view, float xstep, float yste /* area, view, xstep, ystep are in pattern space */ /* ctm maps from pattern space to device space */ - if (dev->top == STACKSIZE) + if (dev->top == STACK_SIZE) { fz_warn("assert: too many buffers on stack"); return; } - bbox = fz_roundrect(fz_transformrect(ctm, view)); - dest = fz_newpixmapwithrect(model, bbox); - fz_clearpixmap(dest); + bbox = fz_round_rect(fz_transform_rect(ctm, view)); + dest = fz_new_pixmap_with_rect(model, bbox); + fz_clear_pixmap(dest); dev->stack[dev->top].scissor = dev->scissor; dev->stack[dev->top].dest = dev->dest; @@ -928,9 +928,9 @@ fz_drawbegintile(void *user, fz_rect area, fz_rect view, float xstep, float yste } static void -fz_drawendtile(void *user) +fz_draw_end_tile(void *user) { - fz_drawdevice *dev = user; + fz_draw_device *dev = user; fz_pixmap *tile = dev->dest; float xstep, ystep; fz_matrix ctm, ttm; @@ -962,32 +962,32 @@ fz_drawendtile(void *user) ttm = fz_concat(fz_translate(x * xstep, y * ystep), ctm); tile->x = ttm.e; tile->y = ttm.f; - fz_paintpixmapbbox(dev->dest, tile, 255, dev->scissor); + fz_paint_pixmap_with_rect(dev->dest, tile, 255, dev->scissor); } } - fz_droppixmap(tile); + fz_drop_pixmap(tile); } } static void -fz_drawfreeuser(void *user) +fz_draw_free_user(void *user) { - fz_drawdevice *dev = user; + fz_draw_device *dev = user; /* TODO: pop and free the stacks */ - fz_freegel(dev->gel); - fz_freeael(dev->ael); + fz_free_gel(dev->gel); + fz_free_ael(dev->ael); fz_free(dev); } fz_device * -fz_newdrawdevice(fz_glyphcache *cache, fz_pixmap *dest) +fz_new_draw_device(fz_glyph_cache *cache, fz_pixmap *dest) { fz_device *dev; - fz_drawdevice *ddev = fz_malloc(sizeof(fz_drawdevice)); + fz_draw_device *ddev = fz_malloc(sizeof(fz_draw_device)); ddev->cache = cache; - ddev->gel = fz_newgel(); - ddev->ael = fz_newael(); + ddev->gel = fz_new_gel(); + ddev->ael = fz_new_ael(); ddev->dest = dest; ddev->top = 0; @@ -996,34 +996,34 @@ fz_newdrawdevice(fz_glyphcache *cache, fz_pixmap *dest) ddev->scissor.x1 = dest->x + dest->w; ddev->scissor.y1 = dest->y + dest->h; - dev = fz_newdevice(ddev); - dev->freeuser = fz_drawfreeuser; + dev = fz_new_device(ddev); + dev->free_user = fz_draw_free_user; - dev->fillpath = fz_drawfillpath; - dev->strokepath = fz_drawstrokepath; - dev->clippath = fz_drawclippath; - dev->clipstrokepath = fz_drawclipstrokepath; + dev->fill_path = fz_draw_fill_path; + dev->stroke_path = fz_draw_stroke_path; + dev->clip_path = fz_draw_clip_path; + dev->clip_stroke_path = fz_draw_clip_stroke_path; - dev->filltext = fz_drawfilltext; - dev->stroketext = fz_drawstroketext; - dev->cliptext = fz_drawcliptext; - dev->clipstroketext = fz_drawclipstroketext; - dev->ignoretext = fz_drawignoretext; + dev->fill_text = fz_draw_fill_text; + dev->stroke_text = fz_draw_stroke_text; + dev->clip_text = fz_draw_clip_text; + dev->clip_stroke_text = fz_draw_clip_stroke_text; + dev->ignore_text = fz_draw_ignore_text; - dev->fillimagemask = fz_drawfillimagemask; - dev->clipimagemask = fz_drawclipimagemask; - dev->fillimage = fz_drawfillimage; - dev->fillshade = fz_drawfillshade; + dev->fill_image_mask = fz_draw_fill_image_mask; + dev->clip_image_mask = fz_draw_clip_image_mask; + dev->fill_image = fz_draw_fill_image; + dev->fill_shade = fz_draw_fill_shade; - dev->popclip = fz_drawpopclip; + dev->pop_clip = fz_draw_pop_clip; - dev->beginmask = fz_drawbeginmask; - dev->endmask = fz_drawendmask; - dev->begingroup = fz_drawbegingroup; - dev->endgroup = fz_drawendgroup; + dev->begin_mask = fz_draw_begin_mask; + dev->end_mask = fz_draw_end_mask; + dev->begin_group = fz_draw_begin_group; + dev->end_group = fz_draw_end_group; - dev->begintile = fz_drawbegintile; - dev->endtile = fz_drawendtile; + dev->begin_tile = fz_draw_begin_tile; + dev->end_tile = fz_draw_end_tile; return dev; } diff --git a/fitz/dev_list.c b/fitz/dev_list.c index 2bba6ed3..d9293dc4 100644 --- a/fitz/dev_list.c +++ b/fitz/dev_list.c @@ -3,24 +3,24 @@ #define ISOLATED 1 #define KNOCKOUT 2 -static fz_displaynode * -fz_newdisplaynode(fz_displaycommand cmd, fz_matrix ctm, +static fz_display_node * +fz_new_display_node(fz_display_command cmd, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { - fz_displaynode *node; + fz_display_node *node; int i; - node = fz_malloc(sizeof(fz_displaynode)); + node = fz_malloc(sizeof(fz_display_node)); node->cmd = cmd; - node->next = nil; - node->rect = fz_emptyrect; - node->item.path = nil; - node->stroke = nil; + node->next = NULL; + node->rect = fz_empty_rect; + node->item.path = NULL; + node->stroke = NULL; node->flag = 0; node->ctm = ctm; if (colorspace) { - node->colorspace = fz_keepcolorspace(colorspace); + node->colorspace = fz_keep_colorspace(colorspace); if (color) { for (i = 0; i < node->colorspace->n; i++) @@ -29,23 +29,23 @@ fz_newdisplaynode(fz_displaycommand cmd, fz_matrix ctm, } else { - node->colorspace = nil; + node->colorspace = NULL; } node->alpha = alpha; return node; } -static fz_strokestate * -fz_clonestrokestate(fz_strokestate *stroke) +static fz_stroke_state * +fz_clone_stroke_state(fz_stroke_state *stroke) { - fz_strokestate *newstroke = fz_malloc(sizeof(fz_strokestate)); + fz_stroke_state *newstroke = fz_malloc(sizeof(fz_stroke_state)); *newstroke = *stroke; return newstroke; } static void -fz_appenddisplaynode(fz_displaylist *list, fz_displaynode *node) +fz_append_display_node(fz_display_list *list, fz_display_node *node) { if (!list->first) { @@ -60,244 +60,244 @@ fz_appenddisplaynode(fz_displaylist *list, fz_displaynode *node) } static void -fz_freedisplaynode(fz_displaynode *node) +fz_free_display_node(fz_display_node *node) { switch (node->cmd) { - case FZ_CMDFILLPATH: - case FZ_CMDSTROKEPATH: - case FZ_CMDCLIPPATH: - case FZ_CMDCLIPSTROKEPATH: - fz_freepath(node->item.path); + case FZ_CMD_FILL_PATH: + case FZ_CMD_STROKE_PATH: + case FZ_CMD_CLIP_PATH: + case FZ_CMD_CLIP_STROKE_PATH: + fz_free_path(node->item.path); break; - case FZ_CMDFILLTEXT: - case FZ_CMDSTROKETEXT: - case FZ_CMDCLIPTEXT: - case FZ_CMDCLIPSTROKETEXT: - case FZ_CMDIGNORETEXT: - fz_freetext(node->item.text); + case FZ_CMD_FILL_TEXT: + case FZ_CMD_STROKE_TEXT: + case FZ_CMD_CLIP_TEXT: + case FZ_CMD_CLIP_STROKE_TEXT: + case FZ_CMD_IGNORE_TEXT: + fz_free_text(node->item.text); break; - case FZ_CMDFILLSHADE: - fz_dropshade(node->item.shade); + case FZ_CMD_FILL_SHADE: + fz_drop_shade(node->item.shade); break; - case FZ_CMDFILLIMAGE: - case FZ_CMDFILLIMAGEMASK: - case FZ_CMDCLIPIMAGEMASK: - fz_droppixmap(node->item.image); + case FZ_CMD_FILL_IMAGE: + case FZ_CMD_FILL_IMAGE_MASK: + case FZ_CMD_CLIP_IMAGE_MASK: + fz_drop_pixmap(node->item.image); break; - case FZ_CMDPOPCLIP: - case FZ_CMDBEGINMASK: - case FZ_CMDENDMASK: - case FZ_CMDBEGINGROUP: - case FZ_CMDENDGROUP: - case FZ_CMDBEGINTILE: - case FZ_CMDENDTILE: + case FZ_CMD_POP_CLIP: + case FZ_CMD_BEGIN_MASK: + case FZ_CMD_END_MASK: + case FZ_CMD_BEGIN_GROUP: + case FZ_CMD_END_GROUP: + case FZ_CMD_BEGIN_TILE: + case FZ_CMD_END_TILE: break; } if (node->stroke) fz_free(node->stroke); if (node->colorspace) - fz_dropcolorspace(node->colorspace); + fz_drop_colorspace(node->colorspace); fz_free(node); } static void -fz_listfillpath(void *user, fz_path *path, int evenodd, fz_matrix ctm, +fz_list_fill_path(void *user, fz_path *path, int even_odd, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { - fz_displaynode *node; - node = fz_newdisplaynode(FZ_CMDFILLPATH, ctm, colorspace, color, alpha); - node->rect = fz_boundpath(path, nil, ctm); - node->item.path = fz_clonepath(path); - node->flag = evenodd; - fz_appenddisplaynode(user, node); + fz_display_node *node; + node = fz_new_display_node(FZ_CMD_FILL_PATH, ctm, colorspace, color, alpha); + node->rect = fz_bound_path(path, NULL, ctm); + node->item.path = fz_clone_path(path); + node->flag = even_odd; + fz_append_display_node(user, node); } static void -fz_liststrokepath(void *user, fz_path *path, fz_strokestate *stroke, fz_matrix ctm, +fz_list_stroke_path(void *user, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { - fz_displaynode *node; - node = fz_newdisplaynode(FZ_CMDSTROKEPATH, ctm, colorspace, color, alpha); - node->rect = fz_boundpath(path, stroke, ctm); - node->item.path = fz_clonepath(path); - node->stroke = fz_clonestrokestate(stroke); - fz_appenddisplaynode(user, node); + fz_display_node *node; + node = fz_new_display_node(FZ_CMD_STROKE_PATH, ctm, colorspace, color, alpha); + node->rect = fz_bound_path(path, stroke, ctm); + node->item.path = fz_clone_path(path); + node->stroke = fz_clone_stroke_state(stroke); + fz_append_display_node(user, node); } static void -fz_listclippath(void *user, fz_path *path, int evenodd, fz_matrix ctm) +fz_list_clip_path(void *user, fz_path *path, int even_odd, fz_matrix ctm) { - fz_displaynode *node; - node = fz_newdisplaynode(FZ_CMDCLIPPATH, ctm, nil, nil, 0); - node->rect = fz_boundpath(path, nil, ctm); - node->item.path = fz_clonepath(path); - node->flag = evenodd; - fz_appenddisplaynode(user, node); + fz_display_node *node; + node = fz_new_display_node(FZ_CMD_CLIP_PATH, ctm, NULL, NULL, 0); + node->rect = fz_bound_path(path, NULL, ctm); + node->item.path = fz_clone_path(path); + node->flag = even_odd; + fz_append_display_node(user, node); } static void -fz_listclipstrokepath(void *user, fz_path *path, fz_strokestate *stroke, fz_matrix ctm) +fz_list_clip_stroke_path(void *user, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm) { - fz_displaynode *node; - node = fz_newdisplaynode(FZ_CMDCLIPSTROKEPATH, ctm, nil, nil, 0); - node->rect = fz_boundpath(path, stroke, ctm); - node->item.path = fz_clonepath(path); - node->stroke = fz_clonestrokestate(stroke); - fz_appenddisplaynode(user, node); + fz_display_node *node; + node = fz_new_display_node(FZ_CMD_CLIP_STROKE_PATH, ctm, NULL, NULL, 0); + node->rect = fz_bound_path(path, stroke, ctm); + node->item.path = fz_clone_path(path); + node->stroke = fz_clone_stroke_state(stroke); + fz_append_display_node(user, node); } static void -fz_listfilltext(void *user, fz_text *text, fz_matrix ctm, +fz_list_fill_text(void *user, fz_text *text, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { - fz_displaynode *node; - node = fz_newdisplaynode(FZ_CMDFILLTEXT, ctm, colorspace, color, alpha); - node->rect = fz_boundtext(text, ctm); - node->item.text = fz_clonetext(text); - fz_appenddisplaynode(user, node); + fz_display_node *node; + node = fz_new_display_node(FZ_CMD_FILL_TEXT, ctm, colorspace, color, alpha); + node->rect = fz_bound_text(text, ctm); + node->item.text = fz_clone_text(text); + fz_append_display_node(user, node); } static void -fz_liststroketext(void *user, fz_text *text, fz_strokestate *stroke, fz_matrix ctm, +fz_list_stroke_text(void *user, fz_text *text, fz_stroke_state *stroke, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { - fz_displaynode *node; - node = fz_newdisplaynode(FZ_CMDSTROKETEXT, ctm, colorspace, color, alpha); - node->rect = fz_boundtext(text, ctm); - node->item.text = fz_clonetext(text); - node->stroke = fz_clonestrokestate(stroke); - fz_appenddisplaynode(user, node); + fz_display_node *node; + node = fz_new_display_node(FZ_CMD_STROKE_TEXT, ctm, colorspace, color, alpha); + node->rect = fz_bound_text(text, ctm); + node->item.text = fz_clone_text(text); + node->stroke = fz_clone_stroke_state(stroke); + fz_append_display_node(user, node); } static void -fz_listcliptext(void *user, fz_text *text, fz_matrix ctm, int accumulate) +fz_list_clip_text(void *user, fz_text *text, fz_matrix ctm, int accumulate) { - fz_displaynode *node; - node = fz_newdisplaynode(FZ_CMDCLIPTEXT, ctm, nil, nil, 0); - node->rect = fz_boundtext(text, ctm); - node->item.text = fz_clonetext(text); + fz_display_node *node; + node = fz_new_display_node(FZ_CMD_CLIP_TEXT, ctm, NULL, NULL, 0); + node->rect = fz_bound_text(text, ctm); + node->item.text = fz_clone_text(text); node->flag = accumulate; /* when accumulating, be conservative about culling */ if (accumulate) - node->rect = fz_infiniterect; - fz_appenddisplaynode(user, node); + node->rect = fz_infinite_rect; + fz_append_display_node(user, node); } static void -fz_listclipstroketext(void *user, fz_text *text, fz_strokestate *stroke, fz_matrix ctm) +fz_list_clip_stroke_text(void *user, fz_text *text, fz_stroke_state *stroke, fz_matrix ctm) { - fz_displaynode *node; - node = fz_newdisplaynode(FZ_CMDCLIPSTROKETEXT, ctm, nil, nil, 0); - node->rect = fz_boundtext(text, ctm); - node->item.text = fz_clonetext(text); - node->stroke = fz_clonestrokestate(stroke); - fz_appenddisplaynode(user, node); + fz_display_node *node; + node = fz_new_display_node(FZ_CMD_CLIP_STROKE_TEXT, ctm, NULL, NULL, 0); + node->rect = fz_bound_text(text, ctm); + node->item.text = fz_clone_text(text); + node->stroke = fz_clone_stroke_state(stroke); + fz_append_display_node(user, node); } static void -fz_listignoretext(void *user, fz_text *text, fz_matrix ctm) +fz_list_ignore_text(void *user, fz_text *text, fz_matrix ctm) { - fz_displaynode *node; - node = fz_newdisplaynode(FZ_CMDIGNORETEXT, ctm, nil, nil, 0); - node->rect = fz_boundtext(text, ctm); - node->item.text = fz_clonetext(text); - fz_appenddisplaynode(user, node); + fz_display_node *node; + node = fz_new_display_node(FZ_CMD_IGNORE_TEXT, ctm, NULL, NULL, 0); + node->rect = fz_bound_text(text, ctm); + node->item.text = fz_clone_text(text); + fz_append_display_node(user, node); } static void -fz_listpopclip(void *user) +fz_list_pop_clip(void *user) { - fz_displaynode *node; - node = fz_newdisplaynode(FZ_CMDPOPCLIP, fz_identity, nil, nil, 0); + fz_display_node *node; + node = fz_new_display_node(FZ_CMD_POP_CLIP, fz_identity, NULL, NULL, 0); /* TODO: scan back for matching pushclip and calculate bbox of contents */ - fz_appenddisplaynode(user, node); + fz_append_display_node(user, node); } static void -fz_listfillshade(void *user, fz_shade *shade, fz_matrix ctm, float alpha) +fz_list_fill_shade(void *user, fz_shade *shade, fz_matrix ctm, float alpha) { - fz_displaynode *node; - node = fz_newdisplaynode(FZ_CMDFILLSHADE, ctm, nil, nil, alpha); - node->rect = fz_boundshade(shade, ctm); - node->item.shade = fz_keepshade(shade); - fz_appenddisplaynode(user, node); + fz_display_node *node; + node = fz_new_display_node(FZ_CMD_FILL_SHADE, ctm, NULL, NULL, alpha); + node->rect = fz_bound_shade(shade, ctm); + node->item.shade = fz_keep_shade(shade); + fz_append_display_node(user, node); } static void -fz_listfillimage(void *user, fz_pixmap *image, fz_matrix ctm, float alpha) +fz_list_fill_image(void *user, fz_pixmap *image, fz_matrix ctm, float alpha) { - fz_displaynode *node; - node = fz_newdisplaynode(FZ_CMDFILLIMAGE, ctm, nil, nil, alpha); - node->rect = fz_transformrect(ctm, fz_unitrect); - node->item.image = fz_keeppixmap(image); - fz_appenddisplaynode(user, node); + fz_display_node *node; + node = fz_new_display_node(FZ_CMD_FILL_IMAGE, ctm, NULL, NULL, alpha); + node->rect = fz_transform_rect(ctm, fz_unit_rect); + node->item.image = fz_keep_pixmap(image); + fz_append_display_node(user, node); } static void -fz_listfillimagemask(void *user, fz_pixmap *image, fz_matrix ctm, +fz_list_fill_image_mask(void *user, fz_pixmap *image, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { - fz_displaynode *node; - node = fz_newdisplaynode(FZ_CMDFILLIMAGEMASK, ctm, colorspace, color, alpha); - node->rect = fz_transformrect(ctm, fz_unitrect); - node->item.image = fz_keeppixmap(image); - fz_appenddisplaynode(user, node); + fz_display_node *node; + node = fz_new_display_node(FZ_CMD_FILL_IMAGE_MASK, ctm, colorspace, color, alpha); + node->rect = fz_transform_rect(ctm, fz_unit_rect); + node->item.image = fz_keep_pixmap(image); + fz_append_display_node(user, node); } static void -fz_listclipimagemask(void *user, fz_pixmap *image, fz_matrix ctm) +fz_list_clip_image_mask(void *user, fz_pixmap *image, fz_matrix ctm) { - fz_displaynode *node; - node = fz_newdisplaynode(FZ_CMDCLIPIMAGEMASK, ctm, nil, nil, 0); - node->rect = fz_transformrect(ctm, fz_unitrect); - node->item.image = fz_keeppixmap(image); - fz_appenddisplaynode(user, node); + fz_display_node *node; + node = fz_new_display_node(FZ_CMD_CLIP_IMAGE_MASK, ctm, NULL, NULL, 0); + node->rect = fz_transform_rect(ctm, fz_unit_rect); + node->item.image = fz_keep_pixmap(image); + fz_append_display_node(user, node); } static void -fz_listbeginmask(void *user, fz_rect rect, int luminosity, fz_colorspace *colorspace, float *color) +fz_list_begin_mask(void *user, fz_rect rect, int luminosity, fz_colorspace *colorspace, float *color) { - fz_displaynode *node; - node = fz_newdisplaynode(FZ_CMDBEGINMASK, fz_identity, colorspace, color, 0); + fz_display_node *node; + node = fz_new_display_node(FZ_CMD_BEGIN_MASK, fz_identity, colorspace, color, 0); node->rect = rect; node->flag = luminosity; - fz_appenddisplaynode(user, node); + fz_append_display_node(user, node); } static void -fz_listendmask(void *user) +fz_list_end_mask(void *user) { - fz_displaynode *node; - node = fz_newdisplaynode(FZ_CMDENDMASK, fz_identity, nil, nil, 0); - fz_appenddisplaynode(user, node); + fz_display_node *node; + node = fz_new_display_node(FZ_CMD_END_MASK, fz_identity, NULL, NULL, 0); + fz_append_display_node(user, node); } static void -fz_listbegingroup(void *user, fz_rect rect, int isolated, int knockout, fz_blendmode blendmode, float alpha) +fz_list_begin_group(void *user, fz_rect rect, int isolated, int knockout, fz_blendmode blendmode, float alpha) { - fz_displaynode *node; - node = fz_newdisplaynode(FZ_CMDBEGINGROUP, fz_identity, nil, nil, alpha); + fz_display_node *node; + node = fz_new_display_node(FZ_CMD_BEGIN_GROUP, fz_identity, NULL, NULL, alpha); node->rect = rect; node->item.blendmode = blendmode; node->flag |= isolated ? ISOLATED : 0; node->flag |= knockout ? KNOCKOUT : 0; - fz_appenddisplaynode(user, node); + fz_append_display_node(user, node); } static void -fz_listendgroup(void *user) +fz_list_end_group(void *user) { - fz_displaynode *node; - node = fz_newdisplaynode(FZ_CMDENDGROUP, fz_identity, nil, nil, 0); - fz_appenddisplaynode(user, node); + fz_display_node *node; + node = fz_new_display_node(FZ_CMD_END_GROUP, fz_identity, NULL, NULL, 0); + fz_append_display_node(user, node); } static void -fz_listbegintile(void *user, fz_rect area, fz_rect view, float xstep, float ystep, fz_matrix ctm) +fz_list_begin_tile(void *user, fz_rect area, fz_rect view, float xstep, float ystep, fz_matrix ctm) { - fz_displaynode *node; - node = fz_newdisplaynode(FZ_CMDBEGINTILE, ctm, nil, nil, 0); + fz_display_node *node; + node = fz_new_display_node(FZ_CMD_BEGIN_TILE, ctm, NULL, NULL, 0); node->rect = area; node->color[0] = xstep; node->color[1] = ystep; @@ -305,82 +305,82 @@ fz_listbegintile(void *user, fz_rect area, fz_rect view, float xstep, float yste node->color[3] = view.y0; node->color[4] = view.x1; node->color[5] = view.y1; - fz_appenddisplaynode(user, node); + fz_append_display_node(user, node); } static void -fz_listendtile(void *user) +fz_list_end_tile(void *user) { - fz_displaynode *node; - node = fz_newdisplaynode(FZ_CMDENDTILE, fz_identity, nil, nil, 0); - fz_appenddisplaynode(user, node); + fz_display_node *node; + node = fz_new_display_node(FZ_CMD_END_TILE, fz_identity, NULL, NULL, 0); + fz_append_display_node(user, node); } fz_device * -fz_newlistdevice(fz_displaylist *list) +fz_new_list_device(fz_display_list *list) { - fz_device *dev = fz_newdevice(list); + fz_device *dev = fz_new_device(list); - dev->fillpath = fz_listfillpath; - dev->strokepath = fz_liststrokepath; - dev->clippath = fz_listclippath; - dev->clipstrokepath = fz_listclipstrokepath; + dev->fill_path = fz_list_fill_path; + dev->stroke_path = fz_list_stroke_path; + dev->clip_path = fz_list_clip_path; + dev->clip_stroke_path = fz_list_clip_stroke_path; - dev->filltext = fz_listfilltext; - dev->stroketext = fz_liststroketext; - dev->cliptext = fz_listcliptext; - dev->clipstroketext = fz_listclipstroketext; - dev->ignoretext = fz_listignoretext; + dev->fill_text = fz_list_fill_text; + dev->stroke_text = fz_list_stroke_text; + dev->clip_text = fz_list_clip_text; + dev->clip_stroke_text = fz_list_clip_stroke_text; + dev->ignore_text = fz_list_ignore_text; - dev->fillshade = fz_listfillshade; - dev->fillimage = fz_listfillimage; - dev->fillimagemask = fz_listfillimagemask; - dev->clipimagemask = fz_listclipimagemask; + dev->fill_shade = fz_list_fill_shade; + dev->fill_image = fz_list_fill_image; + dev->fill_image_mask = fz_list_fill_image_mask; + dev->clip_image_mask = fz_list_clip_image_mask; - dev->popclip = fz_listpopclip; + dev->pop_clip = fz_list_pop_clip; - dev->beginmask = fz_listbeginmask; - dev->endmask = fz_listendmask; - dev->begingroup = fz_listbegingroup; - dev->endgroup = fz_listendgroup; + dev->begin_mask = fz_list_begin_mask; + dev->end_mask = fz_list_end_mask; + dev->begin_group = fz_list_begin_group; + dev->end_group = fz_list_end_group; - dev->begintile = fz_listbegintile; - dev->endtile = fz_listendtile; + dev->begin_tile = fz_list_begin_tile; + dev->end_tile = fz_list_end_tile; return dev; } -fz_displaylist * -fz_newdisplaylist(void) +fz_display_list * +fz_new_display_list(void) { - fz_displaylist *list = fz_malloc(sizeof(fz_displaylist)); - list->first = nil; - list->last = nil; + fz_display_list *list = fz_malloc(sizeof(fz_display_list)); + list->first = NULL; + list->last = NULL; return list; } void -fz_freedisplaylist(fz_displaylist *list) +fz_free_display_list(fz_display_list *list) { - fz_displaynode *node = list->first; + fz_display_node *node = list->first; while (node) { - fz_displaynode *next = node->next; - fz_freedisplaynode(node); + fz_display_node *next = node->next; + fz_free_display_node(node); node = next; } fz_free(list); } void -fz_executedisplaylist(fz_displaylist *list, fz_device *dev, fz_matrix topctm, fz_bbox bounds) +fz_execute_display_list(fz_display_list *list, fz_device *dev, fz_matrix top_ctm, fz_bbox bounds) { - fz_displaynode *node; + fz_display_node *node; fz_rect bbox; int clipped = 0; int tiled = 0; - if (!fz_isinfinitebbox(bounds)) + if (!fz_is_infinite_bbox(bounds)) { /* add some fuzz at the edges, as especially glyph rects * are sometimes not actually completely bounding the glyph */ @@ -390,40 +390,40 @@ fz_executedisplaylist(fz_displaylist *list, fz_device *dev, fz_matrix topctm, fz for (node = list->first; node; node = node->next) { - fz_matrix ctm = fz_concat(node->ctm, topctm); - fz_rect rect = fz_transformrect(topctm, node->rect); + fz_matrix ctm = fz_concat(node->ctm, top_ctm); + fz_rect rect = fz_transform_rect(top_ctm, node->rect); /* never skip tiles */ if (tiled) goto visible; /* cull objects to draw using a quick visibility test */ - if (clipped || fz_isemptybbox(fz_intersectbbox(fz_roundrect(rect), bounds))) + if (clipped || fz_is_empty_bbox(fz_intersect_bbox(fz_round_rect(rect), bounds))) { switch (node->cmd) { - case FZ_CMDBEGINTILE: + case FZ_CMD_BEGIN_TILE: tiled++; goto visible; - case FZ_CMDENDTILE: + case FZ_CMD_END_TILE: tiled--; goto visible; - case FZ_CMDCLIPPATH: - case FZ_CMDCLIPSTROKEPATH: - case FZ_CMDCLIPTEXT: - case FZ_CMDCLIPSTROKETEXT: - case FZ_CMDCLIPIMAGEMASK: - case FZ_CMDBEGINMASK: - case FZ_CMDBEGINGROUP: + case FZ_CMD_CLIP_PATH: + case FZ_CMD_CLIP_STROKE_PATH: + case FZ_CMD_CLIP_TEXT: + case FZ_CMD_CLIP_STROKE_TEXT: + case FZ_CMD_CLIP_IMAGE_MASK: + case FZ_CMD_BEGIN_MASK: + case FZ_CMD_BEGIN_GROUP: clipped++; continue; - case FZ_CMDPOPCLIP: - case FZ_CMDENDGROUP: + case FZ_CMD_POP_CLIP: + case FZ_CMD_END_GROUP: if (!clipped) goto visible; clipped--; continue; - case FZ_CMDENDMASK: + case FZ_CMD_END_MASK: if (!clipped) goto visible; continue; @@ -435,79 +435,79 @@ fz_executedisplaylist(fz_displaylist *list, fz_device *dev, fz_matrix topctm, fz visible: switch (node->cmd) { - case FZ_CMDFILLPATH: - dev->fillpath(dev->user, node->item.path, node->flag, ctm, + case FZ_CMD_FILL_PATH: + dev->fill_path(dev->user, node->item.path, node->flag, ctm, node->colorspace, node->color, node->alpha); break; - case FZ_CMDSTROKEPATH: - dev->strokepath(dev->user, node->item.path, node->stroke, ctm, + case FZ_CMD_STROKE_PATH: + dev->stroke_path(dev->user, node->item.path, node->stroke, ctm, node->colorspace, node->color, node->alpha); break; - case FZ_CMDCLIPPATH: - dev->clippath(dev->user, node->item.path, node->flag, ctm); + case FZ_CMD_CLIP_PATH: + dev->clip_path(dev->user, node->item.path, node->flag, ctm); break; - case FZ_CMDCLIPSTROKEPATH: - dev->clipstrokepath(dev->user, node->item.path, node->stroke, ctm); + case FZ_CMD_CLIP_STROKE_PATH: + dev->clip_stroke_path(dev->user, node->item.path, node->stroke, ctm); break; - case FZ_CMDFILLTEXT: - dev->filltext(dev->user, node->item.text, ctm, + case FZ_CMD_FILL_TEXT: + dev->fill_text(dev->user, node->item.text, ctm, node->colorspace, node->color, node->alpha); break; - case FZ_CMDSTROKETEXT: - dev->stroketext(dev->user, node->item.text, node->stroke, ctm, + case FZ_CMD_STROKE_TEXT: + dev->stroke_text(dev->user, node->item.text, node->stroke, ctm, node->colorspace, node->color, node->alpha); break; - case FZ_CMDCLIPTEXT: - dev->cliptext(dev->user, node->item.text, ctm, node->flag); + case FZ_CMD_CLIP_TEXT: + dev->clip_text(dev->user, node->item.text, ctm, node->flag); break; - case FZ_CMDCLIPSTROKETEXT: - dev->clipstroketext(dev->user, node->item.text, node->stroke, ctm); + case FZ_CMD_CLIP_STROKE_TEXT: + dev->clip_stroke_text(dev->user, node->item.text, node->stroke, ctm); break; - case FZ_CMDIGNORETEXT: - dev->ignoretext(dev->user, node->item.text, ctm); + case FZ_CMD_IGNORE_TEXT: + dev->ignore_text(dev->user, node->item.text, ctm); break; - case FZ_CMDFILLSHADE: - dev->fillshade(dev->user, node->item.shade, ctm, node->alpha); + case FZ_CMD_FILL_SHADE: + dev->fill_shade(dev->user, node->item.shade, ctm, node->alpha); break; - case FZ_CMDFILLIMAGE: - dev->fillimage(dev->user, node->item.image, ctm, node->alpha); + case FZ_CMD_FILL_IMAGE: + dev->fill_image(dev->user, node->item.image, ctm, node->alpha); break; - case FZ_CMDFILLIMAGEMASK: - dev->fillimagemask(dev->user, node->item.image, ctm, + case FZ_CMD_FILL_IMAGE_MASK: + dev->fill_image_mask(dev->user, node->item.image, ctm, node->colorspace, node->color, node->alpha); break; - case FZ_CMDCLIPIMAGEMASK: - dev->clipimagemask(dev->user, node->item.image, ctm); + case FZ_CMD_CLIP_IMAGE_MASK: + dev->clip_image_mask(dev->user, node->item.image, ctm); break; - case FZ_CMDPOPCLIP: - dev->popclip(dev->user); + case FZ_CMD_POP_CLIP: + dev->pop_clip(dev->user); break; - case FZ_CMDBEGINMASK: - bbox = fz_transformrect(topctm, node->rect); - dev->beginmask(dev->user, bbox, node->flag, node->colorspace, node->color); + case FZ_CMD_BEGIN_MASK: + bbox = fz_transform_rect(top_ctm, node->rect); + dev->begin_mask(dev->user, bbox, node->flag, node->colorspace, node->color); break; - case FZ_CMDENDMASK: - dev->endmask(dev->user); + case FZ_CMD_END_MASK: + dev->end_mask(dev->user); break; - case FZ_CMDBEGINGROUP: - bbox = fz_transformrect(topctm, node->rect); - dev->begingroup(dev->user, bbox, + case FZ_CMD_BEGIN_GROUP: + bbox = fz_transform_rect(top_ctm, node->rect); + dev->begin_group(dev->user, bbox, node->flag & ISOLATED, node->flag & KNOCKOUT, node->item.blendmode, node->alpha); break; - case FZ_CMDENDGROUP: - dev->endgroup(dev->user); + case FZ_CMD_END_GROUP: + dev->end_group(dev->user); break; - case FZ_CMDBEGINTILE: + case FZ_CMD_BEGIN_TILE: bbox.x0 = node->color[2]; bbox.y0 = node->color[3]; bbox.x1 = node->color[4]; bbox.y1 = node->color[5]; - dev->begintile(dev->user, node->rect, bbox, + dev->begin_tile(dev->user, node->rect, bbox, node->color[0], node->color[1], ctm); break; - case FZ_CMDENDTILE: - dev->endtile(dev->user); + case FZ_CMD_END_TILE: + dev->end_tile(dev->user); break; } } diff --git a/fitz/dev_null.c b/fitz/dev_null.c index 2d20a966..dcb43292 100644 --- a/fitz/dev_null.c +++ b/fitz/dev_null.c @@ -1,29 +1,29 @@ #include "fitz.h" -static void fz_nullfreeuser(void *user) {} -static void fz_nullfillpath(void *user, fz_path *path, int evenodd, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) {} -static void fz_nullstrokepath(void *user, fz_path *path, fz_strokestate *stroke, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) {} -static void fz_nullclippath(void *user, fz_path *path, int evenodd, fz_matrix ctm) {} -static void fz_nullclipstrokepath(void *user, fz_path *path, fz_strokestate *stroke, fz_matrix ctm) {} -static void fz_nullfilltext(void *user, fz_text *text, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) {} -static void fz_nullstroketext(void *user, fz_text *text, fz_strokestate *stroke, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) {} -static void fz_nullcliptext(void *user, fz_text *text, fz_matrix ctm, int accumulate) {} -static void fz_nullclipstroketext(void *user, fz_text *text, fz_strokestate *stroke, fz_matrix ctm) {} -static void fz_nullignoretext(void *user, fz_text *text, fz_matrix ctm) {} -static void fz_nullpopclip(void *user) {} -static void fz_nullfillshade(void *user, fz_shade *shade, fz_matrix ctm, float alpha) {} -static void fz_nullfillimage(void *user, fz_pixmap *image, fz_matrix ctm, float alpha) {} -static void fz_nullfillimagemask(void *user, fz_pixmap *image, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) {} -static void fz_nullclipimagemask(void *user, fz_pixmap *image, fz_matrix ctm) {} -static void fz_nullbeginmask(void *user, fz_rect r, int luminosity, fz_colorspace *colorspace, float *bc) {} -static void fz_nullendmask(void *user) {} -static void fz_nullbegingroup(void *user, fz_rect r, int isolated, int knockout, fz_blendmode blendmode, float alpha) {} -static void fz_nullendgroup(void *user) {} -static void fz_nullbegintile(void *user, fz_rect area, fz_rect view, float xstep, float ystep, fz_matrix ctm) {} -static void fz_nullendtile(void *user) {} +static void fz_null_free_user(void *user) {} +static void fz_null_fill_path(void *user, fz_path *path, int even_odd, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) {} +static void fz_null_stroke_path(void *user, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) {} +static void fz_null_clip_path(void *user, fz_path *path, int even_odd, fz_matrix ctm) {} +static void fz_null_clip_stroke_path(void *user, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm) {} +static void fz_null_fill_text(void *user, fz_text *text, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) {} +static void fz_null_stroke_text(void *user, fz_text *text, fz_stroke_state *stroke, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) {} +static void fz_null_clip_text(void *user, fz_text *text, fz_matrix ctm, int accumulate) {} +static void fz_null_clip_stroke_text(void *user, fz_text *text, fz_stroke_state *stroke, fz_matrix ctm) {} +static void fz_null_ignore_text(void *user, fz_text *text, fz_matrix ctm) {} +static void fz_null_pop_clip(void *user) {} +static void fz_null_fill_shade(void *user, fz_shade *shade, fz_matrix ctm, float alpha) {} +static void fz_null_fill_image(void *user, fz_pixmap *image, fz_matrix ctm, float alpha) {} +static void fz_null_fill_image_mask(void *user, fz_pixmap *image, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) {} +static void fz_null_clip_image_mask(void *user, fz_pixmap *image, fz_matrix ctm) {} +static void fz_null_begin_mask(void *user, fz_rect r, int luminosity, fz_colorspace *colorspace, float *bc) {} +static void fz_null_end_mask(void *user) {} +static void fz_null_begin_group(void *user, fz_rect r, int isolated, int knockout, fz_blendmode blendmode, float alpha) {} +static void fz_null_end_group(void *user) {} +static void fz_null_begin_tile(void *user, fz_rect area, fz_rect view, float xstep, float ystep, fz_matrix ctm) {} +static void fz_null_end_tile(void *user) {} fz_device * -fz_newdevice(void *user) +fz_new_device(void *user) { fz_device *dev = fz_malloc(sizeof(fz_device)); memset(dev, 0, sizeof(fz_device)); @@ -31,41 +31,41 @@ fz_newdevice(void *user) dev->hints = 0; dev->user = user; - dev->freeuser = fz_nullfreeuser; + dev->free_user = fz_null_free_user; - dev->fillpath = fz_nullfillpath; - dev->strokepath = fz_nullstrokepath; - dev->clippath = fz_nullclippath; - dev->clipstrokepath = fz_nullclipstrokepath; + dev->fill_path = fz_null_fill_path; + dev->stroke_path = fz_null_stroke_path; + dev->clip_path = fz_null_clip_path; + dev->clip_stroke_path = fz_null_clip_stroke_path; - dev->filltext = fz_nullfilltext; - dev->stroketext = fz_nullstroketext; - dev->cliptext = fz_nullcliptext; - dev->clipstroketext = fz_nullclipstroketext; - dev->ignoretext = fz_nullignoretext; + dev->fill_text = fz_null_fill_text; + dev->stroke_text = fz_null_stroke_text; + dev->clip_text = fz_null_clip_text; + dev->clip_stroke_text = fz_null_clip_stroke_text; + dev->ignore_text = fz_null_ignore_text; - dev->fillshade = fz_nullfillshade; - dev->fillimage = fz_nullfillimage; - dev->fillimagemask = fz_nullfillimagemask; - dev->clipimagemask = fz_nullclipimagemask; + dev->fill_shade = fz_null_fill_shade; + dev->fill_image = fz_null_fill_image; + dev->fill_image_mask = fz_null_fill_image_mask; + dev->clip_image_mask = fz_null_clip_image_mask; - dev->popclip = fz_nullpopclip; + dev->pop_clip = fz_null_pop_clip; - dev->beginmask = fz_nullbeginmask; - dev->endmask = fz_nullendmask; - dev->begingroup = fz_nullbegingroup; - dev->endgroup = fz_nullendgroup; + dev->begin_mask = fz_null_begin_mask; + dev->end_mask = fz_null_end_mask; + dev->begin_group = fz_null_begin_group; + dev->end_group = fz_null_end_group; - dev->begintile = fz_nullbegintile; - dev->endtile = fz_nullendtile; + dev->begin_tile = fz_null_begin_tile; + dev->end_tile = fz_null_end_tile; return dev; } void -fz_freedevice(fz_device *dev) +fz_free_device(fz_device *dev) { - if (dev->freeuser) - dev->freeuser(dev->user); + if (dev->free_user) + dev->free_user(dev->user); fz_free(dev); } diff --git a/fitz/dev_text.c b/fitz/dev_text.c index c59a36f7..139c3eed 100644 --- a/fitz/dev_text.c +++ b/fitz/dev_text.c @@ -1,55 +1,55 @@ #include "fitz.h" -#define LINEDIST 0.9f -#define SPACEDIST 0.2f +#define LINE_DIST 0.9f +#define SPACE_DIST 0.2f #include #include FT_FREETYPE_H #include FT_ADVANCES_H -typedef struct fz_textdevice_s fz_textdevice; +typedef struct fz_text_device_s fz_text_device; -struct fz_textdevice_s +struct fz_text_device_s { fz_point point; - fz_textspan *head; - fz_textspan *span; + fz_text_span *head; + fz_text_span *span; }; -fz_textspan * -fz_newtextspan(void) +fz_text_span * +fz_new_text_span(void) { - fz_textspan *span; - span = fz_malloc(sizeof(fz_textspan)); - span->font = nil; + fz_text_span *span; + span = fz_malloc(sizeof(fz_text_span)); + span->font = NULL; span->wmode = 0; span->size = 0; span->len = 0; span->cap = 0; - span->text = nil; - span->next = nil; + span->text = NULL; + span->next = NULL; span->eol = 0; return span; } void -fz_freetextspan(fz_textspan *span) +fz_free_text_span(fz_text_span *span) { if (span->font) - fz_dropfont(span->font); + fz_drop_font(span->font); if (span->next) - fz_freetextspan(span->next); + fz_free_text_span(span->next); fz_free(span->text); fz_free(span); } static void -fz_addtextcharimp(fz_textspan *span, int c, fz_bbox bbox) +fz_add_text_char_imp(fz_text_span *span, int c, fz_bbox bbox) { if (span->len + 1 >= span->cap) { span->cap = span->cap > 1 ? (span->cap * 3) / 2 : 80; - span->text = fz_realloc(span->text, span->cap, sizeof(fz_textchar)); + span->text = fz_realloc(span->text, span->cap, sizeof(fz_text_char)); } span->text[span->len].c = c; span->text[span->len].bbox = bbox; @@ -57,7 +57,7 @@ fz_addtextcharimp(fz_textspan *span, int c, fz_bbox bbox) } static fz_bbox -fz_splitbbox(fz_bbox bbox, int i, int n) +fz_split_bbox(fz_bbox bbox, int i, int n) { float w = (float)(bbox.x1 - bbox.x0) / n; float x0 = bbox.x0; @@ -67,20 +67,20 @@ fz_splitbbox(fz_bbox bbox, int i, int n) } static void -fz_addtextchar(fz_textspan **last, fz_font *font, float size, int wmode, int c, fz_bbox bbox) +fz_add_text_char(fz_text_span **last, fz_font *font, float size, int wmode, int c, fz_bbox bbox) { - fz_textspan *span = *last; + fz_text_span *span = *last; if (!span->font) { - span->font = fz_keepfont(font); + span->font = fz_keep_font(font); span->size = size; } if ((span->font != font || span->size != size || span->wmode != wmode) && c != 32) { - span = fz_newtextspan(); - span->font = fz_keepfont(font); + span = fz_new_text_span(); + span->font = fz_keep_font(font); span->size = size; span->wmode = wmode; (*last)->next = span; @@ -92,55 +92,55 @@ fz_addtextchar(fz_textspan **last, fz_font *font, float size, int wmode, int c, case -1: /* ignore when one unicode character maps to multiple glyphs */ break; case 0xFB00: /* ff */ - fz_addtextcharimp(span, 'f', fz_splitbbox(bbox, 0, 2)); - fz_addtextcharimp(span, 'f', fz_splitbbox(bbox, 1, 2)); + fz_add_text_char_imp(span, 'f', fz_split_bbox(bbox, 0, 2)); + fz_add_text_char_imp(span, 'f', fz_split_bbox(bbox, 1, 2)); break; case 0xFB01: /* fi */ - fz_addtextcharimp(span, 'f', fz_splitbbox(bbox, 0, 2)); - fz_addtextcharimp(span, 'i', fz_splitbbox(bbox, 1, 2)); + fz_add_text_char_imp(span, 'f', fz_split_bbox(bbox, 0, 2)); + fz_add_text_char_imp(span, 'i', fz_split_bbox(bbox, 1, 2)); break; case 0xFB02: /* fl */ - fz_addtextcharimp(span, 'f', fz_splitbbox(bbox, 0, 2)); - fz_addtextcharimp(span, 'l', fz_splitbbox(bbox, 1, 2)); + fz_add_text_char_imp(span, 'f', fz_split_bbox(bbox, 0, 2)); + fz_add_text_char_imp(span, 'l', fz_split_bbox(bbox, 1, 2)); break; case 0xFB03: /* ffi */ - fz_addtextcharimp(span, 'f', fz_splitbbox(bbox, 0, 3)); - fz_addtextcharimp(span, 'f', fz_splitbbox(bbox, 1, 3)); - fz_addtextcharimp(span, 'i', fz_splitbbox(bbox, 2, 3)); + fz_add_text_char_imp(span, 'f', fz_split_bbox(bbox, 0, 3)); + fz_add_text_char_imp(span, 'f', fz_split_bbox(bbox, 1, 3)); + fz_add_text_char_imp(span, 'i', fz_split_bbox(bbox, 2, 3)); break; case 0xFB04: /* ffl */ - fz_addtextcharimp(span, 'f', fz_splitbbox(bbox, 0, 3)); - fz_addtextcharimp(span, 'f', fz_splitbbox(bbox, 1, 3)); - fz_addtextcharimp(span, 'l', fz_splitbbox(bbox, 2, 3)); + fz_add_text_char_imp(span, 'f', fz_split_bbox(bbox, 0, 3)); + fz_add_text_char_imp(span, 'f', fz_split_bbox(bbox, 1, 3)); + fz_add_text_char_imp(span, 'l', fz_split_bbox(bbox, 2, 3)); break; case 0xFB05: /* long st */ case 0xFB06: /* st */ - fz_addtextcharimp(span, 's', fz_splitbbox(bbox, 0, 2)); - fz_addtextcharimp(span, 't', fz_splitbbox(bbox, 1, 2)); + fz_add_text_char_imp(span, 's', fz_split_bbox(bbox, 0, 2)); + fz_add_text_char_imp(span, 't', fz_split_bbox(bbox, 1, 2)); break; default: - fz_addtextcharimp(span, c, bbox); + fz_add_text_char_imp(span, c, bbox); break; } } static void -fz_dividetextchars(fz_textspan **last, int n, fz_bbox bbox) +fz_divide_text_chars(fz_text_span **last, int n, fz_bbox bbox) { - fz_textspan *span = *last; + fz_text_span *span = *last; int i, x; x = span->len - n; if (x >= 0) for (i = 0; i < n; i++) - span->text[x + i].bbox = fz_splitbbox(bbox, i, n); + span->text[x + i].bbox = fz_split_bbox(bbox, i, n); } static void -fz_addtextnewline(fz_textspan **last, fz_font *font, float size, int wmode) +fz_add_text_newline(fz_text_span **last, fz_font *font, float size, int wmode) { - fz_textspan *span; - span = fz_newtextspan(); - span->font = fz_keepfont(font); + fz_text_span *span; + span = fz_new_text_span(); + span->font = fz_keep_font(font); span->size = size; span->wmode = wmode; (*last)->eol = 1; @@ -149,7 +149,7 @@ fz_addtextnewline(fz_textspan **last, fz_font *font, float size, int wmode) } void -fz_debugtextspanxml(fz_textspan *span) +fz_debug_text_span_xml(fz_text_span *span) { char buf[10]; int c, n, k, i; @@ -179,11 +179,11 @@ fz_debugtextspanxml(fz_textspan *span) printf("\n"); if (span->next) - fz_debugtextspanxml(span->next); + fz_debug_text_span_xml(span->next); } void -fz_debugtextspan(fz_textspan *span) +fz_debug_text_span(fz_text_span *span) { char buf[10]; int c, n, k, i; @@ -205,14 +205,14 @@ fz_debugtextspan(fz_textspan *span) putchar('\n'); if (span->next) - fz_debugtextspan(span->next); + fz_debug_text_span(span->next); } static void -fz_textextractspan(fz_textspan **last, fz_text *text, fz_matrix ctm, fz_point *pen) +fz_text_extract_span(fz_text_span **last, fz_text *text, fz_matrix ctm, fz_point *pen) { fz_font *font = text->font; - FT_Face face = font->ftface; + FT_Face face = font->ft_face; fz_matrix tm = text->trm; fz_matrix trm; float size; @@ -229,16 +229,16 @@ fz_textextractspan(fz_textspan **last, fz_text *text, fz_matrix ctm, fz_point *p if (text->len == 0) return; - if (font->ftface) + if (font->ft_face) { - err = FT_Set_Char_Size(font->ftface, 64, 64, 72, 72); + err = FT_Set_Char_Size(font->ft_face, 64, 64, 72, 72); if (err) - fz_warn("freetype set character size: %s", ft_errorstring(err)); + fz_warn("freetype set character size: %s", ft_error_string(err)); ascender = (float)face->ascender / face->units_per_EM; descender = (float)face->descender / face->units_per_EM; } - rect = fz_emptyrect; + rect = fz_empty_rect; if (text->wmode == 0) { @@ -254,29 +254,29 @@ fz_textextractspan(fz_textspan **last, fz_text *text, fz_matrix ctm, fz_point *p tm.e = 0; tm.f = 0; trm = fz_concat(tm, ctm); - dir = fz_transformvector(trm, dir); + dir = fz_transform_vector(trm, dir); dist = sqrtf(dir.x * dir.x + dir.y * dir.y); ndir.x = dir.x / dist; ndir.y = dir.y / dist; - size = fz_matrixexpansion(trm); + size = fz_matrix_expansion(trm); multi = 1; for (i = 0; i < text->len; i++) { - if (text->els[i].gid < 0) + if (text->items[i].gid < 0) { - fz_addtextchar(last, font, size, text->wmode, text->els[i].ucs, fz_roundrect(rect)); + fz_add_text_char(last, font, size, text->wmode, text->items[i].ucs, fz_round_rect(rect)); multi ++; - fz_dividetextchars(last, multi, fz_roundrect(rect)); + fz_divide_text_chars(last, multi, fz_round_rect(rect)); continue; } multi = 1; /* Calculate new pen location and delta */ - tm.e = text->els[i].x; - tm.f = text->els[i].y; + tm.e = text->items[i].x; + tm.f = text->items[i].y; trm = fz_concat(tm, ctm); delta.x = pen->x - trm.e; @@ -293,11 +293,11 @@ fz_textextractspan(fz_textspan **last, fz_text *text, fz_matrix ctm, fz_point *p ndelta.y = delta.y / dist; dot = ndelta.x * ndir.x + ndelta.y * ndir.y; - if (dist > size * LINEDIST) + if (dist > size * LINE_DIST) { - fz_addtextnewline(last, font, size, text->wmode); + fz_add_text_newline(last, font, size, text->wmode); } - else if (fabsf(dot) > 0.95f && dist > size * SPACEDIST) + else if (fabsf(dot) > 0.95f && dist > size * SPACE_DIST) { if ((*last)->len > 0 && (*last)->text[(*last)->len - 1].c != ' ') { @@ -306,14 +306,14 @@ fz_textextractspan(fz_textspan **last, fz_text *text, fz_matrix ctm, fz_point *p spacerect.y0 = 0; spacerect.x1 = 0; spacerect.y1 = 1; - spacerect = fz_transformrect(trm, spacerect); - fz_addtextchar(last, font, size, text->wmode, ' ', fz_roundrect(spacerect)); + spacerect = fz_transform_rect(trm, spacerect); + fz_add_text_char(last, font, size, text->wmode, ' ', fz_round_rect(spacerect)); } } } /* Calculate bounding box and new pen position based on font metrics */ - if (font->ftface) + if (font->ft_face) { FT_Fixed ftadv = 0; int mask = FT_LOAD_NO_BITMAP | FT_LOAD_NO_HINTING | FT_LOAD_IGNORE_TRANSFORM; @@ -321,7 +321,7 @@ fz_textextractspan(fz_textspan **last, fz_text *text, fz_matrix ctm, fz_point *p /* TODO: freetype returns broken vertical metrics */ /* if (text->wmode) mask |= FT_LOAD_VERTICAL_LAYOUT; */ - FT_Get_Advance(font->ftface, text->els[i].gid, mask, &ftadv); + FT_Get_Advance(font->ft_face, text->items[i].gid, mask, &ftadv); adv = ftadv / 65536.0f; rect.x0 = 0; @@ -331,62 +331,62 @@ fz_textextractspan(fz_textspan **last, fz_text *text, fz_matrix ctm, fz_point *p } else { - adv = font->t3widths[text->els[i].gid]; + adv = font->t3widths[text->items[i].gid]; rect.x0 = 0; rect.y0 = descender; rect.x1 = adv; rect.y1 = ascender; } - rect = fz_transformrect(trm, rect); + rect = fz_transform_rect(trm, rect); pen->x = trm.e + dir.x * adv; pen->y = trm.f + dir.y * adv; - fz_addtextchar(last, font, size, text->wmode, text->els[i].ucs, fz_roundrect(rect)); + fz_add_text_char(last, font, size, text->wmode, text->items[i].ucs, fz_round_rect(rect)); } } static void -fz_textfilltext(void *user, fz_text *text, fz_matrix ctm, +fz_text_fill_text(void *user, fz_text *text, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { - fz_textdevice *tdev = user; - fz_textextractspan(&tdev->span, text, ctm, &tdev->point); + fz_text_device *tdev = user; + fz_text_extract_span(&tdev->span, text, ctm, &tdev->point); } static void -fz_textstroketext(void *user, fz_text *text, fz_strokestate *stroke, fz_matrix ctm, +fz_text_stroke_text(void *user, fz_text *text, fz_stroke_state *stroke, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { - fz_textdevice *tdev = user; - fz_textextractspan(&tdev->span, text, ctm, &tdev->point); + fz_text_device *tdev = user; + fz_text_extract_span(&tdev->span, text, ctm, &tdev->point); } static void -fz_textcliptext(void *user, fz_text *text, fz_matrix ctm, int accumulate) +fz_text_clip_text(void *user, fz_text *text, fz_matrix ctm, int accumulate) { - fz_textdevice *tdev = user; - fz_textextractspan(&tdev->span, text, ctm, &tdev->point); + fz_text_device *tdev = user; + fz_text_extract_span(&tdev->span, text, ctm, &tdev->point); } static void -fz_textclipstroketext(void *user, fz_text *text, fz_strokestate *stroke, fz_matrix ctm) +fz_text_clip_stroke_text(void *user, fz_text *text, fz_stroke_state *stroke, fz_matrix ctm) { - fz_textdevice *tdev = user; - fz_textextractspan(&tdev->span, text, ctm, &tdev->point); + fz_text_device *tdev = user; + fz_text_extract_span(&tdev->span, text, ctm, &tdev->point); } static void -fz_textignoretext(void *user, fz_text *text, fz_matrix ctm) +fz_text_ignore_text(void *user, fz_text *text, fz_matrix ctm) { - fz_textdevice *tdev = user; - fz_textextractspan(&tdev->span, text, ctm, &tdev->point); + fz_text_device *tdev = user; + fz_text_extract_span(&tdev->span, text, ctm, &tdev->point); } static void -fz_textfreeuser(void *user) +fz_text_free_user(void *user) { - fz_textdevice *tdev = user; + fz_text_device *tdev = user; tdev->span->eol = 1; @@ -397,22 +397,22 @@ fz_textfreeuser(void *user) } fz_device * -fz_newtextdevice(fz_textspan *root) +fz_new_text_device(fz_text_span *root) { fz_device *dev; - fz_textdevice *tdev = fz_malloc(sizeof(fz_textdevice)); + fz_text_device *tdev = fz_malloc(sizeof(fz_text_device)); tdev->head = root; tdev->span = root; tdev->point.x = -1; tdev->point.y = -1; - dev = fz_newdevice(tdev); - dev->hints = FZ_IGNOREIMAGE | FZ_IGNORESHADE; - dev->freeuser = fz_textfreeuser; - dev->filltext = fz_textfilltext; - dev->stroketext = fz_textstroketext; - dev->cliptext = fz_textcliptext; - dev->clipstroketext = fz_textclipstroketext; - dev->ignoretext = fz_textignoretext; + dev = fz_new_device(tdev); + dev->hints = FZ_IGNORE_IMAGE | FZ_IGNORE_SHADE; + dev->free_user = fz_text_free_user; + dev->fill_text = fz_text_fill_text; + dev->stroke_text = fz_text_stroke_text; + dev->clip_text = fz_text_clip_text; + dev->clip_stroke_text = fz_text_clip_stroke_text; + dev->ignore_text = fz_text_ignore_text; return dev; } diff --git a/fitz/dev_trace.c b/fitz/dev_trace.c index f8a94b43..2bc171de 100644 --- a/fitz/dev_trace.c +++ b/fitz/dev_trace.c @@ -1,14 +1,14 @@ #include "fitz.h" static void -fz_tracematrix(fz_matrix ctm) +fz_trace_matrix(fz_matrix ctm) { printf("matrix=\"%g %g %g %g %g %g\" ", ctm.a, ctm.b, ctm.c, ctm.d, ctm.e, ctm.f); } static void -fz_tracecolor(fz_colorspace *colorspace, float *color, float alpha) +fz_trace_color(fz_colorspace *colorspace, float *color, float alpha) { int i; printf("colorspace=\"%s\" color=\"", colorspace->name); @@ -20,7 +20,7 @@ fz_tracecolor(fz_colorspace *colorspace, float *color, float alpha) } static void -fz_tracepath(fz_path *path, int indent) +fz_trace_path(fz_path *path, int indent) { float x, y; int i = 0; @@ -29,30 +29,30 @@ fz_tracepath(fz_path *path, int indent) { for (n = 0; n < indent; n++) putchar(' '); - switch (path->els[i++].k) + switch (path->items[i++].k) { case FZ_MOVETO: - x = path->els[i++].v; - y = path->els[i++].v; + x = path->items[i++].v; + y = path->items[i++].v; printf("\n", x, y); break; case FZ_LINETO: - x = path->els[i++].v; - y = path->els[i++].v; + x = path->items[i++].v; + y = path->items[i++].v; printf("\n", x, y); break; case FZ_CURVETO: - x = path->els[i++].v; - y = path->els[i++].v; + x = path->items[i++].v; + y = path->items[i++].v; printf("els[i++].v; - y = path->els[i++].v; + x = path->items[i++].v; + y = path->items[i++].v; printf("x2=\"%g\" y2=\"%g\" ", x, y); - x = path->els[i++].v; - y = path->els[i++].v; + x = path->items[i++].v; + y = path->items[i++].v; printf("x3=\"%g\" y3=\"%g\" />\n", x, y); break; - case FZ_CLOSEPATH: + case FZ_CLOSE_PATH: printf("\n"); break; } @@ -60,245 +60,245 @@ fz_tracepath(fz_path *path, int indent) } static void -fz_tracefillpath(void *user, fz_path *path, int evenodd, fz_matrix ctm, +fz_trace_fill_path(void *user, fz_path *path, int even_odd, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { - printf("\n"); - fz_tracepath(path, 0); - printf("\n"); + fz_trace_path(path, 0); + printf("\n"); } static void -fz_tracestrokepath(void *user, fz_path *path, fz_strokestate *stroke, fz_matrix ctm, +fz_trace_stroke_path(void *user, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { int i; - printf("linewidth); printf("miterlimit=\"%g\" ", stroke->miterlimit); printf("linecap=\"%d\" ", stroke->linecap); printf("linejoin=\"%d\" ", stroke->linejoin); - if (stroke->dashlen) + if (stroke->dash_len) { - printf("dashphase=\"%g\" dash=\"", stroke->dashphase); - for (i = 0; i < stroke->dashlen; i++) - printf("%g ", stroke->dashlist[i]); + printf("dash_phase=\"%g\" dash=\"", stroke->dash_phase); + for (i = 0; i < stroke->dash_len; i++) + printf("%g ", stroke->dash_list[i]); printf("\""); } - fz_tracecolor(colorspace, color, alpha); - fz_tracematrix(ctm); + fz_trace_color(colorspace, color, alpha); + fz_trace_matrix(ctm); printf(">\n"); - fz_tracepath(path, 0); + fz_trace_path(path, 0); - printf("\n"); + printf("\n"); } static void -fz_traceclippath(void *user, fz_path *path, int evenodd, fz_matrix ctm) +fz_trace_clip_path(void *user, fz_path *path, int even_odd, fz_matrix ctm) { - printf("\n"); - fz_tracepath(path, 0); - printf("\n"); + fz_trace_path(path, 0); + printf("\n"); } static void -fz_traceclipstrokepath(void *user, fz_path *path, fz_strokestate *stroke, fz_matrix ctm) +fz_trace_clip_stroke_path(void *user, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm) { - printf("\n"); - fz_tracepath(path, 0); - printf("\n"); + fz_trace_path(path, 0); + printf("\n"); } static void -fz_tracefilltext(void *user, fz_text *text, fz_matrix ctm, +fz_trace_fill_text(void *user, fz_text *text, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { - printf("font->name, text->wmode); - fz_tracecolor(colorspace, color, alpha); - fz_tracematrix(fz_concat(ctm, text->trm)); + printf("font->name, text->wmode); + fz_trace_color(colorspace, color, alpha); + fz_trace_matrix(fz_concat(ctm, text->trm)); printf(">\n"); - fz_debugtext(text, 0); - printf("\n"); + fz_debug_text(text, 0); + printf("\n"); } static void -fz_tracestroketext(void *user, fz_text *text, fz_strokestate *stroke, fz_matrix ctm, +fz_trace_stroke_text(void *user, fz_text *text, fz_stroke_state *stroke, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { - printf("font->name, text->wmode); - fz_tracecolor(colorspace, color, alpha); - fz_tracematrix(fz_concat(ctm, text->trm)); + printf("font->name, text->wmode); + fz_trace_color(colorspace, color, alpha); + fz_trace_matrix(fz_concat(ctm, text->trm)); printf(">\n"); - fz_debugtext(text, 0); - printf("\n"); + fz_debug_text(text, 0); + printf("\n"); } static void -fz_tracecliptext(void *user, fz_text *text, fz_matrix ctm, int accumulate) +fz_trace_clip_text(void *user, fz_text *text, fz_matrix ctm, int accumulate) { - printf("font->name, text->wmode); + printf("font->name, text->wmode); printf("accumulate=\"%d\" ", accumulate); - fz_tracematrix(fz_concat(ctm, text->trm)); + fz_trace_matrix(fz_concat(ctm, text->trm)); printf(">\n"); - fz_debugtext(text, 0); - printf("\n"); + fz_debug_text(text, 0); + printf("\n"); } static void -fz_traceclipstroketext(void *user, fz_text *text, fz_strokestate *stroke, fz_matrix ctm) +fz_trace_clip_stroke_text(void *user, fz_text *text, fz_stroke_state *stroke, fz_matrix ctm) { - printf("font->name, text->wmode); - fz_tracematrix(fz_concat(ctm, text->trm)); + printf("font->name, text->wmode); + fz_trace_matrix(fz_concat(ctm, text->trm)); printf(">\n"); - fz_debugtext(text, 0); - printf("\n"); + fz_debug_text(text, 0); + printf("\n"); } static void -fz_traceignoretext(void *user, fz_text *text, fz_matrix ctm) +fz_trace_ignore_text(void *user, fz_text *text, fz_matrix ctm) { - printf("font->name, text->wmode); - fz_tracematrix(fz_concat(ctm, text->trm)); + printf("font->name, text->wmode); + fz_trace_matrix(fz_concat(ctm, text->trm)); printf(">\n"); - fz_debugtext(text, 0); - printf("\n"); + fz_debug_text(text, 0); + printf("\n"); } static void -fz_tracefillimage(void *user, fz_pixmap *image, fz_matrix ctm, float alpha) +fz_trace_fill_image(void *user, fz_pixmap *image, fz_matrix ctm, float alpha) { - printf("\n"); } static void -fz_tracefillshade(void *user, fz_shade *shade, fz_matrix ctm, float alpha) +fz_trace_fill_shade(void *user, fz_shade *shade, fz_matrix ctm, float alpha) { - printf("\n"); } static void -fz_tracefillimagemask(void *user, fz_pixmap *image, fz_matrix ctm, +fz_trace_fill_image_mask(void *user, fz_pixmap *image, fz_matrix ctm, fz_colorspace *colorspace, float *color, float alpha) { - printf("\n"); } static void -fz_traceclipimagemask(void *user, fz_pixmap *image, fz_matrix ctm) +fz_trace_clip_image_mask(void *user, fz_pixmap *image, fz_matrix ctm) { - printf("\n"); } static void -fz_tracepopclip(void *user) +fz_trace_pop_clip(void *user) { - printf("\n"); + printf("\n"); } static void -fz_tracebeginmask(void *user, fz_rect bbox, int luminosity, fz_colorspace *colorspace, float *color) +fz_trace_begin_mask(void *user, fz_rect bbox, int luminosity, fz_colorspace *colorspace, float *color) { printf("\n"); } static void -fz_traceendmask(void *user) +fz_trace_end_mask(void *user) { printf("\n"); } static void -fz_tracebegingroup(void *user, fz_rect bbox, int isolated, int knockout, fz_blendmode blendmode, float alpha) +fz_trace_begin_group(void *user, fz_rect bbox, int isolated, int knockout, fz_blendmode blendmode, float alpha) { printf("\n", bbox.x0, bbox.y0, bbox.x1, bbox.y1, - isolated, knockout, fz_blendnames[blendmode], alpha); + isolated, knockout, fz_blendmode_names[blendmode], alpha); } static void -fz_traceendgroup(void *user) +fz_trace_end_group(void *user) { printf("\n"); } static void -fz_tracebegintile(void *user, fz_rect area, fz_rect view, float xstep, float ystep, fz_matrix ctm) +fz_trace_begin_tile(void *user, fz_rect area, fz_rect view, float xstep, float ystep, fz_matrix ctm) { printf("\n"); } static void -fz_traceendtile(void *user) +fz_trace_end_tile(void *user) { printf("\n"); } -fz_device *fz_newtracedevice(void) +fz_device *fz_new_trace_device(void) { - fz_device *dev = fz_newdevice(nil); + fz_device *dev = fz_new_device(NULL); - dev->fillpath = fz_tracefillpath; - dev->strokepath = fz_tracestrokepath; - dev->clippath = fz_traceclippath; - dev->clipstrokepath = fz_traceclipstrokepath; + dev->fill_path = fz_trace_fill_path; + dev->stroke_path = fz_trace_stroke_path; + dev->clip_path = fz_trace_clip_path; + dev->clip_stroke_path = fz_trace_clip_stroke_path; - dev->filltext = fz_tracefilltext; - dev->stroketext = fz_tracestroketext; - dev->cliptext = fz_tracecliptext; - dev->clipstroketext = fz_traceclipstroketext; - dev->ignoretext = fz_traceignoretext; + dev->fill_text = fz_trace_fill_text; + dev->stroke_text = fz_trace_stroke_text; + dev->clip_text = fz_trace_clip_text; + dev->clip_stroke_text = fz_trace_clip_stroke_text; + dev->ignore_text = fz_trace_ignore_text; - dev->fillshade = fz_tracefillshade; - dev->fillimage = fz_tracefillimage; - dev->fillimagemask = fz_tracefillimagemask; - dev->clipimagemask = fz_traceclipimagemask; + dev->fill_shade = fz_trace_fill_shade; + dev->fill_image = fz_trace_fill_image; + dev->fill_image_mask = fz_trace_fill_image_mask; + dev->clip_image_mask = fz_trace_clip_image_mask; - dev->popclip = fz_tracepopclip; + dev->pop_clip = fz_trace_pop_clip; - dev->beginmask = fz_tracebeginmask; - dev->endmask = fz_traceendmask; - dev->begingroup = fz_tracebegingroup; - dev->endgroup = fz_traceendgroup; + dev->begin_mask = fz_trace_begin_mask; + dev->end_mask = fz_trace_end_mask; + dev->begin_group = fz_trace_begin_group; + dev->end_group = fz_trace_end_group; - dev->begintile = fz_tracebegintile; - dev->endtile = fz_traceendtile; + dev->begin_tile = fz_trace_begin_tile; + dev->end_tile = fz_trace_end_tile; return dev; } diff --git a/fitz/filt_basic.c b/fitz/filt_basic.c index 221d0846..391f06ab 100644 --- a/fitz/filt_basic.c +++ b/fitz/filt_basic.c @@ -3,23 +3,23 @@ /* Pretend we have a filter that just copies data forever */ fz_stream * -fz_opencopy(fz_stream *chain) +fz_open_copy(fz_stream *chain) { - return fz_keepstream(chain); + return fz_keep_stream(chain); } /* Null filter copies a specified amount of data */ -struct nullfilter +struct null_filter { fz_stream *chain; int remain; }; static int -readnull(fz_stream *stm, unsigned char *buf, int len) +read_null(fz_stream *stm, unsigned char *buf, int len) { - struct nullfilter *state = stm->state; + struct null_filter *state = stm->state; int amount = MIN(len, state->remain); int n = fz_read(state->chain, buf, amount); if (n < 0) @@ -29,23 +29,23 @@ readnull(fz_stream *stm, unsigned char *buf, int len) } static void -closenull(fz_stream *stm) +close_null(fz_stream *stm) { - struct nullfilter *state = stm->state; + struct null_filter *state = stm->state; fz_close(state->chain); fz_free(state); } fz_stream * -fz_opennull(fz_stream *chain, int len) +fz_open_null(fz_stream *chain, int len) { - struct nullfilter *state; + struct null_filter *state; - state = fz_malloc(sizeof(struct nullfilter)); + state = fz_malloc(sizeof(struct null_filter)); state->chain = chain; state->remain = len; - return fz_newstream(state, readnull, closenull); + return fz_new_stream(state, read_null, close_null); } /* ASCII Hex Decode */ @@ -75,7 +75,7 @@ static inline int ishex(int a) (a >= '0' && a <= '9'); } -static inline int fromhex(int a) +static inline int from_hex(int a) { if (a >= 'A' && a <= 'F') return a - 'A' + 0xA; @@ -87,7 +87,7 @@ static inline int fromhex(int a) } static int -readahxd(fz_stream *stm, unsigned char *buf, int len) +read_ahxd(fz_stream *stm, unsigned char *buf, int len) { fz_ahxd *state = stm->state; unsigned char *p = buf; @@ -101,7 +101,7 @@ readahxd(fz_stream *stm, unsigned char *buf, int len) if (state->eod) return p - buf; - c = fz_readbyte(state->chain); + c = fz_read_byte(state->chain); if (c < 0) return p - buf; @@ -109,12 +109,12 @@ readahxd(fz_stream *stm, unsigned char *buf, int len) { if (!odd) { - a = fromhex(c); + a = from_hex(c); odd = 1; } else { - b = fromhex(c); + b = from_hex(c); *p++ = (a << 4) | b; odd = 0; } @@ -135,7 +135,7 @@ readahxd(fz_stream *stm, unsigned char *buf, int len) } static void -closeahxd(fz_stream *stm) +close_ahxd(fz_stream *stm) { fz_ahxd *state = stm->state; fz_close(state->chain); @@ -143,7 +143,7 @@ closeahxd(fz_stream *stm) } fz_stream * -fz_openahxd(fz_stream *chain) +fz_open_ahxd(fz_stream *chain) { fz_ahxd *state; @@ -151,7 +151,7 @@ fz_openahxd(fz_stream *chain) state->chain = chain; state->eod = 0; - return fz_newstream(state, readahxd, closeahxd); + return fz_new_stream(state, read_ahxd, close_ahxd); } /* ASCII 85 Decode */ @@ -167,7 +167,7 @@ struct fz_a85d_s }; static int -reada85d(fz_stream *stm, unsigned char *buf, int len) +read_a85d(fz_stream *stm, unsigned char *buf, int len) { fz_a85d *state = stm->state; unsigned char *p = buf; @@ -184,7 +184,7 @@ reada85d(fz_stream *stm, unsigned char *buf, int len) if (state->eod) return p - buf; - c = fz_readbyte(state->chain); + c = fz_read_byte(state->chain); if (c < 0) return p - buf; @@ -223,7 +223,7 @@ reada85d(fz_stream *stm, unsigned char *buf, int len) else if (c == '~') { - c = fz_readbyte(state->chain); + c = fz_read_byte(state->chain); if (c != '>') fz_warn("bad eod marker in a85d"); @@ -270,7 +270,7 @@ reada85d(fz_stream *stm, unsigned char *buf, int len) } static void -closea85d(fz_stream *stm) +close_a85d(fz_stream *stm) { fz_a85d *state = stm->state; fz_close(state->chain); @@ -278,7 +278,7 @@ closea85d(fz_stream *stm) } fz_stream * -fz_opena85d(fz_stream *chain) +fz_open_a85d(fz_stream *chain) { fz_a85d *state; @@ -288,7 +288,7 @@ fz_opena85d(fz_stream *chain) state->wp = state->bp; state->eod = 0; - return fz_newstream(state, reada85d, closea85d); + return fz_new_stream(state, read_a85d, close_a85d); } /* Run Length Decode */ @@ -302,7 +302,7 @@ struct fz_rld_s }; static int -readrld(fz_stream *stm, unsigned char *buf, int len) +read_rld(fz_stream *stm, unsigned char *buf, int len) { fz_rld *state = stm->state; unsigned char *p = buf; @@ -315,7 +315,7 @@ readrld(fz_stream *stm, unsigned char *buf, int len) if (state->n == 0) { - state->run = fz_readbyte(state->chain); + state->run = fz_read_byte(state->chain); if (state->run < 0) state->run = 128; if (state->run < 128) @@ -323,7 +323,7 @@ readrld(fz_stream *stm, unsigned char *buf, int len) if (state->run > 128) { state->n = 257 - state->run; - state->c = fz_readbyte(state->chain); + state->c = fz_read_byte(state->chain); if (state->c < 0) return fz_throw("premature end of data in run length decode"); } @@ -333,7 +333,7 @@ readrld(fz_stream *stm, unsigned char *buf, int len) { while (p < ep && state->n) { - int c = fz_readbyte(state->chain); + int c = fz_read_byte(state->chain); if (c < 0) return fz_throw("premature end of data in run length decode"); *p++ = c; @@ -355,7 +355,7 @@ readrld(fz_stream *stm, unsigned char *buf, int len) } static void -closerld(fz_stream *stm) +close_rld(fz_stream *stm) { fz_rld *state = stm->state; fz_close(state->chain); @@ -363,7 +363,7 @@ closerld(fz_stream *stm) } fz_stream * -fz_openrld(fz_stream *chain) +fz_open_rld(fz_stream *chain) { fz_rld *state; @@ -373,7 +373,7 @@ fz_openrld(fz_stream *chain) state->n = 0; state->c = 0; - return fz_newstream(state, readrld, closerld); + return fz_new_stream(state, read_rld, close_rld); } /* RC4 Filter */ @@ -387,7 +387,7 @@ struct fz_arc4c_s }; static int -readarc4(fz_stream *stm, unsigned char *buf, int len) +read_arc4(fz_stream *stm, unsigned char *buf, int len) { fz_arc4c *state = stm->state; int n; @@ -396,13 +396,13 @@ readarc4(fz_stream *stm, unsigned char *buf, int len) if (n < 0) return fz_rethrow(n, "read error in arc4 filter"); - fz_arc4encrypt(&state->arc4, buf, buf, n); + fz_arc4_encrypt(&state->arc4, buf, buf, n); return n; } static void -closearc4(fz_stream *stm) +close_arc4(fz_stream *stm) { fz_arc4c *state = stm->state; fz_close(state->chain); @@ -410,15 +410,15 @@ closearc4(fz_stream *stm) } fz_stream * -fz_openarc4(fz_stream *chain, unsigned char *key, unsigned keylen) +fz_open_arc4(fz_stream *chain, unsigned char *key, unsigned keylen) { fz_arc4c *state; state = fz_malloc(sizeof(fz_arc4c)); state->chain = chain; - fz_arc4init(&state->arc4, key, keylen); + fz_arc4_init(&state->arc4, key, keylen); - return fz_newstream(state, readarc4, closearc4); + return fz_new_stream(state, read_arc4, close_arc4); } /* AES Filter */ @@ -436,7 +436,7 @@ struct fz_aesd_s }; static int -readaesd(fz_stream *stm, unsigned char *buf, int len) +read_aesd(fz_stream *stm, unsigned char *buf, int len) { fz_aesd *state = stm->state; unsigned char *p = buf; @@ -444,7 +444,7 @@ readaesd(fz_stream *stm, unsigned char *buf, int len) while (state->ivcount < 16) { - int c = fz_readbyte(state->chain); + int c = fz_read_byte(state->chain); if (c < 0) return fz_throw("premature end in aes filter"); state->iv[state->ivcount++] = c; @@ -468,7 +468,7 @@ readaesd(fz_stream *stm, unsigned char *buf, int len) state->wp = state->bp + 16; /* strip padding at end of file */ - if (fz_iseof(state->chain)) + if (fz_is_eof(state->chain)) { int pad = state->bp[15]; if (pad < 1 || pad > 16) @@ -484,7 +484,7 @@ readaesd(fz_stream *stm, unsigned char *buf, int len) } static void -closeaesd(fz_stream *stm) +close_aesd(fz_stream *stm) { fz_aesd *state = stm->state; fz_close(state->chain); @@ -492,7 +492,7 @@ closeaesd(fz_stream *stm) } fz_stream * -fz_openaesd(fz_stream *chain, unsigned char *key, unsigned keylen) +fz_open_aesd(fz_stream *chain, unsigned char *key, unsigned keylen) { fz_aesd *state; @@ -503,5 +503,5 @@ fz_openaesd(fz_stream *chain, unsigned char *key, unsigned keylen) state->rp = state->bp; state->wp = state->bp; - return fz_newstream(state, readaesd, closeaesd); + return fz_new_stream(state, read_aesd, close_aesd); } diff --git a/fitz/filt_dctd.c b/fitz/filt_dctd.c index 05c3db4d..0e24b794 100644 --- a/fitz/filt_dctd.c +++ b/fitz/filt_dctd.c @@ -8,7 +8,7 @@ typedef struct fz_dctd_s fz_dctd; struct fz_dctd_s { fz_stream *chain; - int colortransform; + int color_transform; int init; int stride; unsigned char *scanline; @@ -44,7 +44,7 @@ static boolean fill_input_buffer(j_decompress_ptr cinfo) fz_stream *chain = state->chain; chain->rp = chain->wp; - fz_fillbuffer(chain); + fz_fill_buffer(chain); src->next_input_byte = chain->rp; src->bytes_in_buffer = chain->wp - chain->rp; @@ -75,7 +75,7 @@ static void skip_input_data(j_decompress_ptr cinfo, long num_bytes) } static int -readdctd(fz_stream *stm, unsigned char *buf, int len) +read_dctd(fz_stream *stm, unsigned char *buf, int len) { fz_dctd *state = stm->state; j_decompress_ptr cinfo = &state->cinfo; @@ -113,28 +113,28 @@ readdctd(fz_stream *stm, unsigned char *buf, int len) cinfo->do_fancy_upsampling = FALSE; /* default value if ColorTransform is not set */ - if (state->colortransform == -1) + if (state->color_transform == -1) { if (state->cinfo.num_components == 3) - state->colortransform = 1; + state->color_transform = 1; else - state->colortransform = 0; + state->color_transform = 0; } if (cinfo->saw_Adobe_marker) - state->colortransform = cinfo->Adobe_transform; + state->color_transform = cinfo->Adobe_transform; /* Guess the input colorspace, and set output colorspace accordingly */ switch (cinfo->num_components) { case 3: - if (state->colortransform) + if (state->color_transform) cinfo->jpeg_color_space = JCS_YCbCr; else cinfo->jpeg_color_space = JCS_RGB; break; case 4: - if (state->colortransform) + if (state->color_transform) cinfo->jpeg_color_space = JCS_YCCK; else cinfo->jpeg_color_space = JCS_CMYK; @@ -179,7 +179,7 @@ readdctd(fz_stream *stm, unsigned char *buf, int len) } static void -closedctd(fz_stream *stm) +close_dctd(fz_stream *stm) { fz_dctd *state = stm->state; @@ -202,7 +202,7 @@ skip: } fz_stream * -fz_opendctd(fz_stream *chain, fz_obj *params) +fz_open_dctd(fz_stream *chain, fz_obj *params) { fz_dctd *state; fz_obj *obj; @@ -210,12 +210,12 @@ fz_opendctd(fz_stream *chain, fz_obj *params) state = fz_malloc(sizeof(fz_dctd)); memset(state, 0, sizeof(fz_dctd)); state->chain = chain; - state->colortransform = -1; /* unset */ + state->color_transform = -1; /* unset */ state->init = 0; - obj = fz_dictgets(params, "ColorTransform"); + obj = fz_dict_gets(params, "ColorTransform"); if (obj) - state->colortransform = fz_toint(obj); + state->color_transform = fz_to_int(obj); - return fz_newstream(state, readdctd, closedctd); + return fz_new_stream(state, read_dctd, close_dctd); } diff --git a/fitz/filt_faxd.c b/fitz/filt_faxd.c index 714629e7..97076f89 100644 --- a/fitz/filt_faxd.c +++ b/fitz/filt_faxd.c @@ -171,7 +171,7 @@ const cfd_node cf_uncompressed_decode[] = { /* bit magic */ static inline void -printbits(FILE *f, int code, int nbits) +print_bits(FILE *f, int code, int nbits) { int n, b; for (n = nbits - 1; n >= 0; n--) @@ -188,7 +188,7 @@ getbit(const unsigned char *buf, int x) } static inline void -printline(FILE *f, unsigned char *line, int w) +print_line(FILE *f, unsigned char *line, int w) { int i; for (i = 0; i < w; i++) @@ -197,7 +197,7 @@ printline(FILE *f, unsigned char *line, int w) } static inline int -findchanging(const unsigned char *line, int x, int w) +find_changing(const unsigned char *line, int x, int w) { int a, b; @@ -227,15 +227,15 @@ findchanging(const unsigned char *line, int x, int w) } static inline int -findchangingcolor(const unsigned char *line, int x, int w, int color) +find_changing_color(const unsigned char *line, int x, int w, int color) { if (!line) return w; - x = findchanging(line, x, w); + x = find_changing(line, x, w); if (x < w && getbit(line, x) != color) - x = findchanging(line, x, w); + x = find_changing(line, x, w); return x; } @@ -278,11 +278,11 @@ typedef struct fz_faxd_s fz_faxd; enum { - SNORMAL, /* neutral state, waiting for any code */ - SMAKEUP, /* got a 1d makeup code, waiting for terminating code */ - SEOL, /* at eol, needs output buffer space */ - SH1, SH2, /* in H part 1 and 2 (both makeup and terminating codes) */ - SDONE /* all done */ + STATE_NORMAL, /* neutral state, waiting for any code */ + STATE_MAKEUP, /* got a 1d makeup code, waiting for terminating code */ + STATE_EOL, /* at eol, needs output buffer space */ + STATE_H1, STATE_H2, /* in H part 1 and 2 (both makeup and terminating codes) */ + STATE_DONE /* all done */ }; struct fz_faxd_s @@ -290,12 +290,12 @@ struct fz_faxd_s fz_stream *chain; int k; - int endofline; - int encodedbytealign; + int end_of_line; + int encoded_byte_align; int columns; int rows; - int endofblock; - int blackis1; + int end_of_block; + int black_is_1; int stride; int ridx; @@ -312,18 +312,18 @@ struct fz_faxd_s }; static inline void -eatbits(fz_faxd *fax, int nbits) +eat_bits(fz_faxd *fax, int nbits) { fax->word <<= nbits; fax->bidx += nbits; } static inline int -fillbits(fz_faxd *fax) +fill_bits(fz_faxd *fax) { while (fax->bidx >= 8) { - int c = fz_readbyte(fax->chain); + int c = fz_read_byte(fax->chain); if (c == EOF) return EOF; fax->bidx -= 8; @@ -348,7 +348,7 @@ getcode(fz_faxd *fax, const cfd_node *table, int initialbits) nbits = initialbits + table[tidx].nbits; } - eatbits(fax, nbits); + eat_bits(fax, nbits); return val; } @@ -384,10 +384,10 @@ dec1d(fz_faxd *fax) if (code < 64) { fax->c = !fax->c; - fax->stage = SNORMAL; + fax->stage = STATE_NORMAL; } else - fax->stage = SMAKEUP; + fax->stage = STATE_MAKEUP; return fz_okay; } @@ -398,7 +398,7 @@ dec2d(fz_faxd *fax) { int code, b1, b2; - if (fax->stage == SH1 || fax->stage == SH2) + if (fax->stage == STATE_H1 || fax->stage == STATE_H2) { if (fax->a == -1) fax->a = 0; @@ -425,10 +425,10 @@ dec2d(fz_faxd *fax) if (code < 64) { fax->c = !fax->c; - if (fax->stage == SH1) - fax->stage = SH2; - else if (fax->stage == SH2) - fax->stage = SNORMAL; + if (fax->stage == STATE_H1) + fax->stage = STATE_H2; + else if (fax->stage == STATE_H2) + fax->stage = STATE_NORMAL; } return fz_okay; @@ -439,28 +439,28 @@ dec2d(fz_faxd *fax) switch (code) { case H: - fax->stage = SH1; + fax->stage = STATE_H1; break; case P: - b1 = findchangingcolor(fax->ref, fax->a, fax->columns, !fax->c); + b1 = find_changing_color(fax->ref, fax->a, fax->columns, !fax->c); if (b1 >= fax->columns) b2 = fax->columns; else - b2 = findchanging(fax->ref, b1, fax->columns); + b2 = find_changing(fax->ref, b1, fax->columns); if (fax->c) setbits(fax->dst, fax->a, b2); fax->a = b2; break; case V0: - b1 = findchangingcolor(fax->ref, fax->a, fax->columns, !fax->c); + b1 = find_changing_color(fax->ref, fax->a, fax->columns, !fax->c); if (fax->c) setbits(fax->dst, fax->a, b1); fax->a = b1; fax->c = !fax->c; break; case VR1: - b1 = 1 + findchangingcolor(fax->ref, fax->a, fax->columns, !fax->c); + b1 = 1 + find_changing_color(fax->ref, fax->a, fax->columns, !fax->c); if (b1 >= fax->columns) b1 = fax->columns; if (fax->c) setbits(fax->dst, fax->a, b1); fax->a = b1; @@ -468,7 +468,7 @@ dec2d(fz_faxd *fax) break; case VR2: - b1 = 2 + findchangingcolor(fax->ref, fax->a, fax->columns, !fax->c); + b1 = 2 + find_changing_color(fax->ref, fax->a, fax->columns, !fax->c); if (b1 >= fax->columns) b1 = fax->columns; if (fax->c) setbits(fax->dst, fax->a, b1); fax->a = b1; @@ -476,7 +476,7 @@ dec2d(fz_faxd *fax) break; case VR3: - b1 = 3 + findchangingcolor(fax->ref, fax->a, fax->columns, !fax->c); + b1 = 3 + find_changing_color(fax->ref, fax->a, fax->columns, !fax->c); if (b1 >= fax->columns) b1 = fax->columns; if (fax->c) setbits(fax->dst, fax->a, b1); fax->a = b1; @@ -484,7 +484,7 @@ dec2d(fz_faxd *fax) break; case VL1: - b1 = -1 + findchangingcolor(fax->ref, fax->a, fax->columns, !fax->c); + b1 = -1 + find_changing_color(fax->ref, fax->a, fax->columns, !fax->c); if (b1 < 0) b1 = 0; if (fax->c) setbits(fax->dst, fax->a, b1); fax->a = b1; @@ -492,7 +492,7 @@ dec2d(fz_faxd *fax) break; case VL2: - b1 = -2 + findchangingcolor(fax->ref, fax->a, fax->columns, !fax->c); + b1 = -2 + find_changing_color(fax->ref, fax->a, fax->columns, !fax->c); if (b1 < 0) b1 = 0; if (fax->c) setbits(fax->dst, fax->a, b1); fax->a = b1; @@ -500,7 +500,7 @@ dec2d(fz_faxd *fax) break; case VL3: - b1 = -3 + findchangingcolor(fax->ref, fax->a, fax->columns, !fax->c); + b1 = -3 + find_changing_color(fax->ref, fax->a, fax->columns, !fax->c); if (b1 < 0) b1 = 0; if (fax->c) setbits(fax->dst, fax->a, b1); fax->a = b1; @@ -521,7 +521,7 @@ dec2d(fz_faxd *fax) } static int -readfaxd(fz_stream *stm, unsigned char *buf, int len) +read_faxd(fz_stream *stm, unsigned char *buf, int len) { fz_faxd *fax = stm->state; unsigned char *p = buf; @@ -529,15 +529,15 @@ readfaxd(fz_stream *stm, unsigned char *buf, int len) unsigned char *tmp; fz_error error; - if (fax->stage == SDONE) + if (fax->stage == STATE_DONE) return 0; - if (fax->stage == SEOL) + if (fax->stage == STATE_EOL) goto eol; loop: - if (fillbits(fax)) + if (fill_bits(fax)) { if (fax->bidx > 31) { @@ -549,13 +549,13 @@ loop: if ((fax->word >> (32 - 12)) == 0) { - eatbits(fax, 1); + eat_bits(fax, 1); goto loop; } if ((fax->word >> (32 - 12)) == 1) { - eatbits(fax, 12); + eat_bits(fax, 12); fax->eolc ++; if (fax->k > 0) @@ -566,7 +566,7 @@ loop: fax->dim = 1; else fax->dim = 2; - eatbits(fax, 1); + eat_bits(fax, 1); } } else if (fax->k > 0 && fax->a == -1) @@ -576,7 +576,7 @@ loop: fax->dim = 1; else fax->dim = 2; - eatbits(fax, 1); + eat_bits(fax, 1); } else if (fax->dim == 1) { @@ -594,7 +594,7 @@ loop: } /* no eol check after makeup codes nor in the middle of an H code */ - if (fax->stage == SMAKEUP || fax->stage == SH1 || fax->stage == SH2) + if (fax->stage == STATE_MAKEUP || fax->stage == STATE_H1 || fax->stage == STATE_H2) goto loop; /* check for eol conditions */ @@ -609,9 +609,9 @@ loop: goto loop; eol: - fax->stage = SEOL; + fax->stage = STATE_EOL; - if (fax->blackis1) + if (fax->black_is_1) { while (fax->rp < fax->wp && p < ep) *p++ = *fax->rp++; @@ -625,7 +625,6 @@ eol: if (fax->rp < fax->wp) return p - buf; - tmp = fax->ref; fax->ref = fax->dst; fax->dst = tmp; @@ -634,12 +633,12 @@ eol: fax->rp = fax->dst; fax->wp = fax->dst + fax->stride; - fax->stage = SNORMAL; + fax->stage = STATE_NORMAL; fax->c = 0; fax->a = -1; fax->ridx ++; - if (!fax->endofblock && fax->rows) + if (!fax->end_of_block && fax->rows) { if (fax->ridx >= fax->rows) goto rtc; @@ -654,13 +653,13 @@ eol: fax->dim = 2; } - /* if endofline & encodedbytealign, EOLs are *not* optional */ - if (fax->encodedbytealign) + /* if end_of_line & encoded_byte_align, EOLs are *not* optional */ + if (fax->encoded_byte_align) { - if (fax->endofline) - eatbits(fax, (12 - fax->bidx) & 7); + if (fax->end_of_line) + eat_bits(fax, (12 - fax->bidx) & 7); else - eatbits(fax, (8 - fax->bidx) & 7); + eat_bits(fax, (8 - fax->bidx) & 7); } /* no more space in output, don't decode the next row yet */ @@ -670,12 +669,12 @@ eol: goto loop; rtc: - fax->stage = SDONE; + fax->stage = STATE_DONE; return p - buf; } static void -closefaxd(fz_stream *stm) +close_faxd(fz_stream *stm) { fz_faxd *fax = stm->state; int i; @@ -683,7 +682,7 @@ closefaxd(fz_stream *stm) /* if we read any extra bytes, try to put them back */ i = (32 - fax->bidx) / 8; while (i--) - fz_unreadbyte(fax->chain); + fz_unread_byte(fax->chain); fz_close(fax->chain); fz_free(fax->ref); @@ -692,7 +691,7 @@ closefaxd(fz_stream *stm) } fz_stream * -fz_openfaxd(fz_stream *chain, fz_obj *params) +fz_open_faxd(fz_stream *chain, fz_obj *params) { fz_faxd *fax; fz_obj *obj; @@ -700,44 +699,44 @@ fz_openfaxd(fz_stream *chain, fz_obj *params) fax = fz_malloc(sizeof(fz_faxd)); fax->chain = chain; - fax->ref = nil; - fax->dst = nil; + fax->ref = NULL; + fax->dst = NULL; fax->k = 0; - fax->endofline = 0; - fax->encodedbytealign = 0; + fax->end_of_line = 0; + fax->encoded_byte_align = 0; fax->columns = 1728; fax->rows = 0; - fax->endofblock = 1; - fax->blackis1 = 0; + fax->end_of_block = 1; + fax->black_is_1 = 0; - obj = fz_dictgets(params, "K"); - if (obj) fax->k = fz_toint(obj); + obj = fz_dict_gets(params, "K"); + if (obj) fax->k = fz_to_int(obj); - obj = fz_dictgets(params, "EndOfLine"); - if (obj) fax->endofline = fz_tobool(obj); + obj = fz_dict_gets(params, "EndOfLine"); + if (obj) fax->end_of_line = fz_to_bool(obj); - obj = fz_dictgets(params, "EncodedByteAlign"); - if (obj) fax->encodedbytealign = fz_tobool(obj); + obj = fz_dict_gets(params, "EncodedByteAlign"); + if (obj) fax->encoded_byte_align = fz_to_bool(obj); - obj = fz_dictgets(params, "Columns"); - if (obj) fax->columns = fz_toint(obj); + obj = fz_dict_gets(params, "Columns"); + if (obj) fax->columns = fz_to_int(obj); - obj = fz_dictgets(params, "Rows"); - if (obj) fax->rows = fz_toint(obj); + obj = fz_dict_gets(params, "Rows"); + if (obj) fax->rows = fz_to_int(obj); - obj = fz_dictgets(params, "EndOfBlock"); - if (obj) fax->endofblock = fz_tobool(obj); + obj = fz_dict_gets(params, "EndOfBlock"); + if (obj) fax->end_of_block = fz_to_bool(obj); - obj = fz_dictgets(params, "BlackIs1"); - if (obj) fax->blackis1 = fz_tobool(obj); + obj = fz_dict_gets(params, "BlackIs1"); + if (obj) fax->black_is_1 = fz_to_bool(obj); fax->stride = ((fax->columns - 1) >> 3) + 1; fax->ridx = 0; fax->bidx = 32; fax->word = 0; - fax->stage = SNORMAL; + fax->stage = STATE_NORMAL; fax->a = -1; fax->c = 0; fax->dim = fax->k < 0 ? 2 : 1; @@ -751,5 +750,5 @@ fz_openfaxd(fz_stream *chain, fz_obj *params) memset(fax->ref, 0, fax->stride); memset(fax->dst, 0, fax->stride); - return fz_newstream(fax, readfaxd, closefaxd); + return fz_new_stream(fax, read_faxd, close_faxd); } diff --git a/fitz/filt_flate.c b/fitz/filt_flate.c index 0d14a75c..e7d4c9f7 100644 --- a/fitz/filt_flate.c +++ b/fitz/filt_flate.c @@ -21,7 +21,7 @@ static void zfree(void *opaque, void *ptr) } static int -readflated(fz_stream *stm, unsigned char *outbuf, int outlen) +read_flated(fz_stream *stm, unsigned char *outbuf, int outlen) { fz_flate *state = stm->state; fz_stream *chain = state->chain; @@ -34,7 +34,7 @@ readflated(fz_stream *stm, unsigned char *outbuf, int outlen) while (zp->avail_out > 0) { if (chain->rp == chain->wp) - fz_fillbuffer(chain); + fz_fill_buffer(chain); zp->next_in = chain->rp; zp->avail_in = chain->wp - chain->rp; @@ -67,7 +67,7 @@ readflated(fz_stream *stm, unsigned char *outbuf, int outlen) } static void -closeflated(fz_stream *stm) +close_flated(fz_stream *stm) { fz_flate *state = stm->state; int code; @@ -81,7 +81,7 @@ closeflated(fz_stream *stm) } fz_stream * -fz_openflated(fz_stream *chain) +fz_open_flated(fz_stream *chain) { fz_flate *state; int code; @@ -91,13 +91,13 @@ fz_openflated(fz_stream *chain) state->z.zalloc = zalloc; state->z.zfree = zfree; - state->z.opaque = nil; - state->z.next_in = nil; + state->z.opaque = NULL; + state->z.next_in = NULL; state->z.avail_in = 0; code = inflateInit(&state->z); if (code != Z_OK) fz_warn("zlib error: inflateInit: %s", state->z.msg); - return fz_newstream(state, readflated, closeflated); + return fz_new_stream(state, read_flated, close_flated); } diff --git a/fitz/filt_jbig2d.c b/fitz/filt_jbig2d.c index 8804ef29..4dbe542c 100644 --- a/fitz/filt_jbig2d.c +++ b/fitz/filt_jbig2d.c @@ -29,7 +29,7 @@ struct fz_jbig2d_s }; static void -closejbig2d(fz_stream *stm) +close_jbig2d(fz_stream *stm) { fz_jbig2d *state = stm->state; if (state->page) @@ -42,7 +42,7 @@ closejbig2d(fz_stream *stm) } static int -readjbig2d(fz_stream *stm, unsigned char *buf, int len) +read_jbig2d(fz_stream *stm, unsigned char *buf, int len) { fz_jbig2d *state = stm->state; unsigned char tmp[4096]; @@ -81,23 +81,23 @@ readjbig2d(fz_stream *stm, unsigned char *buf, int len) } fz_stream * -fz_openjbig2d(fz_stream *chain, fz_buffer *globals) +fz_open_jbig2d(fz_stream *chain, fz_buffer *globals) { fz_jbig2d *state; state = fz_malloc(sizeof(fz_jbig2d)); state->chain = chain; - state->ctx = jbig2_ctx_new(nil, JBIG2_OPTIONS_EMBEDDED, nil, nil, nil); - state->gctx = nil; - state->page = nil; + state->ctx = jbig2_ctx_new(NULL, JBIG2_OPTIONS_EMBEDDED, NULL, NULL, NULL); + state->gctx = NULL; + state->page = NULL; state->idx = 0; if (globals) { jbig2_data_in(state->ctx, globals->data, globals->len); state->gctx = jbig2_make_global_ctx(state->ctx); - state->ctx = jbig2_ctx_new(nil, JBIG2_OPTIONS_EMBEDDED, state->gctx, nil, nil); + state->ctx = jbig2_ctx_new(NULL, JBIG2_OPTIONS_EMBEDDED, state->gctx, NULL, NULL); } - return fz_newstream(state, readjbig2d, closejbig2d); + return fz_new_stream(state, read_jbig2d, close_jbig2d); } diff --git a/fitz/filt_jpxd.c b/fitz/filt_jpxd.c index 3ec06ab3..f5a65851 100644 --- a/fitz/filt_jpxd.c +++ b/fitz/filt_jpxd.c @@ -19,7 +19,7 @@ static void fz_opj_info_callback(const char *msg, void *client_data) } fz_error -fz_loadjpximage(fz_pixmap **imgp, unsigned char *data, int size) +fz_load_jpx_image(fz_pixmap **imgp, unsigned char *data, int size) { fz_pixmap *img; opj_event_mgr_t evtmgr; @@ -81,16 +81,16 @@ fz_loadjpximage(fz_pixmap **imgp, unsigned char *data, int size) switch (n) { - case 1: colorspace = fz_devicegray; break; - case 3: colorspace = fz_devicergb; break; - case 4: colorspace = fz_devicecmyk; break; + case 1: colorspace = fz_device_gray; break; + case 3: colorspace = fz_device_rgb; break; + case 4: colorspace = fz_device_cmyk; break; default: /* TODO: SMaskInData */ opj_image_destroy(jpx); return fz_throw("unknown jpx colorspace (%d components)", n); } - img = fz_newpixmap(colorspace, 0, 0, w, h); + img = fz_new_pixmap(colorspace, 0, 0, w, h); p = img->samples; for (y = 0; y < h; y++) diff --git a/fitz/filt_lzwd.c b/fitz/filt_lzwd.c index 23cb7520..942e5837 100644 --- a/fitz/filt_lzwd.c +++ b/fitz/filt_lzwd.c @@ -4,13 +4,13 @@ enum { - MINBITS = 9, - MAXBITS = 12, - NUMCODES = (1 << MAXBITS), + MIN_BITS = 9, + MAX_BITS = 12, + NUM_CODES = (1 << MAX_BITS), LZW_CLEAR = 256, LZW_EOD = 257, LZW_FIRST = 258, - MAXLENGTH = 4097 + MAX_LENGTH = 4097 }; typedef struct lzw_code_s lzw_code; @@ -20,7 +20,7 @@ struct lzw_code_s int prev; /* prev code (in string) */ unsigned short length; /* string len, including this token */ unsigned char value; /* data value */ - unsigned char firstchar; /* first token of string */ + unsigned char first_char; /* first token of string */ }; typedef struct fz_lzwd_s fz_lzwd; @@ -30,21 +30,21 @@ struct fz_lzwd_s fz_stream *chain; int eod; - int earlychange; + int early_change; - int codebits; /* num bits/code */ + int code_bits; /* num bits/code */ int code; /* current code */ - int oldcode; /* previously recognized code */ - int nextcode; /* next free entry */ + int old_code; /* previously recognized code */ + int next_code; /* next free entry */ - lzw_code table[NUMCODES]; + lzw_code table[NUM_CODES]; - unsigned char bp[MAXLENGTH]; + unsigned char bp[MAX_LENGTH]; unsigned char *rp, *wp; }; static int -readlzwd(fz_stream *stm, unsigned char *buf, int len) +read_lzwd(fz_stream *stm, unsigned char *buf, int len) { fz_lzwd *lzw = stm->state; lzw_code *table = lzw->table; @@ -53,10 +53,10 @@ readlzwd(fz_stream *stm, unsigned char *buf, int len) unsigned char *s; int codelen; - int codebits = lzw->codebits; + int code_bits = lzw->code_bits; int code = lzw->code; - int oldcode = lzw->oldcode; - int nextcode = lzw->nextcode; + int old_code = lzw->old_code; + int next_code = lzw->next_code; while (lzw->rp < lzw->wp && p < ep) *p++ = *lzw->rp++; @@ -66,9 +66,9 @@ readlzwd(fz_stream *stm, unsigned char *buf, int len) if (lzw->eod) return 0; - code = fz_readbits(lzw->chain, codebits); + code = fz_read_bits(lzw->chain, code_bits); - if (fz_iseofbits(lzw->chain)) + if (fz_is_eof_bits(lzw->chain)) { lzw->eod = 1; break; @@ -82,40 +82,40 @@ readlzwd(fz_stream *stm, unsigned char *buf, int len) if (code == LZW_CLEAR) { - codebits = MINBITS; - nextcode = LZW_FIRST; - oldcode = -1; + code_bits = MIN_BITS; + next_code = LZW_FIRST; + old_code = -1; continue; } - /* if stream starts without a clear code, oldcode is undefined... */ - if (oldcode == -1) + /* if stream starts without a clear code, old_code is undefined... */ + if (old_code == -1) { - oldcode = code; + old_code = code; } else { /* add new entry to the code table */ - table[nextcode].prev = oldcode; - table[nextcode].firstchar = table[oldcode].firstchar; - table[nextcode].length = table[oldcode].length + 1; - if (code < nextcode) - table[nextcode].value = table[code].firstchar; - else if (code == nextcode) - table[nextcode].value = table[nextcode].firstchar; + table[next_code].prev = old_code; + table[next_code].first_char = table[old_code].first_char; + table[next_code].length = table[old_code].length + 1; + if (code < next_code) + table[next_code].value = table[code].first_char; + else if (code == next_code) + table[next_code].value = table[next_code].first_char; else fz_warn("out of range code encountered in lzw decode"); - nextcode ++; + next_code ++; - if (nextcode > (1 << codebits) - lzw->earlychange - 1) + if (next_code > (1 << code_bits) - lzw->early_change - 1) { - codebits ++; - if (codebits > MAXBITS) - codebits = MAXBITS; /* FIXME */ + code_bits ++; + if (code_bits > MAX_BITS) + code_bits = MAX_BITS; /* FIXME */ } - oldcode = code; + old_code = code; } /* code maps to a string, copy to output (in reverse...) */ @@ -125,7 +125,7 @@ readlzwd(fz_stream *stm, unsigned char *buf, int len) lzw->rp = lzw->bp; lzw->wp = lzw->bp + codelen; - assert(codelen < MAXLENGTH); + assert(codelen < MAX_LENGTH); s = lzw->wp; do { @@ -147,16 +147,16 @@ readlzwd(fz_stream *stm, unsigned char *buf, int len) *p++ = *lzw->rp++; } - lzw->codebits = codebits; + lzw->code_bits = code_bits; lzw->code = code; - lzw->oldcode = oldcode; - lzw->nextcode = nextcode; + lzw->old_code = old_code; + lzw->next_code = next_code; return p - buf; } static void -closelzwd(fz_stream *stm) +close_lzwd(fz_stream *stm) { fz_lzwd *lzw = stm->state; fz_close(lzw->chain); @@ -164,7 +164,7 @@ closelzwd(fz_stream *stm) } fz_stream * -fz_openlzwd(fz_stream *chain, fz_obj *params) +fz_open_lzwd(fz_stream *chain, fz_obj *params) { fz_lzwd *lzw; fz_obj *obj; @@ -173,34 +173,34 @@ fz_openlzwd(fz_stream *chain, fz_obj *params) lzw = fz_malloc(sizeof(fz_lzwd)); lzw->chain = chain; lzw->eod = 0; - lzw->earlychange = 1; + lzw->early_change = 1; - obj = fz_dictgets(params, "EarlyChange"); + obj = fz_dict_gets(params, "EarlyChange"); if (obj) - lzw->earlychange = !!fz_toint(obj); + lzw->early_change = !!fz_to_int(obj); for (i = 0; i < 256; i++) { lzw->table[i].value = i; - lzw->table[i].firstchar = i; + lzw->table[i].first_char = i; lzw->table[i].length = 1; lzw->table[i].prev = -1; } - for (i = 256; i < NUMCODES; i++) + for (i = 256; i < NUM_CODES; i++) { lzw->table[i].value = 0; - lzw->table[i].firstchar = 0; + lzw->table[i].first_char = 0; lzw->table[i].length = 0; lzw->table[i].prev = -1; } - lzw->codebits = MINBITS; + lzw->code_bits = MIN_BITS; lzw->code = -1; - lzw->nextcode = LZW_FIRST; - lzw->oldcode = -1; + lzw->next_code = LZW_FIRST; + lzw->old_code = -1; lzw->rp = lzw->bp; lzw->wp = lzw->bp; - return fz_newstream(lzw, readlzwd, closelzwd); + return fz_new_stream(lzw, read_lzwd, close_lzwd); } diff --git a/fitz/filt_predict.c b/fitz/filt_predict.c index ae2d1aaf..1501fc09 100644 --- a/fitz/filt_predict.c +++ b/fitz/filt_predict.c @@ -60,7 +60,7 @@ paeth(int a, int b, int c) } static void -fz_predicttiff(fz_predict *state, unsigned char *out, unsigned char *in, int len) +fz_predict_tiff(fz_predict *state, unsigned char *out, unsigned char *in, int len) { int left[MAXC]; int i, k; @@ -82,7 +82,7 @@ fz_predicttiff(fz_predict *state, unsigned char *out, unsigned char *in, int len } static void -fz_predictpng(fz_predict *state, unsigned char *out, unsigned char *in, int len, int predictor) +fz_predict_png(fz_predict *state, unsigned char *out, unsigned char *in, int len, int predictor) { int bpp = state->bpp; int i; @@ -141,7 +141,7 @@ fz_predictpng(fz_predict *state, unsigned char *out, unsigned char *in, int len, } static int -readpredict(fz_stream *stm, unsigned char *buf, int len) +read_predict(fz_stream *stm, unsigned char *buf, int len) { fz_predict *state = stm->state; unsigned char *p = buf; @@ -163,10 +163,10 @@ readpredict(fz_stream *stm, unsigned char *buf, int len) if (state->predictor == 1) memcpy(state->out, state->in, n); else if (state->predictor == 2) - fz_predicttiff(state, state->out, state->in, n); + fz_predict_tiff(state, state->out, state->in, n); else { - fz_predictpng(state, state->out, state->in + 1, n - 1, state->in[0]); + fz_predict_png(state, state->out, state->in + 1, n - 1, state->in[0]); memcpy(state->ref, state->out, state->stride); } @@ -181,7 +181,7 @@ readpredict(fz_stream *stm, unsigned char *buf, int len) } static void -closepredict(fz_stream *stm) +close_predict(fz_stream *stm) { fz_predict *state = stm->state; fz_close(state->chain); @@ -192,7 +192,7 @@ closepredict(fz_stream *stm) } fz_stream * -fz_openpredict(fz_stream *chain, fz_obj *params) +fz_open_predict(fz_stream *chain, fz_obj *params) { fz_predict *state; fz_obj *obj; @@ -205,9 +205,9 @@ fz_openpredict(fz_stream *chain, fz_obj *params) state->colors = 1; state->bpc = 8; - obj = fz_dictgets(params, "Predictor"); + obj = fz_dict_gets(params, "Predictor"); if (obj) - state->predictor = fz_toint(obj); + state->predictor = fz_to_int(obj); if (state->predictor != 1 && state->predictor != 2 && state->predictor != 10 && state->predictor != 11 && @@ -218,17 +218,17 @@ fz_openpredict(fz_stream *chain, fz_obj *params) state->predictor = 1; } - obj = fz_dictgets(params, "Columns"); + obj = fz_dict_gets(params, "Columns"); if (obj) - state->columns = fz_toint(obj); + state->columns = fz_to_int(obj); - obj = fz_dictgets(params, "Colors"); + obj = fz_dict_gets(params, "Colors"); if (obj) - state->colors = fz_toint(obj); + state->colors = fz_to_int(obj); - obj = fz_dictgets(params, "BitsPerComponent"); + obj = fz_dict_gets(params, "BitsPerComponent"); if (obj) - state->bpc = fz_toint(obj); + state->bpc = fz_to_int(obj); state->stride = (state->bpc * state->colors * state->columns + 7) / 8; state->bpp = (state->bpc * state->colors + 7) / 8; @@ -241,5 +241,5 @@ fz_openpredict(fz_stream *chain, fz_obj *params) memset(state->ref, 0, state->stride); - return fz_newstream(state, readpredict, closepredict); + return fz_new_stream(state, read_predict, close_predict); } diff --git a/fitz/fitz.h b/fitz/fitz.h index b8972871..c765da87 100644 --- a/fitz/fitz.h +++ b/fitz/fitz.h @@ -18,8 +18,6 @@ #include /* FLT_EPSILON */ #include /* O_RDONLY & co */ -#define nil ((void*)0) - #define nelem(x) (sizeof(x)/sizeof((x)[0])) /* @@ -63,33 +61,33 @@ int gettimeofday(struct timeval *tv, struct timezone *tz); #if __STDC_VERSION__ == 199901L /* C99 */ -#define fz_throw(...) fz_throwimp(__FILE__, __LINE__, __func__, __VA_ARGS__) -#define fz_rethrow(cause, ...) fz_rethrowimp(__FILE__, __LINE__, __func__, cause, __VA_ARGS__) -#define fz_catch(cause, ...) fz_catchimp(__FILE__, __LINE__, __func__, cause, __VA_ARGS__) +#define fz_throw(...) fz_throw_imp(__FILE__, __LINE__, __func__, __VA_ARGS__) +#define fz_rethrow(cause, ...) fz_rethrow_imp(__FILE__, __LINE__, __func__, cause, __VA_ARGS__) +#define fz_catch(cause, ...) fz_catch_imp(__FILE__, __LINE__, __func__, cause, __VA_ARGS__) #elif _MSC_VER >= 1500 /* MSVC 9 or newer */ #define inline __inline #define restrict __restrict -#define fz_throw(...) fz_throwimp(__FILE__, __LINE__, __FUNCTION__, __VA_ARGS__) -#define fz_rethrow(cause, ...) fz_rethrowimp(__FILE__, __LINE__, __FUNCTION__, cause, __VA_ARGS__) -#define fz_catch(cause, ...) fz_catchimp(__FILE__, __LINE__, __FUNCTION__, cause, __VA_ARGS__) +#define fz_throw(...) fz_throw_imp(__FILE__, __LINE__, __FUNCTION__, __VA_ARGS__) +#define fz_rethrow(cause, ...) fz_rethrow_imp(__FILE__, __LINE__, __FUNCTION__, cause, __VA_ARGS__) +#define fz_catch(cause, ...) fz_catch_imp(__FILE__, __LINE__, __FUNCTION__, cause, __VA_ARGS__) #elif __GNUC__ >= 3 /* GCC 3 or newer */ #define inline __inline #define restrict __restrict -#define fz_throw(fmt...) fz_throwimp(__FILE__, __LINE__, __FUNCTION__, fmt) -#define fz_rethrow(cause, fmt...) fz_rethrowimp(__FILE__, __LINE__, __FUNCTION__, cause, fmt) -#define fz_catch(cause, fmt...) fz_catchimp(__FILE__, __LINE__, __FUNCTION__, cause, fmt) +#define fz_throw(fmt...) fz_throw_imp(__FILE__, __LINE__, __FUNCTION__, fmt) +#define fz_rethrow(cause, fmt...) fz_rethrow_imp(__FILE__, __LINE__, __FUNCTION__, cause, fmt) +#define fz_catch(cause, fmt...) fz_catch_imp(__FILE__, __LINE__, __FUNCTION__, cause, fmt) #else /* Unknown or ancient */ #define inline #define restrict -#define fz_throw fz_throwimpx -#define fz_rethrow fz_rethrowimpx -#define fz_catch fz_catchimpx +#define fz_throw fz_throw_impx +#define fz_rethrow fz_rethrow_impx +#define fz_catch fz_catch_impx #endif @@ -113,21 +111,21 @@ int gettimeofday(struct timeval *tv, struct timezone *tz); typedef int fz_error; void fz_warn(char *fmt, ...) __printflike(1, 2); -void fz_flushwarnings(void); +void fz_flush_warnings(void); -fz_error fz_throwimp(const char *file, int line, const char *func, char *fmt, ...) __printflike(4, 5); -fz_error fz_rethrowimp(const char *file, int line, const char *func, fz_error cause, char *fmt, ...) __printflike(5, 6); -void fz_catchimp(const char *file, int line, const char *func, fz_error cause, char *fmt, ...) __printflike(5, 6); +fz_error fz_throw_imp(const char *file, int line, const char *func, char *fmt, ...) __printflike(4, 5); +fz_error fz_rethrow_imp(const char *file, int line, const char *func, fz_error cause, char *fmt, ...) __printflike(5, 6); +void fz_catch_imp(const char *file, int line, const char *func, fz_error cause, char *fmt, ...) __printflike(5, 6); -fz_error fz_throwimpx(char *fmt, ...) __printflike(1, 2); -fz_error fz_rethrowimpx(fz_error cause, char *fmt, ...) __printflike(2, 3); -void fz_catchimpx(fz_error cause, char *fmt, ...) __printflike(2, 3); +fz_error fz_throw_impx(char *fmt, ...) __printflike(1, 2); +fz_error fz_rethrow_impx(fz_error cause, char *fmt, ...) __printflike(2, 3); +void fz_catch_impx(fz_error cause, char *fmt, ...) __printflike(2, 3); #define fz_okay ((fz_error)0) /* extract the last error stack trace */ -int fz_geterrorcount(void); -char *fz_geterrorline(int n); +int fz_get_error_count(void); +char *fz_get_error_line(int n); /* * Basic runtime and utility functions @@ -146,7 +144,7 @@ void fz_free(void *p); char *fz_strdup(char *s); /* runtime (hah!) test for endian-ness */ -int fz_isbigendian(void); +int fz_is_big_endian(void); /* safe string functions */ char *fz_strsep(char **stringp, const char *delim); @@ -167,20 +165,20 @@ extern char *fz_optarg; * Generic hash-table with fixed-length keys. */ -typedef struct fz_hashtable_s fz_hashtable; +typedef struct fz_hash_table_s fz_hash_table; -fz_hashtable *fz_newhash(int initialsize, int keylen); -void fz_debughash(fz_hashtable *table); -void fz_emptyhash(fz_hashtable *table); -void fz_freehash(fz_hashtable *table); +fz_hash_table *fz_new_hash_table(int initialsize, int keylen); +void fz_debug_hash(fz_hash_table *table); +void fz_empty_hash(fz_hash_table *table); +void fz_free_hash(fz_hash_table *table); -void *fz_hashfind(fz_hashtable *table, void *key); -void fz_hashinsert(fz_hashtable *table, void *key, void *val); -void fz_hashremove(fz_hashtable *table, void *key); +void *fz_hash_find(fz_hash_table *table, void *key); +void fz_hash_insert(fz_hash_table *table, void *key, void *val); +void fz_hash_remove(fz_hash_table *table, void *key); -int fz_hashlen(fz_hashtable *table); -void *fz_hashgetkey(fz_hashtable *table, int idx); -void *fz_hashgetval(fz_hashtable *table, int idx); +int fz_hash_len(fz_hash_table *table); +void *fz_hash_get_key(fz_hash_table *table, int idx); +void *fz_hash_get_val(fz_hash_table *table, int idx); /* * Math and geometry @@ -203,7 +201,7 @@ static inline int fz_mul255(int a, int b) #define FZ_COMBINE(A,B) (((A)*(B))>>8) /* Combine values A and C (in the same (any) range) and B and D (in the - * 0..256 range), to give a single value in the same range as A and C were. */ + * 0..256 range), to give a single value in the same range as A and C were. */ #define FZ_COMBINE2(A,B,C,D) (FZ_COMBINE((A), (B)) + FZ_COMBINE((C), (D))) /* Blend SRC and DST (in the same range) together according to @@ -215,18 +213,18 @@ typedef struct fz_point_s fz_point; typedef struct fz_rect_s fz_rect; typedef struct fz_bbox_s fz_bbox; -extern const fz_rect fz_unitrect; -extern const fz_rect fz_emptyrect; -extern const fz_rect fz_infiniterect; +extern const fz_rect fz_unit_rect; +extern const fz_rect fz_empty_rect; +extern const fz_rect fz_infinite_rect; -extern const fz_bbox fz_unitbbox; -extern const fz_bbox fz_emptybbox; -extern const fz_bbox fz_infinitebbox; +extern const fz_bbox fz_unit_bbox; +extern const fz_bbox fz_empty_bbox; +extern const fz_bbox fz_infinite_bbox; -#define fz_isemptyrect(r) ((r).x0 == (r).x1) -#define fz_isinfiniterect(r) ((r).x0 > (r).x1) -#define fz_isemptybbox(b) ((b).x0 == (b).x1) -#define fz_isinfinitebbox(b) ((b).x0 > (b).x1) +#define fz_is_empty_rect(r) ((r).x0 == (r).x1) +#define fz_is_infinite_rect(r) ((r).x0 > (r).x1) +#define fz_is_empty_bbox(b) ((b).x0 == (b).x1) +#define fz_is_infinite_bbox(b) ((b).x0 > (b).x1) struct fz_matrix_s { @@ -256,18 +254,18 @@ fz_matrix fz_concat(fz_matrix one, fz_matrix two); fz_matrix fz_scale(float sx, float sy); fz_matrix fz_rotate(float theta); fz_matrix fz_translate(float tx, float ty); -fz_matrix fz_invertmatrix(fz_matrix m); -int fz_isrectilinear(fz_matrix m); -float fz_matrixexpansion(fz_matrix m); +fz_matrix fz_invert_matrix(fz_matrix m); +int fz_is_rectilinear(fz_matrix m); +float fz_matrix_expansion(fz_matrix m); -fz_bbox fz_roundrect(fz_rect r); -fz_bbox fz_intersectbbox(fz_bbox a, fz_bbox b); -fz_bbox fz_unionbbox(fz_bbox a, fz_bbox b); +fz_bbox fz_round_rect(fz_rect r); +fz_bbox fz_intersect_bbox(fz_bbox a, fz_bbox b); +fz_bbox fz_union_bbox(fz_bbox a, fz_bbox b); -fz_point fz_transformpoint(fz_matrix m, fz_point p); -fz_point fz_transformvector(fz_matrix m, fz_point p); -fz_rect fz_transformrect(fz_matrix m, fz_rect r); -fz_bbox fz_transformbbox(fz_matrix m, fz_bbox b); +fz_point fz_transform_point(fz_matrix m, fz_point p); +fz_point fz_transform_vector(fz_matrix m, fz_point p); +fz_rect fz_transform_rect(fz_matrix m, fz_rect r); +fz_bbox fz_transform_bbox(fz_matrix m, fz_bbox b); /* * Basic crypto functions. @@ -286,9 +284,9 @@ struct fz_md5_s unsigned char buffer[64]; }; -void fz_md5init(fz_md5 *state); -void fz_md5update(fz_md5 *state, const unsigned char *input, const unsigned inlen); -void fz_md5final(fz_md5 *state, unsigned char digest[16]); +void fz_md5_init(fz_md5 *state); +void fz_md5_update(fz_md5 *state, const unsigned char *input, const unsigned inlen); +void fz_md5_final(fz_md5 *state, unsigned char digest[16]); /* sha-256 digests */ @@ -304,9 +302,9 @@ struct fz_sha256_s } buffer; }; -void fz_sha256init(fz_sha256 *state); -void fz_sha256update(fz_sha256 *state, const unsigned char *input, unsigned int inlen); -void fz_sha256final(fz_sha256 *state, unsigned char digest[32]); +void fz_sha256_init(fz_sha256 *state); +void fz_sha256_update(fz_sha256 *state, const unsigned char *input, unsigned int inlen); +void fz_sha256_final(fz_sha256 *state, unsigned char digest[32]); /* arc4 crypto */ @@ -319,8 +317,8 @@ struct fz_arc4_s unsigned char state[256]; }; -void fz_arc4init(fz_arc4 *state, const unsigned char *key, const unsigned len); -void fz_arc4encrypt(fz_arc4 *state, unsigned char *dest, const unsigned char *src, const unsigned len); +void fz_arc4_init(fz_arc4 *state, const unsigned char *key, const unsigned len); +void fz_arc4_encrypt(fz_arc4 *state, unsigned char *dest, const unsigned char *src, const unsigned len); /* AES block cipher implementation from XYSSL */ @@ -406,69 +404,69 @@ struct fz_obj_s } u; }; -extern fz_obj* (*fz_resolveindirect)(fz_obj*); +extern fz_obj* (*fz_resolve_indirect)(fz_obj*); -fz_obj *fz_newnull(void); -fz_obj *fz_newbool(int b); -fz_obj *fz_newint(int i); -fz_obj *fz_newreal(float f); -fz_obj *fz_newname(char *str); -fz_obj *fz_newstring(char *str, int len); -fz_obj *fz_newindirect(int num, int gen, void *xref); +fz_obj *fz_new_null(void); +fz_obj *fz_new_bool(int b); +fz_obj *fz_new_int(int i); +fz_obj *fz_new_real(float f); +fz_obj *fz_new_name(char *str); +fz_obj *fz_new_string(char *str, int len); +fz_obj *fz_new_indirect(int num, int gen, void *xref); -fz_obj *fz_newarray(int initialcap); -fz_obj *fz_newdict(int initialcap); -fz_obj *fz_copyarray(fz_obj *array); -fz_obj *fz_copydict(fz_obj *dict); +fz_obj *fz_new_array(int initialcap); +fz_obj *fz_new_dict(int initialcap); +fz_obj *fz_copy_array(fz_obj *array); +fz_obj *fz_copy_dict(fz_obj *dict); -fz_obj *fz_keepobj(fz_obj *obj); -void fz_dropobj(fz_obj *obj); +fz_obj *fz_keep_obj(fz_obj *obj); +void fz_drop_obj(fz_obj *obj); /* type queries */ -int fz_isnull(fz_obj *obj); -int fz_isbool(fz_obj *obj); -int fz_isint(fz_obj *obj); -int fz_isreal(fz_obj *obj); -int fz_isname(fz_obj *obj); -int fz_isstring(fz_obj *obj); -int fz_isarray(fz_obj *obj); -int fz_isdict(fz_obj *obj); -int fz_isindirect(fz_obj *obj); +int fz_is_null(fz_obj *obj); +int fz_is_bool(fz_obj *obj); +int fz_is_int(fz_obj *obj); +int fz_is_real(fz_obj *obj); +int fz_is_name(fz_obj *obj); +int fz_is_string(fz_obj *obj); +int fz_is_array(fz_obj *obj); +int fz_is_dict(fz_obj *obj); +int fz_is_indirect(fz_obj *obj); int fz_objcmp(fz_obj *a, fz_obj *b); /* silent failure, no error reporting */ -int fz_tobool(fz_obj *obj); -int fz_toint(fz_obj *obj); -float fz_toreal(fz_obj *obj); -char *fz_toname(fz_obj *obj); -char *fz_tostrbuf(fz_obj *obj); -int fz_tostrlen(fz_obj *obj); -int fz_tonum(fz_obj *obj); -int fz_togen(fz_obj *obj); - -int fz_arraylen(fz_obj *array); -fz_obj *fz_arrayget(fz_obj *array, int i); -void fz_arrayput(fz_obj *array, int i, fz_obj *obj); -void fz_arraypush(fz_obj *array, fz_obj *obj); -void fz_arraydrop(fz_obj *array); -void fz_arrayinsert(fz_obj *array, fz_obj *obj); - -int fz_dictlen(fz_obj *dict); -fz_obj *fz_dictgetkey(fz_obj *dict, int idx); -fz_obj *fz_dictgetval(fz_obj *dict, int idx); -fz_obj *fz_dictget(fz_obj *dict, fz_obj *key); -fz_obj *fz_dictgets(fz_obj *dict, char *key); -fz_obj *fz_dictgetsa(fz_obj *dict, char *key, char *abbrev); -void fz_dictput(fz_obj *dict, fz_obj *key, fz_obj *val); -void fz_dictputs(fz_obj *dict, char *key, fz_obj *val); -void fz_dictdel(fz_obj *dict, fz_obj *key); -void fz_dictdels(fz_obj *dict, char *key); -void fz_sortdict(fz_obj *dict); - -int fz_fprintobj(FILE *fp, fz_obj *obj, int tight); -void fz_debugobj(fz_obj *obj); -void fz_debugref(fz_obj *obj); +int fz_to_bool(fz_obj *obj); +int fz_to_int(fz_obj *obj); +float fz_to_real(fz_obj *obj); +char *fz_to_name(fz_obj *obj); +char *fz_to_str_buf(fz_obj *obj); +int fz_to_str_len(fz_obj *obj); +int fz_to_num(fz_obj *obj); +int fz_to_gen(fz_obj *obj); + +int fz_array_len(fz_obj *array); +fz_obj *fz_array_get(fz_obj *array, int i); +void fz_array_put(fz_obj *array, int i, fz_obj *obj); +void fz_array_push(fz_obj *array, fz_obj *obj); +void fz_array_drop(fz_obj *array); +void fz_array_insert(fz_obj *array, fz_obj *obj); + +int fz_dict_len(fz_obj *dict); +fz_obj *fz_dict_get_key(fz_obj *dict, int idx); +fz_obj *fz_dict_get_val(fz_obj *dict, int idx); +fz_obj *fz_dict_get(fz_obj *dict, fz_obj *key); +fz_obj *fz_dict_gets(fz_obj *dict, char *key); +fz_obj *fz_dict_getsa(fz_obj *dict, char *key, char *abbrev); +void fz_dict_put(fz_obj *dict, fz_obj *key, fz_obj *val); +void fz_dict_puts(fz_obj *dict, char *key, fz_obj *val); +void fz_dict_del(fz_obj *dict, fz_obj *key); +void fz_dict_dels(fz_obj *dict, char *key); +void fz_sort_dict(fz_obj *dict); + +int fz_fprint_obj(FILE *fp, fz_obj *obj, int tight); +void fz_debug_obj(fz_obj *obj); +void fz_debug_ref(fz_obj *obj); char *fz_objkindstr(fz_obj *obj); @@ -485,12 +483,12 @@ struct fz_buffer_s int cap, len; }; -fz_buffer *fz_newbuffer(int size); -fz_buffer *fz_keepbuffer(fz_buffer *buf); -void fz_dropbuffer(fz_buffer *buf); +fz_buffer *fz_new_buffer(int size); +fz_buffer *fz_keep_buffer(fz_buffer *buf); +void fz_drop_buffer(fz_buffer *buf); -void fz_resizebuffer(fz_buffer *buf, int size); -void fz_growbuffer(fz_buffer *buf); +void fz_resize_buffer(fz_buffer *buf, int size); +void fz_grow_buffer(fz_buffer *buf); /* * Buffered reader. @@ -515,62 +513,62 @@ struct fz_stream_s unsigned char buf[4096]; }; -fz_stream *fz_openfd(int file); -fz_stream *fz_openfile(const char *filename); -fz_stream *fz_openfilew(const wchar_t *filename); /* only on win32 */ -fz_stream *fz_openbuffer(fz_buffer *buf); -fz_stream *fz_openmemory(unsigned char *data, int len); +fz_stream *fz_open_fd(int file); +fz_stream *fz_open_file(const char *filename); +fz_stream *fz_open_file_w(const wchar_t *filename); /* only on win32 */ +fz_stream *fz_open_buffer(fz_buffer *buf); +fz_stream *fz_open_memory(unsigned char *data, int len); void fz_close(fz_stream *stm); -fz_stream *fz_newstream(void*, int(*)(fz_stream*, unsigned char*, int), void(*)(fz_stream *)); -fz_stream *fz_keepstream(fz_stream *stm); -void fz_fillbuffer(fz_stream *stm); +fz_stream *fz_new_stream(void*, int(*)(fz_stream*, unsigned char*, int), void(*)(fz_stream *)); +fz_stream *fz_keep_stream(fz_stream *stm); +void fz_fill_buffer(fz_stream *stm); int fz_tell(fz_stream *stm); void fz_seek(fz_stream *stm, int offset, int whence); int fz_read(fz_stream *stm, unsigned char *buf, int len); -void fz_readline(fz_stream *stm, char *buf, int max); -fz_error fz_readall(fz_buffer **bufp, fz_stream *stm, int initial); +void fz_read_line(fz_stream *stm, char *buf, int max); +fz_error fz_read_all(fz_buffer **bufp, fz_stream *stm, int initial); -static inline int fz_readbyte(fz_stream *stm) +static inline int fz_read_byte(fz_stream *stm) { if (stm->rp == stm->wp) { - fz_fillbuffer(stm); + fz_fill_buffer(stm); return stm->rp < stm->wp ? *stm->rp++ : EOF; } return *stm->rp++; } -static inline int fz_peekbyte(fz_stream *stm) +static inline int fz_peek_byte(fz_stream *stm) { if (stm->rp == stm->wp) { - fz_fillbuffer(stm); + fz_fill_buffer(stm); return stm->rp < stm->wp ? *stm->rp : EOF; } return *stm->rp; } -static inline void fz_unreadbyte(fz_stream *stm) +static inline void fz_unread_byte(fz_stream *stm) { if (stm->rp > stm->bp) stm->rp--; } -static inline int fz_iseof(fz_stream *stm) +static inline int fz_is_eof(fz_stream *stm) { if (stm->rp == stm->wp) { if (stm->eof) return 1; - return fz_peekbyte(stm) == EOF; + return fz_peek_byte(stm) == EOF; } return 0; } -static inline unsigned int fz_readbits(fz_stream *stm, int n) +static inline unsigned int fz_read_bits(fz_stream *stm, int n) { unsigned int x; @@ -587,13 +585,13 @@ static inline unsigned int fz_readbits(fz_stream *stm, int n) while (n > 8) { - x = (x << 8) | fz_readbyte(stm); + x = (x << 8) | fz_read_byte(stm); n -= 8; } if (n > 0) { - stm->bits = fz_readbyte(stm); + stm->bits = fz_read_byte(stm); stm->avail = 8 - n; x = (x << n) | (stm->bits >> stm->avail); } @@ -602,64 +600,64 @@ static inline unsigned int fz_readbits(fz_stream *stm, int n) return x; } -static inline void fz_syncbits(fz_stream *stm) +static inline void fz_sync_bits(fz_stream *stm) { stm->avail = 0; } -static inline int fz_iseofbits(fz_stream *stm) +static inline int fz_is_eof_bits(fz_stream *stm) { - return fz_iseof(stm) && (stm->avail == 0 || stm->bits == EOF); + return fz_is_eof(stm) && (stm->avail == 0 || stm->bits == EOF); } /* * Data filters. */ -fz_stream *fz_opencopy(fz_stream *chain); -fz_stream *fz_opennull(fz_stream *chain, int len); -fz_stream *fz_openarc4(fz_stream *chain, unsigned char *key, unsigned keylen); -fz_stream *fz_openaesd(fz_stream *chain, unsigned char *key, unsigned keylen); -fz_stream *fz_opena85d(fz_stream *chain); -fz_stream *fz_openahxd(fz_stream *chain); -fz_stream *fz_openrld(fz_stream *chain); -fz_stream *fz_opendctd(fz_stream *chain, fz_obj *param); -fz_stream *fz_openfaxd(fz_stream *chain, fz_obj *param); -fz_stream *fz_openflated(fz_stream *chain); -fz_stream *fz_openlzwd(fz_stream *chain, fz_obj *param); -fz_stream *fz_openpredict(fz_stream *chain, fz_obj *param); -fz_stream *fz_openjbig2d(fz_stream *chain, fz_buffer *global); +fz_stream *fz_open_copy(fz_stream *chain); +fz_stream *fz_open_null(fz_stream *chain, int len); +fz_stream *fz_open_arc4(fz_stream *chain, unsigned char *key, unsigned keylen); +fz_stream *fz_open_aesd(fz_stream *chain, unsigned char *key, unsigned keylen); +fz_stream *fz_open_a85d(fz_stream *chain); +fz_stream *fz_open_ahxd(fz_stream *chain); +fz_stream *fz_open_rld(fz_stream *chain); +fz_stream *fz_open_dctd(fz_stream *chain, fz_obj *param); +fz_stream *fz_open_faxd(fz_stream *chain, fz_obj *param); +fz_stream *fz_open_flated(fz_stream *chain); +fz_stream *fz_open_lzwd(fz_stream *chain, fz_obj *param); +fz_stream *fz_open_predict(fz_stream *chain, fz_obj *param); +fz_stream *fz_open_jbig2d(fz_stream *chain, fz_buffer *global); /* * Resources and other graphics related objects. */ -enum { FZ_MAXCOLORS = 32 }; +enum { FZ_MAX_COLORS = 32 }; typedef enum fz_blendmode_e { /* PDF 1.4 -- standard separable */ - FZ_BNORMAL, - FZ_BMULTIPLY, - FZ_BSCREEN, - FZ_BOVERLAY, - FZ_BDARKEN, - FZ_BLIGHTEN, - FZ_BCOLORDODGE, - FZ_BCOLORBURN, - FZ_BHARDLIGHT, - FZ_BSOFTLIGHT, - FZ_BDIFFERENCE, - FZ_BEXCLUSION, + FZ_BLEND_NORMAL, + FZ_BLEND_MULTIPLY, + FZ_BLEND_SCREEN, + FZ_BLEND_OVERLAY, + FZ_BLEND_DARKEN, + FZ_BLEND_LIGHTEN, + FZ_BLEND_COLOR_DODGE, + FZ_BLEND_COLOR_BURN, + FZ_BLEND_HARD_LIGHT, + FZ_BLEND_SOFT_LIGHT, + FZ_BLEND_DIFFERENCE, + FZ_BLEND_EXCLUSION, /* PDF 1.4 -- standard non-separable */ - FZ_BHUE, - FZ_BSATURATION, - FZ_BCOLOR, - FZ_BLUMINOSITY, + FZ_BLEND_HUE, + FZ_BLEND_SATURATION, + FZ_BLEND_COLOR, + FZ_BLEND_LUMINOSITY, } fz_blendmode; -extern const char *fz_blendnames[]; +extern const char *fz_blendmode_names[]; /* * Pixmaps have n components per pixel. the last is always alpha. @@ -679,54 +677,54 @@ struct fz_pixmap_s int xres, yres; fz_colorspace *colorspace; unsigned char *samples; - int freesamples; + int free_samples; }; -fz_pixmap *fz_newpixmapwithdata(fz_colorspace *colorspace, int x, int y, int w, int h, unsigned char *samples); -fz_pixmap *fz_newpixmapwithrect(fz_colorspace *, fz_bbox bbox); -fz_pixmap *fz_newpixmap(fz_colorspace *, int x, int y, int w, int h); -fz_pixmap *fz_keeppixmap(fz_pixmap *pix); -void fz_droppixmap(fz_pixmap *pix); -void fz_clearpixmap(fz_pixmap *pix); -void fz_clearpixmapwithcolor(fz_pixmap *pix, int value); -void fz_premultiplypixmap(fz_pixmap *pix); -fz_pixmap *fz_alphafromgray(fz_pixmap *gray, int luminosity); -fz_bbox fz_boundpixmap(fz_pixmap *pix); +fz_pixmap *fz_new_pixmap_with_data(fz_colorspace *colorspace, int x, int y, int w, int h, unsigned char *samples); +fz_pixmap *fz_new_pixmap_with_rect(fz_colorspace *, fz_bbox bbox); +fz_pixmap *fz_new_pixmap(fz_colorspace *, int x, int y, int w, int h); +fz_pixmap *fz_keep_pixmap(fz_pixmap *pix); +void fz_drop_pixmap(fz_pixmap *pix); +void fz_clear_pixmap(fz_pixmap *pix); +void fz_clear_pixmap_with_color(fz_pixmap *pix, int value); +void fz_premultiply_pixmap(fz_pixmap *pix); +fz_pixmap *fz_alpha_from_gray(fz_pixmap *gray, int luminosity); +fz_bbox fz_bound_pixmap(fz_pixmap *pix); -fz_pixmap *fz_scalepixmap(fz_pixmap *src, float x, float y, float w, float h); +fz_pixmap *fz_scale_pixmap(fz_pixmap *src, float x, float y, float w, float h); -fz_error fz_writepnm(fz_pixmap *pixmap, char *filename); -fz_error fz_writepam(fz_pixmap *pixmap, char *filename, int savealpha); -fz_error fz_writepng(fz_pixmap *pixmap, char *filename, int savealpha); +fz_error fz_write_pnm(fz_pixmap *pixmap, char *filename); +fz_error fz_write_pam(fz_pixmap *pixmap, char *filename, int savealpha); +fz_error fz_write_png(fz_pixmap *pixmap, char *filename, int savealpha); -fz_error fz_loadjpximage(fz_pixmap **imgp, unsigned char *data, int size); +fz_error fz_load_jpx_image(fz_pixmap **imgp, unsigned char *data, int size); /* * Colorspace resources. */ -extern fz_colorspace *fz_devicegray; -extern fz_colorspace *fz_devicergb; -extern fz_colorspace *fz_devicebgr; -extern fz_colorspace *fz_devicecmyk; +extern fz_colorspace *fz_device_gray; +extern fz_colorspace *fz_device_rgb; +extern fz_colorspace *fz_device_bgr; +extern fz_colorspace *fz_device_cmyk; struct fz_colorspace_s { int refs; char name[16]; int n; - void (*toxyz)(fz_colorspace *, float *src, float *xyz); - void (*fromxyz)(fz_colorspace *, float *xyz, float *dst); - void (*freedata)(fz_colorspace *); + void (*to_xyz)(fz_colorspace *, float *src, float *xyz); + void (*from_xyz)(fz_colorspace *, float *xyz, float *dst); + void (*free_data)(fz_colorspace *); void *data; }; -fz_colorspace *fz_newcolorspace(char *name, int n); -fz_colorspace *fz_keepcolorspace(fz_colorspace *colorspace); -void fz_dropcolorspace(fz_colorspace *colorspace); +fz_colorspace *fz_new_colorspace(char *name, int n); +fz_colorspace *fz_keep_colorspace(fz_colorspace *colorspace); +void fz_drop_colorspace(fz_colorspace *colorspace); -void fz_convertcolor(fz_colorspace *srcs, float *srcv, fz_colorspace *dsts, float *dstv); -void fz_convertpixmap(fz_pixmap *src, fz_pixmap *dst); +void fz_convert_color(fz_colorspace *srcs, float *srcv, fz_colorspace *dsts, float *dstv); +void fz_convert_pixmap(fz_pixmap *src, fz_pixmap *dst); /* * Fonts come in two variants: @@ -737,21 +735,21 @@ void fz_convertpixmap(fz_pixmap *src, fz_pixmap *dst); struct fz_device_s; typedef struct fz_font_s fz_font; -char *ft_errorstring(int err); +char *ft_error_string(int err); struct fz_font_s { int refs; char name[32]; - void *ftface; /* has an FT_Face if used */ - int ftsubstitute; /* ... substitute metrics */ - int fthint; /* ... force hinting for DynaLab fonts */ + void *ft_face; /* has an FT_Face if used */ + int ft_substitute; /* ... substitute metrics */ + int ft_hint; /* ... force hinting for DynaLab fonts */ /* origin of font data */ - char *ftfile; - unsigned char *ftdata; - int ftsize; + char *ft_file; + unsigned char *ft_data; + int ft_size; fz_matrix t3matrix; fz_obj *t3resources; @@ -764,81 +762,81 @@ struct fz_font_s fz_rect bbox; /* substitute metrics */ - int widthcount; - int *widthtable; + int width_count; + int *width_table; }; -fz_font *fz_newtype3font(char *name, fz_matrix matrix); +fz_font *fz_new_type3_font(char *name, fz_matrix matrix); -fz_error fz_newfontfrombuffer(fz_font **fontp, unsigned char *data, int len, int index); -fz_error fz_newfontfromfile(fz_font **fontp, char *path, int index); +fz_error fz_new_font_from_memory(fz_font **fontp, unsigned char *data, int len, int index); +fz_error fz_new_font_from_file(fz_font **fontp, char *path, int index); -fz_font *fz_keepfont(fz_font *font); -void fz_dropfont(fz_font *font); +fz_font *fz_keep_font(fz_font *font); +void fz_drop_font(fz_font *font); -void fz_debugfont(fz_font *font); -void fz_setfontbbox(fz_font *font, float xmin, float ymin, float xmax, float ymax); +void fz_debug_font(fz_font *font); +void fz_set_font_bbox(fz_font *font, float xmin, float ymin, float xmax, float ymax); /* * Vector path buffer. * It can be stroked and dashed, or be filled. - * It has a fill rule (nonzero or evenodd). + * It has a fill rule (nonzero or even_odd). * * When rendering, they are flattened, stroked and dashed straight * into the Global Edge List. */ typedef struct fz_path_s fz_path; -typedef struct fz_strokestate_s fz_strokestate; +typedef struct fz_stroke_state_s fz_stroke_state; -typedef union fz_pathel_s fz_pathel; +typedef union fz_path_item_s fz_path_item; -typedef enum fz_pathelkind_e +typedef enum fz_path_item_kind_e { FZ_MOVETO, FZ_LINETO, FZ_CURVETO, - FZ_CLOSEPATH -} fz_pathelkind; + FZ_CLOSE_PATH +} fz_path_item_kind; -union fz_pathel_s +union fz_path_item_s { - fz_pathelkind k; + fz_path_item_kind k; float v; }; struct fz_path_s { int len, cap; - fz_pathel *els; + fz_path_item *items; }; -struct fz_strokestate_s +struct fz_stroke_state_s { int linecap; int linejoin; float linewidth; float miterlimit; - float dashphase; - int dashlen; - float dashlist[32]; + float dash_phase; + int dash_len; + float dash_list[32]; }; -fz_path *fz_newpath(void); +fz_path *fz_new_path(void); void fz_moveto(fz_path*, float x, float y); void fz_lineto(fz_path*, float x, float y); void fz_curveto(fz_path*, float, float, float, float, float, float); void fz_curvetov(fz_path*, float, float, float, float); void fz_curvetoy(fz_path*, float, float, float, float); void fz_closepath(fz_path*); -void fz_freepath(fz_path *path); +void fz_free_path(fz_path *path); -void fz_transformpath(fz_path *path, fz_matrix transform); +void fz_transform_path(fz_path *path, fz_matrix transform); -fz_path *fz_clonepath(fz_path *old); +fz_path *fz_clone_path(fz_path *old); -fz_rect fz_boundpath(fz_path *path, fz_strokestate *stroke, fz_matrix ctm); -void fz_debugpath(fz_path *, int indent); +fz_rect fz_bound_path(fz_path *path, fz_stroke_state *stroke, fz_matrix ctm); +void fz_debug_path(fz_path *, int indent); /* * Text buffer. @@ -853,9 +851,9 @@ void fz_debugpath(fz_path *, int indent); */ typedef struct fz_text_s fz_text; -typedef struct fz_textel_s fz_textel; +typedef struct fz_text_item_s fz_text_item; -struct fz_textel_s +struct fz_text_item_s { float x, y; int gid; /* -1 for one gid to many ucs mappings */ @@ -868,15 +866,15 @@ struct fz_text_s fz_matrix trm; int wmode; int len, cap; - fz_textel *els; + fz_text_item *items; }; -fz_text *fz_newtext(fz_font *face, fz_matrix trm, int wmode); -void fz_addtext(fz_text *text, int gid, int ucs, float x, float y); -void fz_freetext(fz_text *text); -void fz_debugtext(fz_text*, int indent); -fz_rect fz_boundtext(fz_text *text, fz_matrix ctm); -fz_text *fz_clonetext(fz_text *old); +fz_text *fz_new_text(fz_font *face, fz_matrix trm, int wmode); +void fz_add_text(fz_text *text, int gid, int ucs, float x, float y); +void fz_free_text(fz_text *text); +void fz_debug_text(fz_text*, int indent); +fz_rect fz_bound_text(fz_text *text, fz_matrix ctm); +fz_text *fz_clone_text(fz_text *old); /* * The shading code uses gouraud shaded triangle meshes. @@ -895,44 +893,44 @@ struct fz_shade_s { int refs; - fz_rect bbox; /* can be fz_infiniterect */ + fz_rect bbox; /* can be fz_infinite_rect */ fz_colorspace *colorspace; fz_matrix matrix; /* matrix from pattern dict */ - int usebackground; /* background color for fills but not 'sh' */ - float background[FZ_MAXCOLORS]; + int use_background; /* background color for fills but not 'sh' */ + float background[FZ_MAX_COLORS]; - int usefunction; - float function[256][FZ_MAXCOLORS + 1]; + int use_function; + float function[256][FZ_MAX_COLORS + 1]; int type; /* linear, radial, mesh */ int extend[2]; - int meshlen; - int meshcap; + int mesh_len; + int mesh_cap; float *mesh; /* [x y 0], [x y r], [x y t] or [x y c1 ... cn] */ }; -fz_shade *fz_keepshade(fz_shade *shade); -void fz_dropshade(fz_shade *shade); -void fz_debugshade(fz_shade *shade); +fz_shade *fz_keep_shade(fz_shade *shade); +void fz_drop_shade(fz_shade *shade); +void fz_debug_shade(fz_shade *shade); -fz_rect fz_boundshade(fz_shade *shade, fz_matrix ctm); -void fz_paintshade(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox); +fz_rect fz_bound_shade(fz_shade *shade, fz_matrix ctm); +void fz_paint_shade(fz_shade *shade, fz_matrix ctm, fz_pixmap *dest, fz_bbox bbox); /* * Glyph cache */ -typedef struct fz_glyphcache_s fz_glyphcache; +typedef struct fz_glyph_cache_s fz_glyph_cache; -fz_glyphcache *fz_newglyphcache(void); -fz_pixmap *fz_renderftglyph(fz_font *font, int cid, fz_matrix trm); -fz_pixmap *fz_rendert3glyph(fz_font *font, int cid, fz_matrix trm); -fz_pixmap *fz_renderftstrokedglyph(fz_font *font, int gid, fz_matrix trm, fz_matrix ctm, fz_strokestate *state); -fz_pixmap *fz_renderglyph(fz_glyphcache*, fz_font*, int, fz_matrix); -fz_pixmap *fz_renderstrokedglyph(fz_glyphcache*, fz_font*, int, fz_matrix, fz_matrix, fz_strokestate *stroke); -void fz_freeglyphcache(fz_glyphcache *); +fz_glyph_cache *fz_new_glyph_cache(void); +fz_pixmap *fz_render_ft_glyph(fz_font *font, int cid, fz_matrix trm); +fz_pixmap *fz_render_t3_glyph(fz_font *font, int cid, fz_matrix trm); +fz_pixmap *fz_render_ft_stroked_glyph(fz_font *font, int gid, fz_matrix trm, fz_matrix ctm, fz_stroke_state *state); +fz_pixmap *fz_render_glyph(fz_glyph_cache*, fz_font*, int, fz_matrix); +fz_pixmap *fz_render_stroked_glyph(fz_glyph_cache*, fz_font*, int, fz_matrix, fz_matrix, fz_stroke_state *stroke); +void fz_free_glyph_cache(fz_glyph_cache *); /* * Scan converter @@ -945,7 +943,7 @@ typedef struct fz_ael_s fz_ael; struct fz_edge_s { int x, e, h, y; - int adjup, adjdown; + int adj_up, adj_down; int xmove; int xdir, ydir; /* -1 or +1 */ }; @@ -966,23 +964,23 @@ struct fz_ael_s fz_edge **edges; }; -fz_gel *fz_newgel(void); -void fz_insertgel(fz_gel *gel, float x0, float y0, float x1, float y1); -fz_bbox fz_boundgel(fz_gel *gel); -void fz_resetgel(fz_gel *gel, fz_bbox clip); -void fz_sortgel(fz_gel *gel); -void fz_freegel(fz_gel *gel); -int fz_isrectgel(fz_gel *gel); +fz_gel *fz_new_gel(void); +void fz_insert_gel(fz_gel *gel, float x0, float y0, float x1, float y1); +fz_bbox fz_bound_gel(fz_gel *gel); +void fz_reset_gel(fz_gel *gel, fz_bbox clip); +void fz_sort_gel(fz_gel *gel); +void fz_free_gel(fz_gel *gel); +int fz_is_rect_gel(fz_gel *gel); -fz_ael *fz_newael(void); -void fz_freeael(fz_ael *ael); +fz_ael *fz_new_ael(void); +void fz_free_ael(fz_ael *ael); -fz_error fz_scanconvert(fz_gel *gel, fz_ael *ael, int eofill, +fz_error fz_scan_convert(fz_gel *gel, fz_ael *ael, int eofill, fz_bbox clip, fz_pixmap *pix, unsigned char *colorbv); -void fz_fillpath(fz_gel *gel, fz_path *path, fz_matrix ctm, float flatness); -void fz_strokepath(fz_gel *gel, fz_path *path, fz_strokestate *stroke, fz_matrix ctm, float flatness, float linewidth); -void fz_dashpath(fz_gel *gel, fz_path *path, fz_strokestate *stroke, fz_matrix ctm, float flatness, float linewidth); +void fz_fill_path(fz_gel *gel, fz_path *path, fz_matrix ctm, float flatness); +void fz_stroke_path(fz_gel *gel, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm, float flatness, float linewidth); +void fz_dash_path(fz_gel *gel, fz_path *path, fz_stroke_state *stroke, fz_matrix ctm, float flatness, float linewidth); /* * The device interface. @@ -990,8 +988,8 @@ void fz_dashpath(fz_gel *gel, fz_path *path, fz_strokestate *stroke, fz_matrix c enum { - FZ_IGNOREIMAGE = 1, - FZ_IGNORESHADE = 2, + FZ_IGNORE_IMAGE = 1, + FZ_IGNORE_SHADE = 2, }; typedef struct fz_device_s fz_device; @@ -1001,110 +999,110 @@ struct fz_device_s int hints; void *user; - void (*freeuser)(void *); + void (*free_user)(void *); - void (*fillpath)(void *, fz_path *, int evenodd, fz_matrix, fz_colorspace *, float *color, float alpha); - void (*strokepath)(void *, fz_path *, fz_strokestate *, fz_matrix, fz_colorspace *, float *color, float alpha); - void (*clippath)(void *, fz_path *, int evenodd, fz_matrix); - void (*clipstrokepath)(void *, fz_path *, fz_strokestate *, fz_matrix); + void (*fill_path)(void *, fz_path *, int even_odd, fz_matrix, fz_colorspace *, float *color, float alpha); + void (*stroke_path)(void *, fz_path *, fz_stroke_state *, fz_matrix, fz_colorspace *, float *color, float alpha); + void (*clip_path)(void *, fz_path *, int even_odd, fz_matrix); + void (*clip_stroke_path)(void *, fz_path *, fz_stroke_state *, fz_matrix); - void (*filltext)(void *, fz_text *, fz_matrix, fz_colorspace *, float *color, float alpha); - void (*stroketext)(void *, fz_text *, fz_strokestate *, fz_matrix, fz_colorspace *, float *color, float alpha); - void (*cliptext)(void *, fz_text *, fz_matrix, int accumulate); - void (*clipstroketext)(void *, fz_text *, fz_strokestate *, fz_matrix); - void (*ignoretext)(void *, fz_text *, fz_matrix); + void (*fill_text)(void *, fz_text *, fz_matrix, fz_colorspace *, float *color, float alpha); + void (*stroke_text)(void *, fz_text *, fz_stroke_state *, fz_matrix, fz_colorspace *, float *color, float alpha); + void (*clip_text)(void *, fz_text *, fz_matrix, int accumulate); + void (*clip_stroke_text)(void *, fz_text *, fz_stroke_state *, fz_matrix); + void (*ignore_text)(void *, fz_text *, fz_matrix); - void (*fillshade)(void *, fz_shade *shd, fz_matrix ctm, float alpha); - void (*fillimage)(void *, fz_pixmap *img, fz_matrix ctm, float alpha); - void (*fillimagemask)(void *, fz_pixmap *img, fz_matrix ctm, fz_colorspace *, float *color, float alpha); - void (*clipimagemask)(void *, fz_pixmap *img, fz_matrix ctm); + void (*fill_shade)(void *, fz_shade *shd, fz_matrix ctm, float alpha); + void (*fill_image)(void *, fz_pixmap *img, fz_matrix ctm, float alpha); + void (*fill_image_mask)(void *, fz_pixmap *img, fz_matrix ctm, fz_colorspace *, float *color, float alpha); + void (*clip_image_mask)(void *, fz_pixmap *img, fz_matrix ctm); - void (*popclip)(void *); + void (*pop_clip)(void *); - void (*beginmask)(void *, fz_rect, int luminosity, fz_colorspace *, float *bc); - void (*endmask)(void *); - void (*begingroup)(void *, fz_rect, int isolated, int knockout, fz_blendmode blendmode, float alpha); - void (*endgroup)(void *); + void (*begin_mask)(void *, fz_rect, int luminosity, fz_colorspace *, float *bc); + void (*end_mask)(void *); + void (*begin_group)(void *, fz_rect, int isolated, int knockout, fz_blendmode blendmode, float alpha); + void (*end_group)(void *); - void (*begintile)(void *, fz_rect area, fz_rect view, float xstep, float ystep, fz_matrix ctm); - void (*endtile)(void *); + void (*begin_tile)(void *, fz_rect area, fz_rect view, float xstep, float ystep, fz_matrix ctm); + void (*end_tile)(void *); }; -fz_device *fz_newdevice(void *user); -void fz_freedevice(fz_device *dev); +fz_device *fz_new_device(void *user); +void fz_free_device(fz_device *dev); -fz_device *fz_newtracedevice(void); +fz_device *fz_new_trace_device(void); -fz_device *fz_newbboxdevice(fz_bbox *bboxp); +fz_device *fz_new_bbox_device(fz_bbox *bboxp); -fz_device *fz_newdrawdevice(fz_glyphcache *cache, fz_pixmap *dest); +fz_device *fz_new_draw_device(fz_glyph_cache *cache, fz_pixmap *dest); /* * Text extraction device */ -typedef struct fz_textspan_s fz_textspan; -typedef struct fz_textchar_s fz_textchar; +typedef struct fz_text_span_s fz_text_span; +typedef struct fz_text_char_s fz_text_char; -struct fz_textchar_s +struct fz_text_char_s { int c; fz_bbox bbox; }; -struct fz_textspan_s +struct fz_text_span_s { fz_font *font; float size; int wmode; int len, cap; - fz_textchar *text; - fz_textspan *next; + fz_text_char *text; + fz_text_span *next; int eol; }; -fz_textspan *fz_newtextspan(void); -void fz_freetextspan(fz_textspan *line); -void fz_debugtextspan(fz_textspan *line); -void fz_debugtextspanxml(fz_textspan *span); +fz_text_span *fz_new_text_span(void); +void fz_free_text_span(fz_text_span *line); +void fz_debug_text_span(fz_text_span *line); +void fz_debug_text_span_xml(fz_text_span *span); -fz_device *fz_newtextdevice(fz_textspan *text); +fz_device *fz_new_text_device(fz_text_span *text); /* * Display list device -- record and play back device commands. */ -typedef struct fz_displaylist_s fz_displaylist; -typedef struct fz_displaynode_s fz_displaynode; +typedef struct fz_display_list_s fz_display_list; +typedef struct fz_display_node_s fz_display_node; -typedef enum fz_displaycommand_e +typedef enum fz_display_command_e { - FZ_CMDFILLPATH, - FZ_CMDSTROKEPATH, - FZ_CMDCLIPPATH, - FZ_CMDCLIPSTROKEPATH, - FZ_CMDFILLTEXT, - FZ_CMDSTROKETEXT, - FZ_CMDCLIPTEXT, - FZ_CMDCLIPSTROKETEXT, - FZ_CMDIGNORETEXT, - FZ_CMDFILLSHADE, - FZ_CMDFILLIMAGE, - FZ_CMDFILLIMAGEMASK, - FZ_CMDCLIPIMAGEMASK, - FZ_CMDPOPCLIP, - FZ_CMDBEGINMASK, - FZ_CMDENDMASK, - FZ_CMDBEGINGROUP, - FZ_CMDENDGROUP, - FZ_CMDBEGINTILE, - FZ_CMDENDTILE -} fz_displaycommand; - -struct fz_displaynode_s + FZ_CMD_FILL_PATH, + FZ_CMD_STROKE_PATH, + FZ_CMD_CLIP_PATH, + FZ_CMD_CLIP_STROKE_PATH, + FZ_CMD_FILL_TEXT, + FZ_CMD_STROKE_TEXT, + FZ_CMD_CLIP_TEXT, + FZ_CMD_CLIP_STROKE_TEXT, + FZ_CMD_IGNORE_TEXT, + FZ_CMD_FILL_SHADE, + FZ_CMD_FILL_IMAGE, + FZ_CMD_FILL_IMAGE_MASK, + FZ_CMD_CLIP_IMAGE_MASK, + FZ_CMD_POP_CLIP, + FZ_CMD_BEGIN_MASK, + FZ_CMD_END_MASK, + FZ_CMD_BEGIN_GROUP, + FZ_CMD_END_GROUP, + FZ_CMD_BEGIN_TILE, + FZ_CMD_END_TILE +} fz_display_command; + +struct fz_display_node_s { - fz_displaycommand cmd; - fz_displaynode *next; + fz_display_command cmd; + fz_display_node *next; fz_rect rect; union { fz_path *path; @@ -1113,93 +1111,46 @@ struct fz_displaynode_s fz_pixmap *image; fz_blendmode blendmode; } item; - fz_strokestate *stroke; - int flag; /* evenodd, accumulate, isolated/knockout... */ + fz_stroke_state *stroke; + int flag; /* even_odd, accumulate, isolated/knockout... */ fz_matrix ctm; fz_colorspace *colorspace; float alpha; - float color[FZ_MAXCOLORS]; + float color[FZ_MAX_COLORS]; }; -struct fz_displaylist_s +struct fz_display_list_s { - fz_displaynode *first; - fz_displaynode *last; + fz_display_node *first; + fz_display_node *last; }; -fz_displaylist *fz_newdisplaylist(void); -void fz_freedisplaylist(fz_displaylist *list); -fz_device *fz_newlistdevice(fz_displaylist *list); -void fz_executedisplaylist(fz_displaylist *list, fz_device *dev, fz_matrix ctm, fz_bbox area); +fz_display_list *fz_new_display_list(void); +void fz_free_display_list(fz_display_list *list); +fz_device *fz_new_list_device(fz_display_list *list); +void fz_execute_display_list(fz_display_list *list, fz_device *dev, fz_matrix ctm, fz_bbox area); /* - * Function pointers for plotting functions. - * They can be replaced by cpu-optimized versions. + * Plotting functions. */ -/* -These are the blending primitives: - -span over span (text and path drawing to clip mask) -span in alpha over span -span in span over span -color in span over span (text and path drawing) - - fz_paintspan(dp, sp); - fz_paintspanalpha(dp, sp, alpha) - fz_paintspanmask(dp, sp, mask); - fz_paintspancolor(dp, color, mask); - -pixmap over pixmap (shading with function lookup) -pixmap in alpha over pixmap (xobject/shading with ca) -pixmap in pixmap over pixmap (xobject with softmask / clip) - - fz_paintpixmap() - fz_paintpixmapalpha() - fz_paintpixmapmask() - -affine over span -affine in alpha over span -color in affine over span - - fz_paintaffine() - fz_paintaffinealpha() - fz_paintaffinecolor() - -image over pixmap (image fill) -image in alpha over pixmap (image fill with ca) -color in image over pixmap (image mask fill) - - fz_paintimage() - fz_paintimagealpha() - fz_paintimagecolor() - -pixmap BLEND pixmap -pixmap in alpha BLEND pixmap - - fz_blendpixmap() - fz_blendpixmapalpha() -*/ - void fz_accelerate(void); -void fz_acceleratearch(void); - -void fz_decodetile(fz_pixmap *pix, float *decode); -void fz_decodeindexedtile(fz_pixmap *pix, float *decode, int maxval); -void fz_unpacktile(fz_pixmap *dst, unsigned char * restrict src, int n, int depth, int stride, int scale); +void fz_accelerate_arch(void); -void fz_paintspan(unsigned char * restrict dp, unsigned char * restrict sp, int n, int w, int alpha); -void fz_paintspancolor(unsigned char * restrict dp, unsigned char * restrict mp, int n, int w, unsigned char *color); +void fz_decode_tile(fz_pixmap *pix, float *decode); +void fz_decode_indexed_tile(fz_pixmap *pix, float *decode, int maxval); +void fz_unpack_tile(fz_pixmap *dst, unsigned char * restrict src, int n, int depth, int stride, int scale); -void fz_paintaffinecolor(unsigned char *dp, unsigned char *sp, int sw, int sh, int u, int v, int fa, int fb, int w, int n, unsigned char *color); +void fz_paint_span(unsigned char * restrict dp, unsigned char * restrict sp, int n, int w, int alpha); +void fz_paint_span_with_color(unsigned char * restrict dp, unsigned char * restrict mp, int n, int w, unsigned char *color); -void fz_paintimage(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *img, fz_matrix ctm, int alpha); -void fz_paintimagecolor(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *img, fz_matrix ctm, unsigned char *colorbv); +void fz_paint_image(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *img, fz_matrix ctm, int alpha); +void fz_paint_image_with_color(fz_pixmap *dst, fz_bbox scissor, fz_pixmap *img, fz_matrix ctm, unsigned char *colorbv); -void fz_paintpixmap(fz_pixmap *dst, fz_pixmap *src, int alpha); -void fz_paintpixmapmask(fz_pixmap *dst, fz_pixmap *src, fz_pixmap *msk); -void fz_paintpixmapbbox(fz_pixmap *dst, fz_pixmap *src, int alpha, fz_bbox bbox); +void fz_paint_pixmap(fz_pixmap *dst, fz_pixmap *src, int alpha); +void fz_paint_pixmap_with_mask(fz_pixmap *dst, fz_pixmap *src, fz_pixmap *msk); +void fz_paint_pixmap_with_rect(fz_pixmap *dst, fz_pixmap *src, int alpha, fz_bbox bbox); -void fz_blendpixmap(fz_pixmap *dst, fz_pixmap *src, int alpha, fz_blendmode blendmode); +void fz_blend_pixmap(fz_pixmap *dst, fz_pixmap *src, int alpha, fz_blendmode blendmode); #endif diff --git a/fitz/obj_array.c b/fitz/obj_array.c index 391c1dd8..d6ffb687 100644 --- a/fitz/obj_array.c +++ b/fitz/obj_array.c @@ -1,7 +1,7 @@ #include "fitz.h" fz_obj * -fz_newarray(int initialcap) +fz_new_array(int initialcap) { fz_obj *obj; int i; @@ -15,56 +15,56 @@ fz_newarray(int initialcap) obj->u.a.items = fz_calloc(obj->u.a.cap, sizeof(fz_obj*)); for (i = 0; i < obj->u.a.cap; i++) - obj->u.a.items[i] = nil; + obj->u.a.items[i] = NULL; return obj; } fz_obj * -fz_copyarray(fz_obj *obj) +fz_copy_array(fz_obj *obj) { fz_obj *new; int i; - if (fz_isindirect(obj) || !fz_isarray(obj)) + if (fz_is_indirect(obj) || !fz_is_array(obj)) fz_warn("assert: not an array (%s)", fz_objkindstr(obj)); - new = fz_newarray(fz_arraylen(obj)); - for (i = 0; i < fz_arraylen(obj); i++) - fz_arraypush(new, fz_arrayget(obj, i)); + new = fz_new_array(fz_array_len(obj)); + for (i = 0; i < fz_array_len(obj); i++) + fz_array_push(new, fz_array_get(obj, i)); return new; } int -fz_arraylen(fz_obj *obj) +fz_array_len(fz_obj *obj) { - obj = fz_resolveindirect(obj); - if (!fz_isarray(obj)) + obj = fz_resolve_indirect(obj); + if (!fz_is_array(obj)) return 0; return obj->u.a.len; } fz_obj * -fz_arrayget(fz_obj *obj, int i) +fz_array_get(fz_obj *obj, int i) { - obj = fz_resolveindirect(obj); + obj = fz_resolve_indirect(obj); - if (!fz_isarray(obj)) - return nil; + if (!fz_is_array(obj)) + return NULL; if (i < 0 || i >= obj->u.a.len) - return nil; + return NULL; return obj->u.a.items[i]; } void -fz_arrayput(fz_obj *obj, int i, fz_obj *item) +fz_array_put(fz_obj *obj, int i, fz_obj *item) { - obj = fz_resolveindirect(obj); + obj = fz_resolve_indirect(obj); - if (!fz_isarray(obj)) + if (!fz_is_array(obj)) fz_warn("assert: not an array (%s)", fz_objkindstr(obj)); else if (i < 0) fz_warn("assert: index %d < 0", i); @@ -73,17 +73,17 @@ fz_arrayput(fz_obj *obj, int i, fz_obj *item) else { if (obj->u.a.items[i]) - fz_dropobj(obj->u.a.items[i]); - obj->u.a.items[i] = fz_keepobj(item); + fz_drop_obj(obj->u.a.items[i]); + obj->u.a.items[i] = fz_keep_obj(item); } } void -fz_arraypush(fz_obj *obj, fz_obj *item) +fz_array_push(fz_obj *obj, fz_obj *item) { - obj = fz_resolveindirect(obj); + obj = fz_resolve_indirect(obj); - if (!fz_isarray(obj)) + if (!fz_is_array(obj)) fz_warn("assert: not an array (%s)", fz_objkindstr(obj)); else { @@ -93,35 +93,35 @@ fz_arraypush(fz_obj *obj, fz_obj *item) obj->u.a.cap = (obj->u.a.cap * 3) / 2; obj->u.a.items = fz_realloc(obj->u.a.items, obj->u.a.cap, sizeof(fz_obj*)); for (i = obj->u.a.len ; i < obj->u.a.cap; i++) - obj->u.a.items[i] = nil; + obj->u.a.items[i] = NULL; } - obj->u.a.items[obj->u.a.len] = fz_keepobj(item); + obj->u.a.items[obj->u.a.len] = fz_keep_obj(item); obj->u.a.len++; } } void -fz_arraydrop(fz_obj *obj) +fz_array_drop(fz_obj *obj) { - obj = fz_resolveindirect(obj); + obj = fz_resolve_indirect(obj); - if (!fz_isarray(obj)) + if (!fz_is_array(obj)) fz_warn("assert: not an array (%s)", fz_objkindstr(obj)); else { if (obj->u.a.len > 0) { - fz_dropobj(obj->u.a.items[--obj->u.a.len]); + fz_drop_obj(obj->u.a.items[--obj->u.a.len]); } } } void -fz_arrayinsert(fz_obj *obj, fz_obj *item) +fz_array_insert(fz_obj *obj, fz_obj *item) { - obj = fz_resolveindirect(obj); + obj = fz_resolve_indirect(obj); - if (!fz_isarray(obj)) + if (!fz_is_array(obj)) fz_warn("assert: not an array (%s)", fz_objkindstr(obj)); else { @@ -131,16 +131,16 @@ fz_arrayinsert(fz_obj *obj, fz_obj *item) obj->u.a.cap = (obj->u.a.cap * 3) / 2; obj->u.a.items = fz_realloc(obj->u.a.items, obj->u.a.cap, sizeof(fz_obj*)); for (i = obj->u.a.len ; i < obj->u.a.cap; i++) - obj->u.a.items[i] = nil; + obj->u.a.items[i] = NULL; } memmove(obj->u.a.items + 1, obj->u.a.items, obj->u.a.len * sizeof(fz_obj*)); - obj->u.a.items[0] = fz_keepobj(item); + obj->u.a.items[0] = fz_keep_obj(item); obj->u.a.len++; } } void -fz_freearray(fz_obj *obj) +fz_free_array(fz_obj *obj) { int i; @@ -148,7 +148,7 @@ fz_freearray(fz_obj *obj) for (i = 0; i < obj->u.a.len; i++) if (obj->u.a.items[i]) - fz_dropobj(obj->u.a.items[i]); + fz_drop_obj(obj->u.a.items[i]); fz_free(obj->u.a.items); fz_free(obj); diff --git a/fitz/obj_dict.c b/fitz/obj_dict.c index d1cc22cc..6f3ba9da 100644 --- a/fitz/obj_dict.c +++ b/fitz/obj_dict.c @@ -6,20 +6,20 @@ static int keyvalcmp(const void *ap, const void *bp) { const fz_keyval *a = ap; const fz_keyval *b = bp; - if (fz_isname(a->k) && fz_isname(b->k)) - return strcmp(fz_toname(a->k), fz_toname(b->k)); + if (fz_is_name(a->k) && fz_is_name(b->k)) + return strcmp(fz_to_name(a->k), fz_to_name(b->k)); return -1; } static inline int keystrcmp(fz_obj *key, char *s) { - if (fz_isname(key)) - return strcmp(fz_toname(key), s); + if (fz_is_name(key)) + return strcmp(fz_to_name(key), s); return -1; } fz_obj * -fz_newdict(int initialcap) +fz_new_dict(int initialcap) { fz_obj *obj; int i; @@ -35,68 +35,68 @@ fz_newdict(int initialcap) obj->u.d.items = fz_calloc(obj->u.d.cap, sizeof(fz_keyval)); for (i = 0; i < obj->u.d.cap; i++) { - obj->u.d.items[i].k = nil; - obj->u.d.items[i].v = nil; + obj->u.d.items[i].k = NULL; + obj->u.d.items[i].v = NULL; } return obj; } fz_obj * -fz_copydict(fz_obj *obj) +fz_copy_dict(fz_obj *obj) { fz_obj *new; int i; - if (fz_isindirect(obj) || !fz_isdict(obj)) + if (fz_is_indirect(obj) || !fz_is_dict(obj)) fz_throw("assert: not a dict (%s)", fz_objkindstr(obj)); - new = fz_newdict(fz_dictlen(obj)); - for (i = 0; i < fz_dictlen(obj); i++) - fz_dictput(new, fz_dictgetkey(obj, i), fz_dictgetval(obj, i)); + new = fz_new_dict(fz_dict_len(obj)); + for (i = 0; i < fz_dict_len(obj); i++) + fz_dict_put(new, fz_dict_get_key(obj, i), fz_dict_get_val(obj, i)); return new; } int -fz_dictlen(fz_obj *obj) +fz_dict_len(fz_obj *obj) { - obj = fz_resolveindirect(obj); - if (!fz_isdict(obj)) + obj = fz_resolve_indirect(obj); + if (!fz_is_dict(obj)) return 0; return obj->u.d.len; } fz_obj * -fz_dictgetkey(fz_obj *obj, int i) +fz_dict_get_key(fz_obj *obj, int i) { - obj = fz_resolveindirect(obj); + obj = fz_resolve_indirect(obj); - if (!fz_isdict(obj)) - return nil; + if (!fz_is_dict(obj)) + return NULL; if (i < 0 || i >= obj->u.d.len) - return nil; + return NULL; return obj->u.d.items[i].k; } fz_obj * -fz_dictgetval(fz_obj *obj, int i) +fz_dict_get_val(fz_obj *obj, int i) { - obj = fz_resolveindirect(obj); + obj = fz_resolve_indirect(obj); - if (!fz_isdict(obj)) - return nil; + if (!fz_is_dict(obj)) + return NULL; if (i < 0 || i >= obj->u.d.len) - return nil; + return NULL; return obj->u.d.items[i].v; } static inline int -fz_dictfinds(fz_obj *obj, char *key) +fz_dict_finds(fz_obj *obj, char *key) { if (obj->u.d.sorted) { @@ -127,56 +127,56 @@ fz_dictfinds(fz_obj *obj, char *key) } fz_obj * -fz_dictgets(fz_obj *obj, char *key) +fz_dict_gets(fz_obj *obj, char *key) { int i; - obj = fz_resolveindirect(obj); + obj = fz_resolve_indirect(obj); - if (!fz_isdict(obj)) - return nil; + if (!fz_is_dict(obj)) + return NULL; - i = fz_dictfinds(obj, key); + i = fz_dict_finds(obj, key); if (i >= 0) return obj->u.d.items[i].v; - return nil; + return NULL; } fz_obj * -fz_dictget(fz_obj *obj, fz_obj *key) +fz_dict_get(fz_obj *obj, fz_obj *key) { - if (fz_isname(key)) - return fz_dictgets(obj, fz_toname(key)); - return nil; + if (fz_is_name(key)) + return fz_dict_gets(obj, fz_to_name(key)); + return NULL; } fz_obj * -fz_dictgetsa(fz_obj *obj, char *key, char *abbrev) +fz_dict_getsa(fz_obj *obj, char *key, char *abbrev) { fz_obj *v; - v = fz_dictgets(obj, key); + v = fz_dict_gets(obj, key); if (v) return v; - return fz_dictgets(obj, abbrev); + return fz_dict_gets(obj, abbrev); } void -fz_dictput(fz_obj *obj, fz_obj *key, fz_obj *val) +fz_dict_put(fz_obj *obj, fz_obj *key, fz_obj *val) { char *s; int i; - obj = fz_resolveindirect(obj); + obj = fz_resolve_indirect(obj); - if (!fz_isdict(obj)) + if (!fz_is_dict(obj)) { fz_warn("assert: not a dict (%s)", fz_objkindstr(obj)); return; } - if (fz_isname(key)) - s = fz_toname(key); + if (fz_is_name(key)) + s = fz_to_name(key); else { fz_warn("assert: key is not a name (%s)", fz_objkindstr(obj)); @@ -189,11 +189,11 @@ fz_dictput(fz_obj *obj, fz_obj *key, fz_obj *val) return; } - i = fz_dictfinds(obj, s); + i = fz_dict_finds(obj, s); if (i >= 0) { - fz_dropobj(obj->u.d.items[i].v); - obj->u.d.items[i].v = fz_keepobj(val); + fz_drop_obj(obj->u.d.items[i].v); + obj->u.d.items[i].v = fz_keep_obj(val); return; } @@ -203,8 +203,8 @@ fz_dictput(fz_obj *obj, fz_obj *key, fz_obj *val) obj->u.d.items = fz_realloc(obj->u.d.items, obj->u.d.cap, sizeof(fz_keyval)); for (i = obj->u.d.len; i < obj->u.d.cap; i++) { - obj->u.d.items[i].k = nil; - obj->u.d.items[i].v = nil; + obj->u.d.items[i].k = NULL; + obj->u.d.items[i].v = NULL; } } @@ -213,33 +213,33 @@ fz_dictput(fz_obj *obj, fz_obj *key, fz_obj *val) if (keystrcmp(obj->u.d.items[obj->u.d.len - 1].k, s) > 0) obj->u.d.sorted = 0; - obj->u.d.items[obj->u.d.len].k = fz_keepobj(key); - obj->u.d.items[obj->u.d.len].v = fz_keepobj(val); + obj->u.d.items[obj->u.d.len].k = fz_keep_obj(key); + obj->u.d.items[obj->u.d.len].v = fz_keep_obj(val); obj->u.d.len ++; } void -fz_dictputs(fz_obj *obj, char *key, fz_obj *val) +fz_dict_puts(fz_obj *obj, char *key, fz_obj *val) { - fz_obj *keyobj = fz_newname(key); - fz_dictput(obj, keyobj, val); - fz_dropobj(keyobj); + fz_obj *keyobj = fz_new_name(key); + fz_dict_put(obj, keyobj, val); + fz_drop_obj(keyobj); } void -fz_dictdels(fz_obj *obj, char *key) +fz_dict_dels(fz_obj *obj, char *key) { - obj = fz_resolveindirect(obj); + obj = fz_resolve_indirect(obj); - if (!fz_isdict(obj)) + if (!fz_is_dict(obj)) fz_warn("assert: not a dict (%s)", fz_objkindstr(obj)); else { - int i = fz_dictfinds(obj, key); + int i = fz_dict_finds(obj, key); if (i >= 0) { - fz_dropobj(obj->u.d.items[i].k); - fz_dropobj(obj->u.d.items[i].v); + fz_drop_obj(obj->u.d.items[i].k); + fz_drop_obj(obj->u.d.items[i].v); obj->u.d.sorted = 0; obj->u.d.items[i] = obj->u.d.items[obj->u.d.len-1]; obj->u.d.len --; @@ -248,29 +248,29 @@ fz_dictdels(fz_obj *obj, char *key) } void -fz_dictdel(fz_obj *obj, fz_obj *key) +fz_dict_del(fz_obj *obj, fz_obj *key) { - if (fz_isname(key)) - fz_dictdels(obj, fz_toname(key)); + if (fz_is_name(key)) + fz_dict_dels(obj, fz_to_name(key)); else fz_warn("assert: key is not a name (%s)", fz_objkindstr(obj)); } void -fz_freedict(fz_obj *obj) +fz_free_dict(fz_obj *obj) { int i; - obj = fz_resolveindirect(obj); + obj = fz_resolve_indirect(obj); - if (!fz_isdict(obj)) + if (!fz_is_dict(obj)) return; for (i = 0; i < obj->u.d.len; i++) { if (obj->u.d.items[i].k) - fz_dropobj(obj->u.d.items[i].k); + fz_drop_obj(obj->u.d.items[i].k); if (obj->u.d.items[i].v) - fz_dropobj(obj->u.d.items[i].v); + fz_drop_obj(obj->u.d.items[i].v); } fz_free(obj->u.d.items); @@ -278,10 +278,10 @@ fz_freedict(fz_obj *obj) } void -fz_sortdict(fz_obj *obj) +fz_sort_dict(fz_obj *obj) { - obj = fz_resolveindirect(obj); - if (!fz_isdict(obj)) + obj = fz_resolve_indirect(obj); + if (!fz_is_dict(obj)) return; if (!obj->u.d.sorted) { diff --git a/fitz/obj_print.c b/fitz/obj_print.c index 4233b80f..3433903c 100644 --- a/fitz/obj_print.c +++ b/fitz/obj_print.c @@ -12,7 +12,7 @@ struct fmt int last; }; -static void fmtobj(struct fmt *fmt, fz_obj *obj); +static void fmt_obj(struct fmt *fmt, fz_obj *obj); static inline int iswhite(int ch) { @@ -35,11 +35,11 @@ static inline int isdelim(int ch) ch == '%'; } -static inline void fmtputc(struct fmt *fmt, int c) +static inline void fmt_putc(struct fmt *fmt, int c) { if (fmt->sep && !isdelim(fmt->last) && !isdelim(c)) { fmt->sep = 0; - fmtputc(fmt, ' '); + fmt_putc(fmt, ' '); } fmt->sep = 0; @@ -56,195 +56,195 @@ static inline void fmtputc(struct fmt *fmt, int c) fmt->last = c; } -static inline void fmtindent(struct fmt *fmt) +static inline void fmt_indent(struct fmt *fmt) { int i = fmt->indent; while (i--) { - fmtputc(fmt, ' '); - fmtputc(fmt, ' '); + fmt_putc(fmt, ' '); + fmt_putc(fmt, ' '); } } -static inline void fmtputs(struct fmt *fmt, char *s) +static inline void fmt_puts(struct fmt *fmt, char *s) { while (*s) - fmtputc(fmt, *s++); + fmt_putc(fmt, *s++); } -static inline void fmtsep(struct fmt *fmt) +static inline void fmt_sep(struct fmt *fmt) { fmt->sep = 1; } -static void fmtstr(struct fmt *fmt, fz_obj *obj) +static void fmt_str(struct fmt *fmt, fz_obj *obj) { int i, c; - fmtputc(fmt, '('); + fmt_putc(fmt, '('); for (i = 0; i < obj->u.s.len; i++) { c = (unsigned char) obj->u.s.buf[i]; if (c == '\n') - fmtputs(fmt, "\\n"); + fmt_puts(fmt, "\\n"); else if (c == '\r') - fmtputs(fmt, "\\r"); + fmt_puts(fmt, "\\r"); else if (c == '\t') - fmtputs(fmt, "\\t"); + fmt_puts(fmt, "\\t"); else if (c == '\b') - fmtputs(fmt, "\\b"); + fmt_puts(fmt, "\\b"); else if (c == '\f') - fmtputs(fmt, "\\f"); + fmt_puts(fmt, "\\f"); else if (c == '(') - fmtputs(fmt, "\\("); + fmt_puts(fmt, "\\("); else if (c == ')') - fmtputs(fmt, "\\)"); + fmt_puts(fmt, "\\)"); else if (c < 32 || c > 126) { char buf[16]; - fmtputc(fmt, '\\'); + fmt_putc(fmt, '\\'); sprintf(buf, "%o", c); - fmtputs(fmt, buf); + fmt_puts(fmt, buf); } else - fmtputc(fmt, c); + fmt_putc(fmt, c); } - fmtputc(fmt, ')'); + fmt_putc(fmt, ')'); } -static void fmthex(struct fmt *fmt, fz_obj *obj) +static void fmt_hex(struct fmt *fmt, fz_obj *obj) { int i, b, c; - fmtputc(fmt, '<'); + fmt_putc(fmt, '<'); for (i = 0; i < obj->u.s.len; i++) { b = (unsigned char) obj->u.s.buf[i]; c = (b >> 4) & 0x0f; - fmtputc(fmt, c < 0xA ? c + '0' : c + 'A' - 0xA); + fmt_putc(fmt, c < 0xA ? c + '0' : c + 'A' - 0xA); c = (b) & 0x0f; - fmtputc(fmt, c < 0xA ? c + '0' : c + 'A' - 0xA); + fmt_putc(fmt, c < 0xA ? c + '0' : c + 'A' - 0xA); } - fmtputc(fmt, '>'); + fmt_putc(fmt, '>'); } -static void fmtname(struct fmt *fmt, fz_obj *obj) +static void fmt_name(struct fmt *fmt, fz_obj *obj) { - unsigned char *s = (unsigned char *) fz_toname(obj); + unsigned char *s = (unsigned char *) fz_to_name(obj); int i, c; - fmtputc(fmt, '/'); + fmt_putc(fmt, '/'); for (i = 0; s[i]; i++) { if (isdelim(s[i]) || iswhite(s[i]) || s[i] == '#' || s[i] < 32 || s[i] > 127) { - fmtputc(fmt, '#'); + fmt_putc(fmt, '#'); c = (s[i] >> 4) & 0xf; - fmtputc(fmt, c < 0xA ? c + '0' : c + 'A' - 0xA); + fmt_putc(fmt, c < 0xA ? c + '0' : c + 'A' - 0xA); c = s[i] & 0xf; - fmtputc(fmt, c < 0xA ? c + '0' : c + 'A' - 0xA); + fmt_putc(fmt, c < 0xA ? c + '0' : c + 'A' - 0xA); } else { - fmtputc(fmt, s[i]); + fmt_putc(fmt, s[i]); } } } -static void fmtarray(struct fmt *fmt, fz_obj *obj) +static void fmt_array(struct fmt *fmt, fz_obj *obj) { int i; if (fmt->tight) { - fmtputc(fmt, '['); - for (i = 0; i < fz_arraylen(obj); i++) { - fmtobj(fmt, fz_arrayget(obj, i)); - fmtsep(fmt); + fmt_putc(fmt, '['); + for (i = 0; i < fz_array_len(obj); i++) { + fmt_obj(fmt, fz_array_get(obj, i)); + fmt_sep(fmt); } - fmtputc(fmt, ']'); + fmt_putc(fmt, ']'); } else { - fmtputs(fmt, "[ "); - for (i = 0; i < fz_arraylen(obj); i++) { + fmt_puts(fmt, "[ "); + for (i = 0; i < fz_array_len(obj); i++) { if (fmt->col > 60) { - fmtputc(fmt, '\n'); - fmtindent(fmt); + fmt_putc(fmt, '\n'); + fmt_indent(fmt); } - fmtobj(fmt, fz_arrayget(obj, i)); - fmtputc(fmt, ' '); + fmt_obj(fmt, fz_array_get(obj, i)); + fmt_putc(fmt, ' '); } - fmtputc(fmt, ']'); - fmtsep(fmt); + fmt_putc(fmt, ']'); + fmt_sep(fmt); } } -static void fmtdict(struct fmt *fmt, fz_obj *obj) +static void fmt_dict(struct fmt *fmt, fz_obj *obj) { int i; fz_obj *key, *val; if (fmt->tight) { - fmtputs(fmt, "<<"); - for (i = 0; i < fz_dictlen(obj); i++) { - fmtobj(fmt, fz_dictgetkey(obj, i)); - fmtsep(fmt); - fmtobj(fmt, fz_dictgetval(obj, i)); - fmtsep(fmt); + fmt_puts(fmt, "<<"); + for (i = 0; i < fz_dict_len(obj); i++) { + fmt_obj(fmt, fz_dict_get_key(obj, i)); + fmt_sep(fmt); + fmt_obj(fmt, fz_dict_get_val(obj, i)); + fmt_sep(fmt); } - fmtputs(fmt, ">>"); + fmt_puts(fmt, ">>"); } else { - fmtputs(fmt, "<<\n"); + fmt_puts(fmt, "<<\n"); fmt->indent ++; - for (i = 0; i < fz_dictlen(obj); i++) { - key = fz_dictgetkey(obj, i); - val = fz_dictgetval(obj, i); - fmtindent(fmt); - fmtobj(fmt, key); - fmtputc(fmt, ' '); - if (!fz_isindirect(val) && fz_isarray(val)) + for (i = 0; i < fz_dict_len(obj); i++) { + key = fz_dict_get_key(obj, i); + val = fz_dict_get_val(obj, i); + fmt_indent(fmt); + fmt_obj(fmt, key); + fmt_putc(fmt, ' '); + if (!fz_is_indirect(val) && fz_is_array(val)) fmt->indent ++; - fmtobj(fmt, val); - fmtputc(fmt, '\n'); - if (!fz_isindirect(val) && fz_isarray(val)) + fmt_obj(fmt, val); + fmt_putc(fmt, '\n'); + if (!fz_is_indirect(val) && fz_is_array(val)) fmt->indent --; } fmt->indent --; - fmtindent(fmt); - fmtputs(fmt, ">>"); + fmt_indent(fmt); + fmt_puts(fmt, ">>"); } } -static void fmtobj(struct fmt *fmt, fz_obj *obj) +static void fmt_obj(struct fmt *fmt, fz_obj *obj) { char buf[256]; if (!obj) - fmtputs(fmt, ""); - else if (fz_isindirect(obj)) + fmt_puts(fmt, ""); + else if (fz_is_indirect(obj)) { - sprintf(buf, "%d %d R", fz_tonum(obj), fz_togen(obj)); - fmtputs(fmt, buf); + sprintf(buf, "%d %d R", fz_to_num(obj), fz_to_gen(obj)); + fmt_puts(fmt, buf); } - else if (fz_isnull(obj)) - fmtputs(fmt, "null"); - else if (fz_isbool(obj)) - fmtputs(fmt, fz_tobool(obj) ? "true" : "false"); - else if (fz_isint(obj)) + else if (fz_is_null(obj)) + fmt_puts(fmt, "null"); + else if (fz_is_bool(obj)) + fmt_puts(fmt, fz_to_bool(obj) ? "true" : "false"); + else if (fz_is_int(obj)) { - sprintf(buf, "%d", fz_toint(obj)); - fmtputs(fmt, buf); + sprintf(buf, "%d", fz_to_int(obj)); + fmt_puts(fmt, buf); } - else if (fz_isreal(obj)) + else if (fz_is_real(obj)) { - sprintf(buf, "%g", fz_toreal(obj)); + sprintf(buf, "%g", fz_to_real(obj)); if (strchr(buf, 'e')) /* bad news! */ - sprintf(buf, fabsf(fz_toreal(obj)) > 1 ? "%1.1f" : "%1.8f", fz_toreal(obj)); - fmtputs(fmt, buf); + sprintf(buf, fabsf(fz_to_real(obj)) > 1 ? "%1.1f" : "%1.8f", fz_to_real(obj)); + fmt_puts(fmt, buf); } - else if (fz_isstring(obj)) + else if (fz_is_string(obj)) { - char *str = fz_tostrbuf(obj); - int len = fz_tostrlen(obj); + char *str = fz_to_str_buf(obj); + int len = fz_to_str_len(obj); int added = 0; int i, c; for (i = 0; i < len; i++) { @@ -259,22 +259,22 @@ static void fmtobj(struct fmt *fmt, fz_obj *obj) added += 3; } if (added < obj->u.s.len) - fmtstr(fmt, obj); + fmt_str(fmt, obj); else - fmthex(fmt, obj); + fmt_hex(fmt, obj); } - else if (fz_isname(obj)) - fmtname(fmt, obj); - else if (fz_isarray(obj)) - fmtarray(fmt, obj); - else if (fz_isdict(obj)) - fmtdict(fmt, obj); + else if (fz_is_name(obj)) + fmt_name(fmt, obj); + else if (fz_is_array(obj)) + fmt_array(fmt, obj); + else if (fz_is_dict(obj)) + fmt_dict(fmt, obj); else - fmtputs(fmt, ""); + fmt_puts(fmt, ""); } static int -fz_sprintobj(char *s, int n, fz_obj *obj, int tight) +fz_sprint_obj(char *s, int n, fz_obj *obj, int tight) { struct fmt fmt; @@ -287,7 +287,7 @@ fz_sprintobj(char *s, int n, fz_obj *obj, int tight) fmt.buf = s; fmt.cap = n; fmt.len = 0; - fmtobj(&fmt, obj); + fmt_obj(&fmt, obj); if (fmt.buf && fmt.len < fmt.cap) fmt.buf[fmt.len] = '\0'; @@ -296,23 +296,23 @@ fz_sprintobj(char *s, int n, fz_obj *obj, int tight) } int -fz_fprintobj(FILE *fp, fz_obj *obj, int tight) +fz_fprint_obj(FILE *fp, fz_obj *obj, int tight) { char buf[1024]; char *ptr; int n; - n = fz_sprintobj(nil, 0, obj, tight); + n = fz_sprint_obj(NULL, 0, obj, tight); if ((n + 1) < sizeof buf) { - fz_sprintobj(buf, sizeof buf, obj, tight); + fz_sprint_obj(buf, sizeof buf, obj, tight); fputs(buf, fp); fputc('\n', fp); } else { ptr = fz_malloc(n + 1); - fz_sprintobj(ptr, n + 1, obj, tight); + fz_sprint_obj(ptr, n + 1, obj, tight); fputs(ptr, fp); fputc('\n', fp); fz_free(ptr); @@ -321,16 +321,15 @@ fz_fprintobj(FILE *fp, fz_obj *obj, int tight) } void -fz_debugobj(fz_obj *obj) +fz_debug_obj(fz_obj *obj) { - fz_fprintobj(stdout, obj, 0); + fz_fprint_obj(stdout, obj, 0); } void -fz_debugref(fz_obj *ref) +fz_debug_ref(fz_obj *ref) { fz_obj *obj; - obj = fz_resolveindirect(ref); - fz_debugobj(obj); + obj = fz_resolve_indirect(ref); + fz_debug_obj(obj); } - diff --git a/fitz/obj_simple.c b/fitz/obj_simple.c index b629974e..2dc9d686 100644 --- a/fitz/obj_simple.c +++ b/fitz/obj_simple.c @@ -1,17 +1,17 @@ #include "fitz.h" -extern void fz_freearray(fz_obj *array); -extern void fz_freedict(fz_obj *dict); +extern void fz_free_array(fz_obj *array); +extern void fz_free_dict(fz_obj *dict); static fz_obj *fz_resolve_indirect_null(fz_obj *ref) { return ref; } -fz_obj* (*fz_resolveindirect)(fz_obj*) = fz_resolve_indirect_null; +fz_obj* (*fz_resolve_indirect)(fz_obj*) = fz_resolve_indirect_null; fz_obj * -fz_newnull(void) +fz_new_null(void) { fz_obj *o = fz_malloc(sizeof(fz_obj)); o->refs = 1; @@ -20,7 +20,7 @@ fz_newnull(void) } fz_obj * -fz_newbool(int b) +fz_new_bool(int b) { fz_obj *o = fz_malloc(sizeof(fz_obj)); o->refs = 1; @@ -30,7 +30,7 @@ fz_newbool(int b) } fz_obj * -fz_newint(int i) +fz_new_int(int i) { fz_obj *o = fz_malloc(sizeof(fz_obj)); o->refs = 1; @@ -40,7 +40,7 @@ fz_newint(int i) } fz_obj * -fz_newreal(float f) +fz_new_real(float f) { fz_obj *o = fz_malloc(sizeof(fz_obj)); o->refs = 1; @@ -50,7 +50,7 @@ fz_newreal(float f) } fz_obj * -fz_newstring(char *str, int len) +fz_new_string(char *str, int len) { fz_obj *o = fz_malloc(offsetof(fz_obj, u.s.buf) + len + 1); o->refs = 1; @@ -62,7 +62,7 @@ fz_newstring(char *str, int len) } fz_obj * -fz_newname(char *str) +fz_new_name(char *str) { fz_obj *o = fz_malloc(offsetof(fz_obj, u.n) + strlen(str) + 1); o->refs = 1; @@ -72,7 +72,7 @@ fz_newname(char *str) } fz_obj * -fz_newindirect(int num, int gen, void *xref) +fz_new_indirect(int num, int gen, void *xref) { fz_obj *o = fz_malloc(sizeof(fz_obj)); o->refs = 1; @@ -84,143 +84,143 @@ fz_newindirect(int num, int gen, void *xref) } fz_obj * -fz_keepobj(fz_obj *o) +fz_keep_obj(fz_obj *o) { - assert(o != nil); + assert(o != NULL); o->refs ++; return o; } void -fz_dropobj(fz_obj *o) +fz_drop_obj(fz_obj *o) { - assert(o != nil); + assert(o != NULL); if (--o->refs == 0) { if (o->kind == FZ_ARRAY) - fz_freearray(o); + fz_free_array(o); else if (o->kind == FZ_DICT) - fz_freedict(o); + fz_free_dict(o); else fz_free(o); } } -int fz_isindirect(fz_obj *obj) +int fz_is_indirect(fz_obj *obj) { return obj ? obj->kind == FZ_INDIRECT : 0; } -int fz_isnull(fz_obj *obj) +int fz_is_null(fz_obj *obj) { - obj = fz_resolveindirect(obj); + obj = fz_resolve_indirect(obj); return obj ? obj->kind == FZ_NULL : 0; } -int fz_isbool(fz_obj *obj) +int fz_is_bool(fz_obj *obj) { - obj = fz_resolveindirect(obj); + obj = fz_resolve_indirect(obj); return obj ? obj->kind == FZ_BOOL : 0; } -int fz_isint(fz_obj *obj) +int fz_is_int(fz_obj *obj) { - obj = fz_resolveindirect(obj); + obj = fz_resolve_indirect(obj); return obj ? obj->kind == FZ_INT : 0; } -int fz_isreal(fz_obj *obj) +int fz_is_real(fz_obj *obj) { - obj = fz_resolveindirect(obj); + obj = fz_resolve_indirect(obj); return obj ? obj->kind == FZ_REAL : 0; } -int fz_isstring(fz_obj *obj) +int fz_is_string(fz_obj *obj) { - obj = fz_resolveindirect(obj); + obj = fz_resolve_indirect(obj); return obj ? obj->kind == FZ_STRING : 0; } -int fz_isname(fz_obj *obj) +int fz_is_name(fz_obj *obj) { - obj = fz_resolveindirect(obj); + obj = fz_resolve_indirect(obj); return obj ? obj->kind == FZ_NAME : 0; } -int fz_isarray(fz_obj *obj) +int fz_is_array(fz_obj *obj) { - obj = fz_resolveindirect(obj); + obj = fz_resolve_indirect(obj); return obj ? obj->kind == FZ_ARRAY : 0; } -int fz_isdict(fz_obj *obj) +int fz_is_dict(fz_obj *obj) { - obj = fz_resolveindirect(obj); + obj = fz_resolve_indirect(obj); return obj ? obj->kind == FZ_DICT : 0; } -int fz_tobool(fz_obj *obj) +int fz_to_bool(fz_obj *obj) { - obj = fz_resolveindirect(obj); - if (fz_isbool(obj)) + obj = fz_resolve_indirect(obj); + if (fz_is_bool(obj)) return obj->u.b; return 0; } -int fz_toint(fz_obj *obj) +int fz_to_int(fz_obj *obj) { - obj = fz_resolveindirect(obj); - if (fz_isint(obj)) + obj = fz_resolve_indirect(obj); + if (fz_is_int(obj)) return obj->u.i; - if (fz_isreal(obj)) + if (fz_is_real(obj)) return obj->u.f; return 0; } -float fz_toreal(fz_obj *obj) +float fz_to_real(fz_obj *obj) { - obj = fz_resolveindirect(obj); - if (fz_isreal(obj)) + obj = fz_resolve_indirect(obj); + if (fz_is_real(obj)) return obj->u.f; - if (fz_isint(obj)) + if (fz_is_int(obj)) return obj->u.i; return 0; } -char *fz_toname(fz_obj *obj) +char *fz_to_name(fz_obj *obj) { - obj = fz_resolveindirect(obj); - if (fz_isname(obj)) + obj = fz_resolve_indirect(obj); + if (fz_is_name(obj)) return obj->u.n; return ""; } -char *fz_tostrbuf(fz_obj *obj) +char *fz_to_str_buf(fz_obj *obj) { - obj = fz_resolveindirect(obj); - if (fz_isstring(obj)) + obj = fz_resolve_indirect(obj); + if (fz_is_string(obj)) return obj->u.s.buf; return ""; } -int fz_tostrlen(fz_obj *obj) +int fz_to_str_len(fz_obj *obj) { - obj = fz_resolveindirect(obj); - if (fz_isstring(obj)) + obj = fz_resolve_indirect(obj); + if (fz_is_string(obj)) return obj->u.s.len; return 0; } -int fz_tonum(fz_obj *obj) +int fz_to_num(fz_obj *obj) { - if (fz_isindirect(obj)) + if (fz_is_indirect(obj)) return obj->u.r.num; return 0; } -int fz_togen(fz_obj *obj) +int fz_to_gen(fz_obj *obj) { - if (fz_isindirect(obj)) + if (fz_is_indirect(obj)) return obj->u.r.gen; return 0; } @@ -306,8 +306,8 @@ fz_objcmp(fz_obj *a, fz_obj *b) char *fz_objkindstr(fz_obj *obj) { - if (obj == nil) - return ""; + if (obj == NULL) + return ""; switch (obj->kind) { case FZ_NULL: return "null"; diff --git a/fitz/res_colorspace.c b/fitz/res_colorspace.c index 09e6c349..a98d568b 100644 --- a/fitz/res_colorspace.c +++ b/fitz/res_colorspace.c @@ -3,21 +3,21 @@ #define SLOWCMYK fz_colorspace * -fz_newcolorspace(char *name, int n) +fz_new_colorspace(char *name, int n) { fz_colorspace *cs = fz_malloc(sizeof(fz_colorspace)); cs->refs = 1; fz_strlcpy(cs->name, name, sizeof cs->name); cs->n = n; - cs->toxyz = nil; - cs->fromxyz = nil; - cs->freedata = nil; - cs->data = nil; + cs->to_xyz = NULL; + cs->from_xyz = NULL; + cs->free_data = NULL; + cs->data = NULL; return cs; } fz_colorspace * -fz_keepcolorspace(fz_colorspace *cs) +fz_keep_colorspace(fz_colorspace *cs) { if (cs->refs < 0) return cs; @@ -26,28 +26,28 @@ fz_keepcolorspace(fz_colorspace *cs) } void -fz_dropcolorspace(fz_colorspace *cs) +fz_drop_colorspace(fz_colorspace *cs) { if (cs && cs->refs < 0) return; if (cs && --cs->refs == 0) { - if (cs->freedata && cs->data) - cs->freedata(cs); + if (cs->free_data && cs->data) + cs->free_data(cs); fz_free(cs); } } /* Device colorspace definitions */ -static void graytoxyz(fz_colorspace *cs, float *gray, float *xyz) +static void gray_to_xyz(fz_colorspace *cs, float *gray, float *xyz) { xyz[0] = gray[0]; xyz[1] = gray[0]; xyz[2] = gray[0]; } -static void xyztogray(fz_colorspace *cs, float *xyz, float *gray) +static void xyz_to_gray(fz_colorspace *cs, float *xyz, float *gray) { float r = xyz[0]; float g = xyz[1]; @@ -55,35 +55,35 @@ static void xyztogray(fz_colorspace *cs, float *xyz, float *gray) gray[0] = r * 0.3f + g * 0.59f + b * 0.11f; } -static void rgbtoxyz(fz_colorspace *cs, float *rgb, float *xyz) +static void rgb_to_xyz(fz_colorspace *cs, float *rgb, float *xyz) { xyz[0] = rgb[0]; xyz[1] = rgb[1]; xyz[2] = rgb[2]; } -static void xyztorgb(fz_colorspace *cs, float *xyz, float *rgb) +static void xyz_to_rgb(fz_colorspace *cs, float *xyz, float *rgb) { rgb[0] = xyz[0]; rgb[1] = xyz[1]; rgb[2] = xyz[2]; } -static void bgrtoxyz(fz_colorspace *cs, float *bgr, float *xyz) +static void bgr_to_xyz(fz_colorspace *cs, float *bgr, float *xyz) { xyz[0] = bgr[2]; xyz[1] = bgr[1]; xyz[2] = bgr[0]; } -static void xyztobgr(fz_colorspace *cs, float *xyz, float *bgr) +static void xyz_to_bgr(fz_colorspace *cs, float *xyz, float *bgr) { bgr[0] = xyz[2]; bgr[1] = xyz[1]; bgr[2] = xyz[0]; } -static void cmyktoxyz(fz_colorspace *cs, float *cmyk, float *xyz) +static void cmyk_to_xyz(fz_colorspace *cs, float *cmyk, float *xyz) { #ifdef SLOWCMYK /* from poppler */ float c = cmyk[0], m = cmyk[1], y = cmyk[2], k = cmyk[3]; @@ -146,7 +146,7 @@ static void cmyktoxyz(fz_colorspace *cs, float *cmyk, float *xyz) #endif } -static void xyztocmyk(fz_colorspace *cs, float *xyz, float *cmyk) +static void xyz_to_cmyk(fz_colorspace *cs, float *xyz, float *cmyk) { float c, m, y, k; c = 1 - xyz[0]; @@ -159,19 +159,19 @@ static void xyztocmyk(fz_colorspace *cs, float *xyz, float *cmyk) cmyk[3] = k; } -static fz_colorspace kdevicegray = { -1, "DeviceGray", 1, graytoxyz, xyztogray }; -static fz_colorspace kdevicergb = { -1, "DeviceRGB", 3, rgbtoxyz, xyztorgb }; -static fz_colorspace kdevicebgr = { -1, "DeviceRGB", 3, bgrtoxyz, xyztobgr }; -static fz_colorspace kdevicecmyk = { -1, "DeviceCMYK", 4, cmyktoxyz, xyztocmyk }; +static fz_colorspace k_device_gray = { -1, "DeviceGray", 1, gray_to_xyz, xyz_to_gray }; +static fz_colorspace k_device_rgb = { -1, "DeviceRGB", 3, rgb_to_xyz, xyz_to_rgb }; +static fz_colorspace k_device_bgr = { -1, "DeviceRGB", 3, bgr_to_xyz, xyz_to_bgr }; +static fz_colorspace k_device_cmyk = { -1, "DeviceCMYK", 4, cmyk_to_xyz, xyz_to_cmyk }; -fz_colorspace *fz_devicegray = &kdevicegray; -fz_colorspace *fz_devicergb = &kdevicergb; -fz_colorspace *fz_devicebgr = &kdevicebgr; -fz_colorspace *fz_devicecmyk = &kdevicecmyk; +fz_colorspace *fz_device_gray = &k_device_gray; +fz_colorspace *fz_device_rgb = &k_device_rgb; +fz_colorspace *fz_device_bgr = &k_device_bgr; +fz_colorspace *fz_device_cmyk = &k_device_cmyk; /* Fast pixmap color conversions */ -static void fastgraytorgb(fz_pixmap *src, fz_pixmap *dst) +static void fast_gray_to_rgb(fz_pixmap *src, fz_pixmap *dst) { unsigned char *s = src->samples; unsigned char *d = dst->samples; @@ -187,7 +187,7 @@ static void fastgraytorgb(fz_pixmap *src, fz_pixmap *dst) } } -static void fastgraytocmyk(fz_pixmap *src, fz_pixmap *dst) +static void fast_gray_to_cmyk(fz_pixmap *src, fz_pixmap *dst) { unsigned char *s = src->samples; unsigned char *d = dst->samples; @@ -204,7 +204,7 @@ static void fastgraytocmyk(fz_pixmap *src, fz_pixmap *dst) } } -static void fastrgbtogray(fz_pixmap *src, fz_pixmap *dst) +static void fast_rgb_to_gray(fz_pixmap *src, fz_pixmap *dst) { unsigned char *s = src->samples; unsigned char *d = dst->samples; @@ -218,7 +218,7 @@ static void fastrgbtogray(fz_pixmap *src, fz_pixmap *dst) } } -static void fastbgrtogray(fz_pixmap *src, fz_pixmap *dst) +static void fast_bgr_to_gray(fz_pixmap *src, fz_pixmap *dst) { unsigned char *s = src->samples; unsigned char *d = dst->samples; @@ -232,7 +232,7 @@ static void fastbgrtogray(fz_pixmap *src, fz_pixmap *dst) } } -static void fastrgbtocmyk(fz_pixmap *src, fz_pixmap *dst) +static void fast_rgb_to_cmyk(fz_pixmap *src, fz_pixmap *dst) { unsigned char *s = src->samples; unsigned char *d = dst->samples; @@ -253,7 +253,7 @@ static void fastrgbtocmyk(fz_pixmap *src, fz_pixmap *dst) } } -static void fastbgrtocmyk(fz_pixmap *src, fz_pixmap *dst) +static void fast_bgr_to_cmyk(fz_pixmap *src, fz_pixmap *dst) { unsigned char *s = src->samples; unsigned char *d = dst->samples; @@ -274,7 +274,7 @@ static void fastbgrtocmyk(fz_pixmap *src, fz_pixmap *dst) } } -static void fastcmyktogray(fz_pixmap *src, fz_pixmap *dst) +static void fast_cmyk_to_gray(fz_pixmap *src, fz_pixmap *dst) { unsigned char *s = src->samples; unsigned char *d = dst->samples; @@ -291,7 +291,7 @@ static void fastcmyktogray(fz_pixmap *src, fz_pixmap *dst) } } -static void fastcmyktorgb(fz_pixmap *src, fz_pixmap *dst) +static void fast_cmyk_to_rgb(fz_pixmap *src, fz_pixmap *dst) { unsigned char *s = src->samples; unsigned char *d = dst->samples; @@ -304,7 +304,7 @@ static void fastcmyktorgb(fz_pixmap *src, fz_pixmap *dst) cmyk[1] = s[1] / 255.0f; cmyk[2] = s[2] / 255.0f; cmyk[3] = s[3] / 255.0f; - cmyktoxyz(nil, cmyk, rgb); + cmyk_to_xyz(NULL, cmyk, rgb); d[0] = rgb[0] * 255; d[1] = rgb[1] * 255; d[2] = rgb[2] * 255; @@ -319,7 +319,7 @@ static void fastcmyktorgb(fz_pixmap *src, fz_pixmap *dst) } } -static void fastcmyktobgr(fz_pixmap *src, fz_pixmap *dst) +static void fast_cmyk_to_bgr(fz_pixmap *src, fz_pixmap *dst) { unsigned char *s = src->samples; unsigned char *d = dst->samples; @@ -332,7 +332,7 @@ static void fastcmyktobgr(fz_pixmap *src, fz_pixmap *dst) cmyk[1] = s[1] / 255.0f; cmyk[2] = s[2] / 255.0f; cmyk[3] = s[3] / 255.0f; - cmyktoxyz(nil, cmyk, rgb); + cmyk_to_xyz(NULL, cmyk, rgb); d[0] = rgb[2] * 255; d[1] = rgb[1] * 255; d[2] = rgb[0] * 255; @@ -347,7 +347,7 @@ static void fastcmyktobgr(fz_pixmap *src, fz_pixmap *dst) } } -static void fastrgbtobgr(fz_pixmap *src, fz_pixmap *dst) +static void fast_rgb_to_bgr(fz_pixmap *src, fz_pixmap *dst) { unsigned char *s = src->samples; unsigned char *d = dst->samples; @@ -364,10 +364,10 @@ static void fastrgbtobgr(fz_pixmap *src, fz_pixmap *dst) } static void -fz_stdconvpixmap(fz_pixmap *src, fz_pixmap *dst) +fz_std_conv_pixmap(fz_pixmap *src, fz_pixmap *dst) { - float srcv[FZ_MAXCOLORS]; - float dstv[FZ_MAXCOLORS]; + float srcv[FZ_MAX_COLORS]; + float dstv[FZ_MAX_COLORS]; int srcn, dstn; int y, x, k, i; @@ -395,7 +395,7 @@ fz_stdconvpixmap(fz_pixmap *src, fz_pixmap *dst) srcv[1] = *s++ - 128; srcv[2] = *s++ - 128; - fz_convertcolor(ss, srcv, ds, dstv); + fz_convert_color(ss, srcv, ds, dstv); for (k = 0; k < dstn; k++) *d++ = dstv[k] * 255; @@ -415,7 +415,7 @@ fz_stdconvpixmap(fz_pixmap *src, fz_pixmap *dst) for (k = 0; k < srcn; k++) srcv[k] = *s++ / 255.0f; - fz_convertcolor(ss, srcv, ds, dstv); + fz_convert_color(ss, srcv, ds, dstv); for (k = 0; k < dstn; k++) *d++ = dstv[k] * 255; @@ -428,12 +428,12 @@ fz_stdconvpixmap(fz_pixmap *src, fz_pixmap *dst) /* 1-d lookup table for separation and similar colorspaces */ else if (srcn == 1) { - unsigned char lookup[FZ_MAXCOLORS * 256]; + unsigned char lookup[FZ_MAX_COLORS * 256]; for (i = 0; i < 256; i++) { srcv[0] = i / 255.0f; - fz_convertcolor(ss, srcv, ds, dstv); + fz_convert_color(ss, srcv, ds, dstv); for (k = 0; k < dstn; k++) lookup[i * dstn + k] = dstv[k] * 255; } @@ -453,16 +453,16 @@ fz_stdconvpixmap(fz_pixmap *src, fz_pixmap *dst) /* Memoize colors using a hash table for the general case */ else { - fz_hashtable *lookup; + fz_hash_table *lookup; unsigned char *color; - lookup = fz_newhash(509, srcn); + lookup = fz_new_hash_table(509, srcn); for (y = 0; y < src->h; y++) { for (x = 0; x < src->w; x++) { - color = fz_hashfind(lookup, s); + color = fz_hash_find(lookup, s); if (color) { memcpy(d, color, dstn); @@ -474,23 +474,23 @@ fz_stdconvpixmap(fz_pixmap *src, fz_pixmap *dst) { for (k = 0; k < srcn; k++) srcv[k] = *s++ / 255.0f; - fz_convertcolor(ss, srcv, ds, dstv); + fz_convert_color(ss, srcv, ds, dstv); for (k = 0; k < dstn; k++) *d++ = dstv[k] * 255; - fz_hashinsert(lookup, s - srcn, d - dstn); + fz_hash_insert(lookup, s - srcn, d - dstn); *d++ = *s++; } } } - fz_freehash(lookup); + fz_free_hash(lookup); } } void -fz_convertpixmap(fz_pixmap *sp, fz_pixmap *dp) +fz_convert_pixmap(fz_pixmap *sp, fz_pixmap *dp) { fz_colorspace *ss = sp->colorspace; fz_colorspace *ds = dp->colorspace; @@ -498,57 +498,57 @@ fz_convertpixmap(fz_pixmap *sp, fz_pixmap *dp) assert(ss && ds); if (sp->mask) - dp->mask = fz_keeppixmap(sp->mask); + dp->mask = fz_keep_pixmap(sp->mask); dp->interpolate = sp->interpolate; - if (ss == fz_devicegray) + if (ss == fz_device_gray) { - if (ds == fz_devicergb) fastgraytorgb(sp, dp); - else if (ds == fz_devicebgr) fastgraytorgb(sp, dp); /* bgr == rgb here */ - else if (ds == fz_devicecmyk) fastgraytocmyk(sp, dp); - else fz_stdconvpixmap(sp, dp); + if (ds == fz_device_rgb) fast_gray_to_rgb(sp, dp); + else if (ds == fz_device_bgr) fast_gray_to_rgb(sp, dp); /* bgr == rgb here */ + else if (ds == fz_device_cmyk) fast_gray_to_cmyk(sp, dp); + else fz_std_conv_pixmap(sp, dp); } - else if (ss == fz_devicergb) + else if (ss == fz_device_rgb) { - if (ds == fz_devicegray) fastrgbtogray(sp, dp); - else if (ds == fz_devicebgr) fastrgbtobgr(sp, dp); - else if (ds == fz_devicecmyk) fastrgbtocmyk(sp, dp); - else fz_stdconvpixmap(sp, dp); + if (ds == fz_device_gray) fast_rgb_to_gray(sp, dp); + else if (ds == fz_device_bgr) fast_rgb_to_bgr(sp, dp); + else if (ds == fz_device_cmyk) fast_rgb_to_cmyk(sp, dp); + else fz_std_conv_pixmap(sp, dp); } - else if (ss == fz_devicebgr) + else if (ss == fz_device_bgr) { - if (ds == fz_devicegray) fastbgrtogray(sp, dp); - else if (ds == fz_devicergb) fastrgbtobgr(sp, dp); /* bgr = rgb here */ - else if (ds == fz_devicecmyk) fastbgrtocmyk(sp, dp); - else fz_stdconvpixmap(sp, dp); + if (ds == fz_device_gray) fast_bgr_to_gray(sp, dp); + else if (ds == fz_device_rgb) fast_rgb_to_bgr(sp, dp); /* bgr = rgb here */ + else if (ds == fz_device_cmyk) fast_bgr_to_cmyk(sp, dp); + else fz_std_conv_pixmap(sp, dp); } - else if (ss == fz_devicecmyk) + else if (ss == fz_device_cmyk) { - if (ds == fz_devicegray) fastcmyktogray(sp, dp); - else if (ds == fz_devicebgr) fastcmyktobgr(sp, dp); - else if (ds == fz_devicergb) fastcmyktorgb(sp, dp); - else fz_stdconvpixmap(sp, dp); + if (ds == fz_device_gray) fast_cmyk_to_gray(sp, dp); + else if (ds == fz_device_bgr) fast_cmyk_to_bgr(sp, dp); + else if (ds == fz_device_rgb) fast_cmyk_to_rgb(sp, dp); + else fz_std_conv_pixmap(sp, dp); } - else fz_stdconvpixmap(sp, dp); + else fz_std_conv_pixmap(sp, dp); } /* Convert a single color */ static void -fz_stdconvcolor(fz_colorspace *srcs, float *srcv, fz_colorspace *dsts, float *dstv) +fz_std_conv_color(fz_colorspace *srcs, float *srcv, fz_colorspace *dsts, float *dstv) { float xyz[3]; int i; if (srcs != dsts) { - assert(srcs->toxyz && dsts->fromxyz); - srcs->toxyz(srcs, srcv, xyz); - dsts->fromxyz(dsts, xyz, dstv); + assert(srcs->to_xyz && dsts->from_xyz); + srcs->to_xyz(srcs, srcv, xyz); + dsts->from_xyz(dsts, xyz, dstv); for (i = 0; i < dsts->n; i++) dstv[i] = CLAMP(dstv[i], 0, 1); } @@ -560,17 +560,17 @@ fz_stdconvcolor(fz_colorspace *srcs, float *srcv, fz_colorspace *dsts, float *ds } void -fz_convertcolor(fz_colorspace *ss, float *sv, fz_colorspace *ds, float *dv) +fz_convert_color(fz_colorspace *ss, float *sv, fz_colorspace *ds, float *dv) { - if (ss == fz_devicegray) + if (ss == fz_device_gray) { - if ((ds == fz_devicergb) || (ds == fz_devicebgr)) + if ((ds == fz_device_rgb) || (ds == fz_device_bgr)) { dv[0] = sv[0]; dv[1] = sv[0]; dv[2] = sv[0]; } - else if (ds == fz_devicecmyk) + else if (ds == fz_device_cmyk) { dv[0] = 0; dv[1] = 0; @@ -578,22 +578,22 @@ fz_convertcolor(fz_colorspace *ss, float *sv, fz_colorspace *ds, float *dv) dv[3] = sv[0]; } else - fz_stdconvcolor(ss, sv, ds, dv); + fz_std_conv_color(ss, sv, ds, dv); } - else if (ss == fz_devicergb) + else if (ss == fz_device_rgb) { - if (ds == fz_devicegray) + if (ds == fz_device_gray) { dv[0] = sv[0] * 0.3f + sv[1] * 0.59f + sv[2] * 0.11f; } - else if (ds == fz_devicebgr) + else if (ds == fz_device_bgr) { dv[0] = sv[2]; dv[1] = sv[1]; dv[2] = sv[0]; } - else if (ds == fz_devicecmyk) + else if (ds == fz_device_cmyk) { float c = 1 - sv[0]; float m = 1 - sv[1]; @@ -605,22 +605,22 @@ fz_convertcolor(fz_colorspace *ss, float *sv, fz_colorspace *ds, float *dv) dv[3] = k; } else - fz_stdconvcolor(ss, sv, ds, dv); + fz_std_conv_color(ss, sv, ds, dv); } - else if (ss == fz_devicebgr) + else if (ss == fz_device_bgr) { - if (ds == fz_devicegray) + if (ds == fz_device_gray) { dv[0] = sv[0] * 0.11f + sv[1] * 0.59f + sv[2] * 0.3f; } - else if (ds == fz_devicebgr) + else if (ds == fz_device_bgr) { dv[0] = sv[2]; dv[1] = sv[1]; dv[2] = sv[0]; } - else if (ds == fz_devicecmyk) + else if (ds == fz_device_cmyk) { float c = 1 - sv[2]; float m = 1 - sv[1]; @@ -632,33 +632,33 @@ fz_convertcolor(fz_colorspace *ss, float *sv, fz_colorspace *ds, float *dv) dv[3] = k; } else - fz_stdconvcolor(ss, sv, ds, dv); + fz_std_conv_color(ss, sv, ds, dv); } - else if (ss == fz_devicecmyk) + else if (ss == fz_device_cmyk) { - if (ds == fz_devicegray) + if (ds == fz_device_gray) { float c = sv[0] * 0.3f; float m = sv[1] * 0.59f; float y = sv[2] * 0.11f; dv[0] = 1 - MIN(c + m + y + sv[3], 1); } - else if (ds == fz_devicergb) + else if (ds == fz_device_rgb) { #ifdef SLOWCMYK - cmyktoxyz(nil, sv, dv); + cmyk_to_xyz(NULL, sv, dv); #else dv[0] = 1 - MIN(sv[0] + sv[3], 1); dv[1] = 1 - MIN(sv[1] + sv[3], 1); dv[2] = 1 - MIN(sv[2] + sv[3], 1); #endif } - else if (ds == fz_devicebgr) + else if (ds == fz_device_bgr) { #ifdef SLOWCMYK float rgb[3]; - cmyktoxyz(nil, sv, rgb); + cmyk_to_xyz(NULL, sv, rgb); dv[0] = rgb[2]; dv[1] = rgb[1]; dv[2] = rgb[0]; @@ -669,9 +669,9 @@ fz_convertcolor(fz_colorspace *ss, float *sv, fz_colorspace *ds, float *dv) #endif } else - fz_stdconvcolor(ss, sv, ds, dv); + fz_std_conv_color(ss, sv, ds, dv); } else - fz_stdconvcolor(ss, sv, ds, dv); + fz_std_conv_color(ss, sv, ds, dv); } diff --git a/fitz/res_font.c b/fitz/res_font.c index f076a9e9..f94940a6 100644 --- a/fitz/res_font.c +++ b/fitz/res_font.c @@ -4,10 +4,10 @@ #include FT_FREETYPE_H #include FT_STROKER_H -static void fz_finalizefreetype(void); +static void fz_finalize_freetype(void); static fz_font * -fz_newfont(void) +fz_new_font(void) { fz_font *font; @@ -15,41 +15,41 @@ fz_newfont(void) font->refs = 1; strcpy(font->name, ""); - font->ftface = nil; - font->ftsubstitute = 0; - font->fthint = 0; + font->ft_face = NULL; + font->ft_substitute = 0; + font->ft_hint = 0; - font->ftfile = nil; - font->ftdata = nil; - font->ftsize = 0; + font->ft_file = NULL; + font->ft_data = NULL; + font->ft_size = 0; font->t3matrix = fz_identity; - font->t3resources = nil; - font->t3procs = nil; - font->t3widths = nil; - font->t3xref = nil; - font->t3run = nil; + font->t3resources = NULL; + font->t3procs = NULL; + font->t3widths = NULL; + font->t3xref = NULL; + font->t3run = NULL; font->bbox.x0 = 0; font->bbox.y0 = 0; font->bbox.x1 = 1000; font->bbox.y1 = 1000; - font->widthcount = 0; - font->widthtable = nil; + font->width_count = 0; + font->width_table = NULL; return font; } fz_font * -fz_keepfont(fz_font *font) +fz_keep_font(fz_font *font) { font->refs ++; return font; } void -fz_dropfont(fz_font *font) +fz_drop_font(fz_font *font) { int fterr; int i; @@ -59,36 +59,36 @@ fz_dropfont(fz_font *font) if (font->t3procs) { if (font->t3resources) - fz_dropobj(font->t3resources); + fz_drop_obj(font->t3resources); for (i = 0; i < 256; i++) if (font->t3procs[i]) - fz_dropbuffer(font->t3procs[i]); + fz_drop_buffer(font->t3procs[i]); fz_free(font->t3procs); fz_free(font->t3widths); } - if (font->ftface) + if (font->ft_face) { - fterr = FT_Done_Face((FT_Face)font->ftface); + fterr = FT_Done_Face((FT_Face)font->ft_face); if (fterr) - fz_warn("freetype finalizing face: %s", ft_errorstring(fterr)); - fz_finalizefreetype(); + fz_warn("freetype finalizing face: %s", ft_error_string(fterr)); + fz_finalize_freetype(); } - if (font->ftfile) - fz_free(font->ftfile); - if (font->ftdata) - fz_free(font->ftdata); + if (font->ft_file) + fz_free(font->ft_file); + if (font->ft_data) + fz_free(font->ft_data); - if (font->widthtable) - fz_free(font->widthtable); + if (font->width_table) + fz_free(font->width_table); fz_free(font); } } void -fz_setfontbbox(fz_font *font, float xmin, float ymin, float xmax, float ymax) +fz_set_font_bbox(fz_font *font, float xmin, float ymin, float xmax, float ymax) { font->bbox.x0 = xmin; font->bbox.y0 = ymin; @@ -100,7 +100,7 @@ fz_setfontbbox(fz_font *font, float xmin, float ymin, float xmax, float ymax) * Freetype hooks */ -static FT_Library fz_ftlib = nil; +static FT_Library fz_ftlib = NULL; static int fz_ftlib_refs = 0; #undef __FTERRORS_H__ @@ -119,7 +119,7 @@ static const struct ft_error ft_errors[] = #include FT_ERRORS_H }; -char *ft_errorstring(int err) +char *ft_error_string(int err) { const struct ft_error *e; @@ -131,7 +131,7 @@ char *ft_errorstring(int err) } static fz_error -fz_initfreetype(void) +fz_init_freetype(void) { int fterr; int maj, min, pat; @@ -144,14 +144,14 @@ fz_initfreetype(void) fterr = FT_Init_FreeType(&fz_ftlib); if (fterr) - return fz_throw("cannot init freetype: %s", ft_errorstring(fterr)); + return fz_throw("cannot init freetype: %s", ft_error_string(fterr)); FT_Library_Version(fz_ftlib, &maj, &min, &pat); if (maj == 2 && min == 1 && pat < 7) { fterr = FT_Done_FreeType(fz_ftlib); if (fterr) - fz_warn("freetype finalizing: %s", ft_errorstring(fterr)); + fz_warn("freetype finalizing: %s", ft_error_string(fterr)); return fz_throw("freetype version too old: %d.%d.%d", maj, min, pat); } @@ -160,7 +160,7 @@ fz_initfreetype(void) } static void -fz_finalizefreetype(void) +fz_finalize_freetype(void) { int fterr; @@ -168,29 +168,29 @@ fz_finalizefreetype(void) { fterr = FT_Done_FreeType(fz_ftlib); if (fterr) - fz_warn("freetype finalizing: %s", ft_errorstring(fterr)); - fz_ftlib = nil; + fz_warn("freetype finalizing: %s", ft_error_string(fterr)); + fz_ftlib = NULL; } } fz_error -fz_newfontfromfile(fz_font **fontp, char *path, int index) +fz_new_font_from_file(fz_font **fontp, char *path, int index) { FT_Face face; fz_error error; fz_font *font; int fterr; - error = fz_initfreetype(); + error = fz_init_freetype(); if (error) return fz_rethrow(error, "cannot init freetype library"); fterr = FT_New_Face(fz_ftlib, path, index, &face); if (fterr) - return fz_throw("freetype: cannot load font: %s", ft_errorstring(fterr)); + return fz_throw("freetype: cannot load font: %s", ft_error_string(fterr)); - font = fz_newfont(); - font->ftface = face; + font = fz_new_font(); + font->ft_face = face; font->bbox.x0 = face->bbox.xMin * 1000 / face->units_per_EM; font->bbox.y0 = face->bbox.yMin * 1000 / face->units_per_EM; font->bbox.x1 = face->bbox.xMax * 1000 / face->units_per_EM; @@ -201,23 +201,23 @@ fz_newfontfromfile(fz_font **fontp, char *path, int index) } fz_error -fz_newfontfrombuffer(fz_font **fontp, unsigned char *data, int len, int index) +fz_new_font_from_memory(fz_font **fontp, unsigned char *data, int len, int index) { FT_Face face; fz_error error; fz_font *font; int fterr; - error = fz_initfreetype(); + error = fz_init_freetype(); if (error) return fz_rethrow(error, "cannot init freetype library"); fterr = FT_New_Memory_Face(fz_ftlib, data, len, index, &face); if (fterr) - return fz_throw("freetype: cannot load font: %s", ft_errorstring(fterr)); + return fz_throw("freetype: cannot load font: %s", ft_error_string(fterr)); - font = fz_newfont(); - font->ftface = face; + font = fz_new_font(); + font->ft_face = face; font->bbox.x0 = face->bbox.xMin * 1000 / face->units_per_EM; font->bbox.y0 = face->bbox.yMin * 1000 / face->units_per_EM; font->bbox.x1 = face->bbox.xMax * 1000 / face->units_per_EM; @@ -228,10 +228,10 @@ fz_newfontfrombuffer(fz_font **fontp, unsigned char *data, int len, int index) } static fz_matrix -fz_adjustftglyphwidth(fz_font *font, int gid, fz_matrix trm) +fz_adjust_ft_glyph_width(fz_font *font, int gid, fz_matrix trm) { /* Fudge the font matrix to stretch the glyph if we've substituted the font. */ - if (font->ftsubstitute && gid < font->widthcount) + if (font->ft_substitute && gid < font->width_count) { FT_Error fterr; int subw; @@ -239,17 +239,17 @@ fz_adjustftglyphwidth(fz_font *font, int gid, fz_matrix trm) float scale; /* TODO: use FT_Get_Advance */ - fterr = FT_Set_Char_Size(font->ftface, 1000, 1000, 72, 72); + fterr = FT_Set_Char_Size(font->ft_face, 1000, 1000, 72, 72); if (fterr) - fz_warn("freetype setting character size: %s", ft_errorstring(fterr)); + fz_warn("freetype setting character size: %s", ft_error_string(fterr)); - fterr = FT_Load_Glyph(font->ftface, gid, + fterr = FT_Load_Glyph(font->ft_face, gid, FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP | FT_LOAD_IGNORE_TRANSFORM); if (fterr) - fz_warn("freetype failed to load glyph: %s", ft_errorstring(fterr)); + fz_warn("freetype failed to load glyph: %s", ft_error_string(fterr)); - realw = ((FT_Face)font->ftface)->glyph->metrics.horiAdvance; - subw = font->widthtable[gid]; + realw = ((FT_Face)font->ft_face)->glyph->metrics.horiAdvance; + subw = font->width_table[gid]; if (realw) scale = (float) subw / realw; else @@ -262,16 +262,16 @@ fz_adjustftglyphwidth(fz_font *font, int gid, fz_matrix trm) } fz_pixmap * -fz_renderftglyph(fz_font *font, int gid, fz_matrix trm) +fz_render_ft_glyph(fz_font *font, int gid, fz_matrix trm) { - FT_Face face = font->ftface; + FT_Face face = font->ft_face; FT_Matrix m; FT_Vector v; FT_Error fterr; fz_pixmap *glyph; int y; - trm = fz_adjustftglyphwidth(font, gid, trm); + trm = fz_adjust_ft_glyph_width(font, gid, trm); /* Freetype mutilates complex glyphs if they are loaded @@ -290,10 +290,10 @@ fz_renderftglyph(fz_font *font, int gid, fz_matrix trm) fterr = FT_Set_Char_Size(face, 65536, 65536, 72, 72); /* should be 64, 64 */ if (fterr) - fz_warn("freetype setting character size: %s", ft_errorstring(fterr)); + fz_warn("freetype setting character size: %s", ft_error_string(fterr)); FT_Set_Transform(face, &m, &v); - if (font->fthint) + if (font->ft_hint) { /* Enable hinting, but keep the huge char size so that @@ -304,7 +304,7 @@ fz_renderftglyph(fz_font *font, int gid, fz_matrix trm) */ #ifdef GRIDFIT /* If you really want grid fitting, enable this code. */ - float scale = fz_matrixexpansion(trm); + float scale = fz_matrix_expansion(trm); m.xx = trm.a * 65536 / scale; m.xy = trm.b * 65536 / scale; m.yx = trm.c * 65536 / scale; @@ -314,31 +314,31 @@ fz_renderftglyph(fz_font *font, int gid, fz_matrix trm) fterr = FT_Set_Char_Size(face, 64 * scale, 64 * scale, 72, 72); if (fterr) - fz_warn("freetype setting character size: %s", ft_errorstring(fterr)); + fz_warn("freetype setting character size: %s", ft_error_string(fterr)); FT_Set_Transform(face, &m, &v); #endif fterr = FT_Load_Glyph(face, gid, FT_LOAD_NO_BITMAP); if (fterr) - fz_warn("freetype load glyph (gid %d): %s", gid, ft_errorstring(fterr)); + fz_warn("freetype load glyph (gid %d): %s", gid, ft_error_string(fterr)); } else { fterr = FT_Load_Glyph(face, gid, FT_LOAD_NO_BITMAP | FT_LOAD_NO_HINTING); if (fterr) { - fz_warn("freetype load glyph (gid %d): %s", gid, ft_errorstring(fterr)); - return nil; + fz_warn("freetype load glyph (gid %d): %s", gid, ft_error_string(fterr)); + return NULL; } } fterr = FT_Render_Glyph(face->glyph, ft_render_mode_normal); if (fterr) { - fz_warn("freetype render glyph (gid %d): %s", gid, ft_errorstring(fterr)); - return nil; + fz_warn("freetype render glyph (gid %d): %s", gid, ft_error_string(fterr)); + return NULL; } - glyph = fz_newpixmap(nil, + glyph = fz_new_pixmap(NULL, face->glyph->bitmap_left, face->glyph->bitmap_top - face->glyph->bitmap.rows, face->glyph->bitmap.width, @@ -355,10 +355,10 @@ fz_renderftglyph(fz_font *font, int gid, fz_matrix trm) } fz_pixmap * -fz_renderftstrokedglyph(fz_font *font, int gid, fz_matrix trm, fz_matrix ctm, fz_strokestate *state) +fz_render_ft_stroked_glyph(fz_font *font, int gid, fz_matrix trm, fz_matrix ctm, fz_stroke_state *state) { - FT_Face face = font->ftface; - float expansion = fz_matrixexpansion(ctm); + FT_Face face = font->ft_face; + float expansion = fz_matrix_expansion(ctm); int linewidth = state->linewidth * expansion * 64 / 2; FT_Matrix m; FT_Vector v; @@ -369,7 +369,7 @@ fz_renderftstrokedglyph(fz_font *font, int gid, fz_matrix trm, fz_matrix ctm, fz fz_pixmap *pix; int y; - trm = fz_adjustftglyphwidth(font, gid, trm); + trm = fz_adjust_ft_glyph_width(font, gid, trm); m.xx = trm.a * 64; /* should be 65536 */ m.yx = trm.b * 64; @@ -381,8 +381,8 @@ fz_renderftstrokedglyph(fz_font *font, int gid, fz_matrix trm, fz_matrix ctm, fz fterr = FT_Set_Char_Size(face, 65536, 65536, 72, 72); /* should be 64, 64 */ if (fterr) { - fz_warn("FT_Set_Char_Size: %s", ft_errorstring(fterr)); - return nil; + fz_warn("FT_Set_Char_Size: %s", ft_error_string(fterr)); + return NULL; } FT_Set_Transform(face, &m, &v); @@ -390,15 +390,15 @@ fz_renderftstrokedglyph(fz_font *font, int gid, fz_matrix trm, fz_matrix ctm, fz fterr = FT_Load_Glyph(face, gid, FT_LOAD_NO_BITMAP | FT_LOAD_NO_HINTING); if (fterr) { - fz_warn("FT_Load_Glyph(gid %d): %s", gid, ft_errorstring(fterr)); - return nil; + fz_warn("FT_Load_Glyph(gid %d): %s", gid, ft_error_string(fterr)); + return NULL; } fterr = FT_Stroker_New(fz_ftlib, &stroker); if (fterr) { - fz_warn("FT_Stroker_New: %s", ft_errorstring(fterr)); - return nil; + fz_warn("FT_Stroker_New: %s", ft_error_string(fterr)); + return NULL; } FT_Stroker_Set(stroker, linewidth, state->linecap, state->linejoin, state->miterlimit * 65536); @@ -406,31 +406,31 @@ fz_renderftstrokedglyph(fz_font *font, int gid, fz_matrix trm, fz_matrix ctm, fz fterr = FT_Get_Glyph(face->glyph, &glyph); if (fterr) { - fz_warn("FT_Get_Glyph: %s", ft_errorstring(fterr)); + fz_warn("FT_Get_Glyph: %s", ft_error_string(fterr)); FT_Stroker_Done(stroker); - return nil; + return NULL; } fterr = FT_Glyph_Stroke(&glyph, stroker, 1); if (fterr) { - fz_warn("FT_Glyph_Stroke: %s", ft_errorstring(fterr)); + fz_warn("FT_Glyph_Stroke: %s", ft_error_string(fterr)); FT_Done_Glyph(glyph); FT_Stroker_Done(stroker); - return nil; + return NULL; } fterr = FT_Glyph_To_Bitmap(&glyph, FT_RENDER_MODE_NORMAL, 0, 1); if (fterr) { - fz_warn("FT_Glyph_To_Bitmap: %s", ft_errorstring(fterr)); + fz_warn("FT_Glyph_To_Bitmap: %s", ft_error_string(fterr)); FT_Done_Glyph(glyph); FT_Stroker_Done(stroker); - return nil; + return NULL; } bitmap = (FT_BitmapGlyph)glyph; - pix = fz_newpixmap(nil, + pix = fz_new_pixmap(NULL, bitmap->left, bitmap->top - bitmap->bitmap.rows, bitmap->bitmap.width, @@ -454,12 +454,12 @@ fz_renderftstrokedglyph(fz_font *font, int gid, fz_matrix trm, fz_matrix ctm, fz */ fz_font * -fz_newtype3font(char *name, fz_matrix matrix) +fz_new_type3_font(char *name, fz_matrix matrix) { fz_font *font; int i; - font = fz_newfont(); + font = fz_new_font(); font->t3procs = fz_calloc(256, sizeof(fz_buffer*)); font->t3widths = fz_calloc(256, sizeof(float)); @@ -467,7 +467,7 @@ fz_newtype3font(char *name, fz_matrix matrix) font->t3matrix = matrix; for (i = 0; i < 256; i++) { - font->t3procs[i] = nil; + font->t3procs[i] = NULL; font->t3widths[i] = 0; } @@ -475,57 +475,57 @@ fz_newtype3font(char *name, fz_matrix matrix) } fz_pixmap * -fz_rendert3glyph(fz_font *font, int gid, fz_matrix trm) +fz_render_t3_glyph(fz_font *font, int gid, fz_matrix trm) { fz_error error; fz_matrix ctm; fz_buffer *contents; fz_bbox bbox; fz_device *dev; - fz_glyphcache *cache; + fz_glyph_cache *cache; fz_pixmap *glyph; fz_pixmap *result; if (gid < 0 || gid > 255) - return nil; + return NULL; contents = font->t3procs[gid]; if (!contents) - return nil; + return NULL; ctm = fz_concat(font->t3matrix, trm); - dev = fz_newbboxdevice(&bbox); + dev = fz_new_bbox_device(&bbox); error = font->t3run(font->t3xref, font->t3resources, contents, dev, ctm); if (error) fz_catch(error, "cannot draw type3 glyph"); - fz_freedevice(dev); + fz_free_device(dev); - glyph = fz_newpixmap(fz_devicegray, bbox.x0-1, bbox.y0-1, bbox.x1 - bbox.x0 + 1, bbox.y1 - bbox.y0 + 1); - fz_clearpixmap(glyph); + glyph = fz_new_pixmap(fz_device_gray, bbox.x0-1, bbox.y0-1, bbox.x1 - bbox.x0 + 1, bbox.y1 - bbox.y0 + 1); + fz_clear_pixmap(glyph); - cache = fz_newglyphcache(); - dev = fz_newdrawdevice(cache, glyph); + cache = fz_new_glyph_cache(); + dev = fz_new_draw_device(cache, glyph); error = font->t3run(font->t3xref, font->t3resources, contents, dev, ctm); if (error) fz_catch(error, "cannot draw type3 glyph"); - fz_freedevice(dev); - fz_freeglyphcache(cache); + fz_free_device(dev); + fz_free_glyph_cache(cache); - result = fz_alphafromgray(glyph, 0); - fz_droppixmap(glyph); + result = fz_alpha_from_gray(glyph, 0); + fz_drop_pixmap(glyph); return result; } void -fz_debugfont(fz_font *font) +fz_debug_font(fz_font *font) { printf("font '%s' {\n", font->name); - if (font->ftface) + if (font->ft_face) { - printf("\tfreetype face %p\n", font->ftface); - if (font->ftsubstitute) + printf("\tfreetype face %p\n", font->ft_face); + if (font->ft_substitute) printf("\tsubstitute font\n"); } diff --git a/fitz/res_path.c b/fitz/res_path.c index b4ac415a..4959754b 100644 --- a/fitz/res_path.c +++ b/fitz/res_path.c @@ -1,56 +1,56 @@ #include "fitz.h" fz_path * -fz_newpath(void) +fz_new_path(void) { fz_path *path; path = fz_malloc(sizeof(fz_path)); path->len = 0; path->cap = 0; - path->els = nil; + path->items = NULL; return path; } fz_path * -fz_clonepath(fz_path *old) +fz_clone_path(fz_path *old) { fz_path *path; path = fz_malloc(sizeof(fz_path)); path->len = old->len; path->cap = old->len; - path->els = fz_calloc(path->cap, sizeof(fz_pathel)); - memcpy(path->els, old->els, sizeof(fz_pathel) * path->len); + path->items = fz_calloc(path->cap, sizeof(fz_path_item)); + memcpy(path->items, old->items, sizeof(fz_path_item) * path->len); return path; } void -fz_freepath(fz_path *path) +fz_free_path(fz_path *path) { - fz_free(path->els); + fz_free(path->items); fz_free(path); } static void -growpath(fz_path *path, int n) +grow_path(fz_path *path, int n) { if (path->len + n < path->cap) return; while (path->len + n > path->cap) path->cap = path->cap + 36; - path->els = fz_realloc(path->els, path->cap, sizeof(fz_pathel)); + path->items = fz_realloc(path->items, path->cap, sizeof(fz_path_item)); } void fz_moveto(fz_path *path, float x, float y) { - growpath(path, 3); - path->els[path->len++].k = FZ_MOVETO; - path->els[path->len++].v = x; - path->els[path->len++].v = y; + grow_path(path, 3); + path->items[path->len++].k = FZ_MOVETO; + path->items[path->len++].v = x; + path->items[path->len++].v = y; } void @@ -58,10 +58,10 @@ fz_lineto(fz_path *path, float x, float y) { if (path->len == 0) 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; + grow_path(path, 3); + path->items[path->len++].k = FZ_LINETO; + path->items[path->len++].v = x; + path->items[path->len++].v = y; } void @@ -72,21 +72,21 @@ fz_curveto(fz_path *path, { if (path->len == 0) 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; - path->els[path->len++].v = x2; - path->els[path->len++].v = y2; - path->els[path->len++].v = x3; - path->els[path->len++].v = y3; + grow_path(path, 7); + path->items[path->len++].k = FZ_CURVETO; + path->items[path->len++].v = x1; + path->items[path->len++].v = y1; + path->items[path->len++].v = x2; + path->items[path->len++].v = y2; + path->items[path->len++].v = x3; + path->items[path->len++].v = 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; + float x1 = path->items[path->len-2].v; + float y1 = path->items[path->len-1].v; fz_curveto(path, x1, y1, x2, y2, x3, y3); } @@ -101,11 +101,11 @@ fz_closepath(fz_path *path) { if (path->len == 0) return; - growpath(path, 1); - path->els[path->len++].k = FZ_CLOSEPATH; + grow_path(path, 1); + path->items[path->len++].k = FZ_CLOSE_PATH; } -static inline fz_rect boundexpand(fz_rect r, fz_point p) +static inline fz_rect bound_expand(fz_rect r, fz_point p) { if (p.x < r.x0) r.x0 = p.x; if (p.y < r.y0) r.y0 = p.y; @@ -115,43 +115,43 @@ static inline fz_rect boundexpand(fz_rect r, fz_point p) } fz_rect -fz_boundpath(fz_path *path, fz_strokestate *stroke, fz_matrix ctm) +fz_bound_path(fz_path *path, fz_stroke_state *stroke, fz_matrix ctm) { fz_point p; - fz_rect r = fz_emptyrect; + fz_rect r = fz_empty_rect; int i = 0; if (path->len) { - p.x = path->els[1].v; - p.y = path->els[2].v; - p = fz_transformpoint(ctm, p); + p.x = path->items[1].v; + p.y = path->items[2].v; + p = fz_transform_point(ctm, p); r.x0 = r.x1 = p.x; r.y0 = r.y1 = p.y; } while (i < path->len) { - switch (path->els[i++].k) + switch (path->items[i++].k) { case FZ_CURVETO: - p.x = path->els[i++].v; - p.y = path->els[i++].v; - r = boundexpand(r, fz_transformpoint(ctm, p)); - p.x = path->els[i++].v; - p.y = path->els[i++].v; - r = boundexpand(r, fz_transformpoint(ctm, p)); - p.x = path->els[i++].v; - p.y = path->els[i++].v; - r = boundexpand(r, fz_transformpoint(ctm, p)); + p.x = path->items[i++].v; + p.y = path->items[i++].v; + r = bound_expand(r, fz_transform_point(ctm, p)); + p.x = path->items[i++].v; + p.y = path->items[i++].v; + r = bound_expand(r, fz_transform_point(ctm, p)); + p.x = path->items[i++].v; + p.y = path->items[i++].v; + r = bound_expand(r, fz_transform_point(ctm, p)); break; case FZ_MOVETO: case FZ_LINETO: - p.x = path->els[i++].v; - p.y = path->els[i++].v; - r = boundexpand(r, fz_transformpoint(ctm, p)); + p.x = path->items[i++].v; + p.y = path->items[i++].v; + r = bound_expand(r, fz_transform_point(ctm, p)); break; - case FZ_CLOSEPATH: + case FZ_CLOSE_PATH: break; } } @@ -171,43 +171,43 @@ fz_boundpath(fz_path *path, fz_strokestate *stroke, fz_matrix ctm) } void -fz_transformpath(fz_path *path, fz_matrix ctm) +fz_transform_path(fz_path *path, fz_matrix ctm) { fz_point p; int k, i = 0; while (i < path->len) { - switch (path->els[i++].k) + switch (path->items[i++].k) { case FZ_CURVETO: for (k = 0; k < 3; k++) { - p.x = path->els[i].v; - p.y = path->els[i+1].v; - p = fz_transformpoint(ctm, p); - path->els[i].v = p.x; - path->els[i+1].v = p.y; + p.x = path->items[i].v; + p.y = path->items[i+1].v; + p = fz_transform_point(ctm, p); + path->items[i].v = p.x; + path->items[i+1].v = p.y; i += 2; } break; case FZ_MOVETO: case FZ_LINETO: - p.x = path->els[i].v; - p.y = path->els[i+1].v; - p = fz_transformpoint(ctm, p); - path->els[i].v = p.x; - path->els[i+1].v = p.y; + p.x = path->items[i].v; + p.y = path->items[i+1].v; + p = fz_transform_point(ctm, p); + path->items[i].v = p.x; + path->items[i+1].v = p.y; i += 2; break; - case FZ_CLOSEPATH: + case FZ_CLOSE_PATH: break; } } } void -fz_debugpath(fz_path *path, int indent) +fz_debug_path(fz_path *path, int indent) { float x, y; int i = 0; @@ -216,30 +216,30 @@ fz_debugpath(fz_path *path, int indent) { for (n = 0; n < indent; n++) putchar(' '); - switch (path->els[i++].k) + switch (path->items[i++].k) { case FZ_MOVETO: - x = path->els[i++].v; - y = path->els[i++].v; + x = path->items[i++].v; + y = path->items[i++].v; printf("%g %g m\n", x, y); break; case FZ_LINETO: - x = path->els[i++].v; - y = path->els[i++].v; + x = path->items[i++].v; + y = path->items[i++].v; printf("%g %g l\n", x, y); break; case FZ_CURVETO: - x = path->els[i++].v; - y = path->els[i++].v; + x = path->items[i++].v; + y = path->items[i++].v; printf("%g %g ", x, y); - x = path->els[i++].v; - y = path->els[i++].v; + x = path->items[i++].v; + y = path->items[i++].v; printf("%g %g ", x, y); - x = path->els[i++].v; - y = path->els[i++].v; + x = path->items[i++].v; + y = path->items[i++].v; printf("%g %g c\n", x, y); break; - case FZ_CLOSEPATH: + case FZ_CLOSE_PATH: printf("h\n"); break; } diff --git a/fitz/res_pixmap.c b/fitz/res_pixmap.c index 85138be1..7e689e07 100644 --- a/fitz/res_pixmap.c +++ b/fitz/res_pixmap.c @@ -1,7 +1,7 @@ #include "fitz.h" fz_pixmap * -fz_newpixmapwithdata(fz_colorspace *colorspace, int x, int y, int w, int h, unsigned char *samples) +fz_new_pixmap_with_data(fz_colorspace *colorspace, int x, int y, int w, int h, unsigned char *samples) { fz_pixmap *pix; @@ -11,75 +11,75 @@ fz_newpixmapwithdata(fz_colorspace *colorspace, int x, int y, int w, int h, unsi pix->y = y; pix->w = w; pix->h = h; - pix->mask = nil; + pix->mask = NULL; pix->interpolate = 1; pix->xres = 96; pix->yres = 96; - pix->colorspace = nil; + pix->colorspace = NULL; pix->n = 1; if (colorspace) { - pix->colorspace = fz_keepcolorspace(colorspace); + pix->colorspace = fz_keep_colorspace(colorspace); pix->n = 1 + colorspace->n; } if (samples) { pix->samples = samples; - pix->freesamples = 0; + pix->free_samples = 0; } else { pix->samples = fz_calloc(pix->h, pix->w * pix->n); - pix->freesamples = 1; + pix->free_samples = 1; } return pix; } fz_pixmap * -fz_newpixmap(fz_colorspace *colorspace, int x, int y, int w, int h) +fz_new_pixmap(fz_colorspace *colorspace, int x, int y, int w, int h) { - return fz_newpixmapwithdata(colorspace, x, y, w, h, nil); + return fz_new_pixmap_with_data(colorspace, x, y, w, h, NULL); } fz_pixmap * -fz_newpixmapwithrect(fz_colorspace *colorspace, fz_bbox r) +fz_new_pixmap_with_rect(fz_colorspace *colorspace, fz_bbox r) { - return fz_newpixmap(colorspace, r.x0, r.y0, r.x1 - r.x0, r.y1 - r.y0); + return fz_new_pixmap(colorspace, r.x0, r.y0, r.x1 - r.x0, r.y1 - r.y0); } fz_pixmap * -fz_keeppixmap(fz_pixmap *pix) +fz_keep_pixmap(fz_pixmap *pix) { pix->refs++; return pix; } void -fz_droppixmap(fz_pixmap *pix) +fz_drop_pixmap(fz_pixmap *pix) { if (pix && --pix->refs == 0) { if (pix->mask) - fz_droppixmap(pix->mask); + fz_drop_pixmap(pix->mask); if (pix->colorspace) - fz_dropcolorspace(pix->colorspace); - if (pix->freesamples) + fz_drop_colorspace(pix->colorspace); + if (pix->free_samples) fz_free(pix->samples); fz_free(pix); } } void -fz_clearpixmap(fz_pixmap *pix) +fz_clear_pixmap(fz_pixmap *pix) { memset(pix->samples, 0, pix->w * pix->h * pix->n); } void -fz_clearpixmapwithcolor(fz_pixmap *pix, int value) +fz_clear_pixmap_with_color(fz_pixmap *pix, int value) { if (value == 255) memset(pix->samples, 255, pix->w * pix->h * pix->n); @@ -100,7 +100,7 @@ fz_clearpixmapwithcolor(fz_pixmap *pix, int value) } void -fz_premultiplypixmap(fz_pixmap *pix) +fz_premultiply_pixmap(fz_pixmap *pix) { unsigned char *s = pix->samples; unsigned char a; @@ -119,7 +119,7 @@ fz_premultiplypixmap(fz_pixmap *pix) } fz_bbox -fz_boundpixmap(fz_pixmap *pix) +fz_bound_pixmap(fz_pixmap *pix) { fz_bbox bbox; bbox.x0 = pix->x; @@ -130,7 +130,7 @@ fz_boundpixmap(fz_pixmap *pix) } fz_pixmap * -fz_alphafromgray(fz_pixmap *gray, int luminosity) +fz_alpha_from_gray(fz_pixmap *gray, int luminosity) { fz_pixmap *alpha; unsigned char *sp, *dp; @@ -138,7 +138,7 @@ fz_alphafromgray(fz_pixmap *gray, int luminosity) assert(gray->n == 2); - alpha = fz_newpixmap(nil, gray->x, gray->y, gray->w, gray->h); + alpha = fz_new_pixmap(NULL, gray->x, gray->y, gray->w, gray->h); dp = alpha->samples; sp = gray->samples; if (!luminosity) @@ -159,7 +159,7 @@ fz_alphafromgray(fz_pixmap *gray, int luminosity) */ fz_error -fz_writepnm(fz_pixmap *pixmap, char *filename) +fz_write_pnm(fz_pixmap *pixmap, char *filename) { FILE *fp; unsigned char *p; @@ -213,7 +213,7 @@ fz_writepnm(fz_pixmap *pixmap, char *filename) */ fz_error -fz_writepam(fz_pixmap *pixmap, char *filename, int savealpha) +fz_write_pam(fz_pixmap *pixmap, char *filename, int savealpha) { unsigned char *sp; int y, w, k; @@ -289,14 +289,14 @@ static void putchunk(char *tag, unsigned char *data, int size, FILE *fp) put32(size, fp); fwrite(tag, 1, 4, fp); fwrite(data, 1, size, fp); - sum = crc32(0, nil, 0); + sum = crc32(0, NULL, 0); sum = crc32(sum, (unsigned char*)tag, 4); sum = crc32(sum, data, size); put32(sum, fp); } fz_error -fz_writepng(fz_pixmap *pixmap, char *filename, int savealpha) +fz_write_png(fz_pixmap *pixmap, char *filename, int savealpha) { static const unsigned char pngsig[8] = { 137, 80, 78, 71, 13, 10, 26, 10 }; FILE *fp; diff --git a/fitz/res_shade.c b/fitz/res_shade.c index e4afa14a..7faff3bf 100644 --- a/fitz/res_shade.c +++ b/fitz/res_shade.c @@ -1,26 +1,26 @@ #include "fitz.h" fz_shade * -fz_keepshade(fz_shade *shade) +fz_keep_shade(fz_shade *shade) { shade->refs ++; return shade; } void -fz_dropshade(fz_shade *shade) +fz_drop_shade(fz_shade *shade) { if (shade && --shade->refs == 0) { if (shade->colorspace) - fz_dropcolorspace(shade->colorspace); + fz_drop_colorspace(shade->colorspace); fz_free(shade->mesh); fz_free(shade); } } fz_rect -fz_boundshade(fz_shade *shade, fz_matrix ctm) +fz_bound_shade(fz_shade *shade, fz_matrix ctm) { float *v; fz_rect r; @@ -28,22 +28,22 @@ fz_boundshade(fz_shade *shade, fz_matrix ctm) int i, ncomp, nvert; ctm = fz_concat(shade->matrix, ctm); - ncomp = shade->usefunction ? 3 : 2 + shade->colorspace->n; - nvert = shade->meshlen / ncomp; + ncomp = shade->use_function ? 3 : 2 + shade->colorspace->n; + nvert = shade->mesh_len / ncomp; v = shade->mesh; if (shade->type == FZ_LINEAR) - return fz_infiniterect; + return fz_infinite_rect; if (shade->type == FZ_RADIAL) - return fz_infiniterect; + return fz_infinite_rect; if (nvert == 0) - return fz_emptyrect; + return fz_empty_rect; p.x = v[0]; p.y = v[1]; v += ncomp; - p = fz_transformpoint(ctm, p); + p = fz_transform_point(ctm, p); r.x0 = r.x1 = p.x; r.y0 = r.y1 = p.y; @@ -51,7 +51,7 @@ fz_boundshade(fz_shade *shade, fz_matrix ctm) { p.x = v[0]; p.y = v[1]; - p = fz_transformpoint(ctm, p); + p = fz_transform_point(ctm, p); v += ncomp; if (p.x < r.x0) r.x0 = p.x; if (p.y < r.y0) r.y0 = p.y; @@ -63,7 +63,7 @@ fz_boundshade(fz_shade *shade, fz_matrix ctm) } void -fz_debugshade(fz_shade *shade) +fz_debug_shade(fz_shade *shade) { int i, j, n; float *vertex; @@ -88,7 +88,7 @@ fz_debugshade(fz_shade *shade) shade->matrix.a, shade->matrix.b, shade->matrix.c, shade->matrix.d, shade->matrix.e, shade->matrix.f); - if (shade->usebackground) + if (shade->use_background) { printf("\tbackground ["); for (i = 0; i < shade->colorspace->n; i++) @@ -96,7 +96,7 @@ fz_debugshade(fz_shade *shade) printf("]\n"); } - if (shade->usefunction) + if (shade->use_function) { printf("\tfunction\n"); n = 3; @@ -104,12 +104,12 @@ fz_debugshade(fz_shade *shade) else n = 2 + shade->colorspace->n; - printf("\tvertices: %d\n", shade->meshlen); + printf("\tvertices: %d\n", shade->mesh_len); vertex = shade->mesh; triangle = 0; i = 0; - while (i < shade->meshlen) + while (i < shade->mesh_len) { printf("\t%d:(%g, %g): ", triangle, vertex[0], vertex[1]); diff --git a/fitz/res_text.c b/fitz/res_text.c index 8ba62669..d38637f1 100644 --- a/fitz/res_text.c +++ b/fitz/res_text.c @@ -1,48 +1,48 @@ #include "fitz.h" fz_text * -fz_newtext(fz_font *font, fz_matrix trm, int wmode) +fz_new_text(fz_font *font, fz_matrix trm, int wmode) { fz_text *text; text = fz_malloc(sizeof(fz_text)); - text->font = fz_keepfont(font); + text->font = fz_keep_font(font); text->trm = trm; text->wmode = wmode; text->len = 0; text->cap = 0; - text->els = nil; + text->items = NULL; return text; } void -fz_freetext(fz_text *text) +fz_free_text(fz_text *text) { - fz_dropfont(text->font); - fz_free(text->els); + fz_drop_font(text->font); + fz_free(text->items); fz_free(text); } fz_text * -fz_clonetext(fz_text *old) +fz_clone_text(fz_text *old) { fz_text *text; text = fz_malloc(sizeof(fz_text)); - text->font = fz_keepfont(old->font); + text->font = fz_keep_font(old->font); text->trm = old->trm; text->wmode = old->wmode; text->len = old->len; text->cap = text->len; - text->els = fz_calloc(text->len, sizeof(fz_textel)); - memcpy(text->els, old->els, text->len * sizeof(fz_textel)); + text->items = fz_calloc(text->len, sizeof(fz_text_item)); + memcpy(text->items, old->items, text->len * sizeof(fz_text_item)); return text; } fz_rect -fz_boundtext(fz_text *text, fz_matrix ctm) +fz_bound_text(fz_text *text, fz_matrix ctm) { fz_matrix trm; fz_rect bbox; @@ -50,22 +50,22 @@ fz_boundtext(fz_text *text, fz_matrix ctm) int i; if (text->len == 0) - return fz_emptyrect; + return fz_empty_rect; /* find bbox of glyph origins in ctm space */ - bbox.x0 = bbox.x1 = text->els[0].x; - bbox.y0 = bbox.y1 = text->els[0].y; + bbox.x0 = bbox.x1 = text->items[0].x; + bbox.y0 = bbox.y1 = text->items[0].y; for (i = 1; i < text->len; i++) { - bbox.x0 = MIN(bbox.x0, text->els[i].x); - bbox.y0 = MIN(bbox.y0, text->els[i].y); - bbox.x1 = MAX(bbox.x1, text->els[i].x); - bbox.y1 = MAX(bbox.y1, text->els[i].y); + bbox.x0 = MIN(bbox.x0, text->items[i].x); + bbox.y0 = MIN(bbox.y0, text->items[i].y); + bbox.x1 = MAX(bbox.x1, text->items[i].x); + bbox.y1 = MAX(bbox.y1, text->items[i].y); } - bbox = fz_transformrect(ctm, bbox); + bbox = fz_transform_rect(ctm, bbox); /* find bbox of font in trm * ctm space */ @@ -78,7 +78,7 @@ fz_boundtext(fz_text *text, fz_matrix ctm) fbox.x1 = text->font->bbox.x1 * 0.001f; fbox.y1 = text->font->bbox.y1 * 0.001f; - fbox = fz_transformrect(trm, fbox); + fbox = fz_transform_rect(trm, fbox); /* expand glyph origin bbox by font bbox */ @@ -91,23 +91,23 @@ fz_boundtext(fz_text *text, fz_matrix ctm) } static void -fz_growtext(fz_text *text, int n) +fz_grow_text(fz_text *text, int n) { if (text->len + n < text->cap) return; while (text->len + n > text->cap) text->cap = text->cap + 36; - text->els = fz_realloc(text->els, text->cap, sizeof(fz_textel)); + text->items = fz_realloc(text->items, text->cap, sizeof(fz_text_item)); } void -fz_addtext(fz_text *text, int gid, int ucs, float x, float y) +fz_add_text(fz_text *text, int gid, int ucs, float x, float y) { - fz_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; + fz_grow_text(text, 1); + text->items[text->len].ucs = ucs; + text->items[text->len].gid = gid; + text->items[text->len].x = x; + text->items[text->len].y = y; text->len++; } @@ -116,18 +116,18 @@ static int isxmlmeta(int c) return c < 32 || c >= 128 || c == '&' || c == '<' || c == '>' || c == '\'' || c == '"'; } -void fz_debugtext(fz_text *text, int indent) +void fz_debug_text(fz_text *text, int indent) { int i, n; for (i = 0; i < text->len; i++) { for (n = 0; n < indent; n++) putchar(' '); - if (!isxmlmeta(text->els[i].ucs)) + if (!isxmlmeta(text->items[i].ucs)) printf("\n", - text->els[i].ucs, text->els[i].gid, text->els[i].x, text->els[i].y); + text->items[i].ucs, text->items[i].gid, text->items[i].x, text->items[i].y); else printf("\n", - text->els[i].ucs, text->els[i].gid, text->els[i].x, text->els[i].y); + text->items[i].ucs, text->items[i].gid, text->items[i].x, text->items[i].y); } } diff --git a/fitz/stm_buffer.c b/fitz/stm_buffer.c index 9b1ee469..4c7410c3 100644 --- a/fitz/stm_buffer.c +++ b/fitz/stm_buffer.c @@ -1,7 +1,7 @@ #include "fitz.h" fz_buffer * -fz_newbuffer(int size) +fz_new_buffer(int size) { fz_buffer *b; @@ -17,14 +17,14 @@ fz_newbuffer(int size) } fz_buffer * -fz_keepbuffer(fz_buffer *buf) +fz_keep_buffer(fz_buffer *buf) { buf->refs ++; return buf; } void -fz_dropbuffer(fz_buffer *buf) +fz_drop_buffer(fz_buffer *buf) { if (--buf->refs == 0) { @@ -34,7 +34,7 @@ fz_dropbuffer(fz_buffer *buf) } void -fz_resizebuffer(fz_buffer *buf, int size) +fz_resize_buffer(fz_buffer *buf, int size) { buf->data = fz_realloc(buf->data, size, 1); buf->cap = size; @@ -43,7 +43,7 @@ fz_resizebuffer(fz_buffer *buf, int size) } void -fz_growbuffer(fz_buffer *buf) +fz_grow_buffer(fz_buffer *buf) { - fz_resizebuffer(buf, (buf->cap * 3) / 2); + fz_resize_buffer(buf, (buf->cap * 3) / 2); } diff --git a/fitz/stm_open.c b/fitz/stm_open.c index c7cf8409..74346f73 100644 --- a/fitz/stm_open.c +++ b/fitz/stm_open.c @@ -1,7 +1,7 @@ #include "fitz.h" fz_stream * -fz_newstream(void *state, +fz_new_stream(void *state, int(*read)(fz_stream *stm, unsigned char *buf, int len), void(*close)(fz_stream *stm)) { @@ -25,13 +25,13 @@ fz_newstream(void *state, stm->state = state; stm->read = read; stm->close = close; - stm->seek = nil; + stm->seek = NULL; return stm; } fz_stream * -fz_keepstream(fz_stream *stm) +fz_keep_stream(fz_stream *stm) { stm->refs ++; return stm; @@ -51,7 +51,7 @@ fz_close(fz_stream *stm) /* File stream */ -static int readfile(fz_stream *stm, unsigned char *buf, int len) +static int read_file(fz_stream *stm, unsigned char *buf, int len) { int n = read(*(int*)stm->state, buf, len); if (n < 0) @@ -59,7 +59,7 @@ static int readfile(fz_stream *stm, unsigned char *buf, int len) return n; } -static void seekfile(fz_stream *stm, int offset, int whence) +static void seek_file(fz_stream *stm, int offset, int whence) { int n = lseek(*(int*)stm->state, offset, whence); if (n < 0) @@ -69,7 +69,7 @@ static void seekfile(fz_stream *stm, int offset, int whence) stm->wp = stm->bp; } -static void closefile(fz_stream *stm) +static void close_file(fz_stream *stm) { int n = close(*(int*)stm->state); if (n < 0) @@ -78,7 +78,7 @@ static void closefile(fz_stream *stm) } fz_stream * -fz_openfd(int fd) +fz_open_fd(int fd) { fz_stream *stm; int *state; @@ -86,40 +86,40 @@ fz_openfd(int fd) state = fz_malloc(sizeof(int)); *state = fd; - stm = fz_newstream(state, readfile, closefile); - stm->seek = seekfile; + stm = fz_new_stream(state, read_file, close_file); + stm->seek = seek_file; return stm; } fz_stream * -fz_openfile(const char *name) +fz_open_file(const char *name) { int fd = open(name, O_BINARY | O_RDONLY, 0); if (fd == -1) - return nil; - return fz_openfd(fd); + return NULL; + return fz_open_fd(fd); } #ifdef _WIN32 fz_stream * -fz_openfilew(const wchar_t *name) +fz_open_file_w(const wchar_t *name) { int fd = _wopen(name, O_BINARY | O_RDONLY, 0); if (fd == -1) - return nil; - return fz_openfd(fd); + return NULL; + return fz_open_fd(fd); } #endif /* Memory stream */ -static int readbuffer(fz_stream *stm, unsigned char *buf, int len) +static int read_buffer(fz_stream *stm, unsigned char *buf, int len) { return 0; } -static void seekbuffer(fz_stream *stm, int offset, int whence) +static void seek_buffer(fz_stream *stm, int offset, int whence) { if (whence == 0) stm->rp = stm->bp + offset; @@ -131,19 +131,19 @@ static void seekbuffer(fz_stream *stm, int offset, int whence) stm->wp = stm->ep; } -static void closebuffer(fz_stream *stm) +static void close_buffer(fz_stream *stm) { if (stm->state) - fz_dropbuffer(stm->state); + fz_drop_buffer(stm->state); } fz_stream * -fz_openbuffer(fz_buffer *buf) +fz_open_buffer(fz_buffer *buf) { fz_stream *stm; - stm = fz_newstream(fz_keepbuffer(buf), readbuffer, closebuffer); - stm->seek = seekbuffer; + stm = fz_new_stream(fz_keep_buffer(buf), read_buffer, close_buffer); + stm->seek = seek_buffer; stm->bp = buf->data; stm->rp = buf->data; @@ -156,12 +156,12 @@ fz_openbuffer(fz_buffer *buf) } fz_stream * -fz_openmemory(unsigned char *data, int len) +fz_open_memory(unsigned char *data, int len) { fz_stream *stm; - stm = fz_newstream(nil, readbuffer, closebuffer); - stm->seek = seekbuffer; + stm = fz_new_stream(NULL, read_buffer, close_buffer); + stm->seek = seek_buffer; stm->bp = data; stm->rp = data; diff --git a/fitz/stm_read.c b/fitz/stm_read.c index 10626e5d..4a81b9cd 100644 --- a/fitz/stm_read.c +++ b/fitz/stm_read.c @@ -67,7 +67,7 @@ fz_read(fz_stream *stm, unsigned char *buf, int len) } void -fz_fillbuffer(fz_stream *stm) +fz_fill_buffer(fz_stream *stm) { int n; @@ -95,7 +95,7 @@ fz_fillbuffer(fz_stream *stm) } fz_error -fz_readall(fz_buffer **bufp, fz_stream *stm, int initial) +fz_read_all(fz_buffer **bufp, fz_stream *stm, int initial) { fz_buffer *buf; int n; @@ -103,23 +103,23 @@ fz_readall(fz_buffer **bufp, fz_stream *stm, int initial) if (initial < 1024) initial = 1024; - buf = fz_newbuffer(initial); + buf = fz_new_buffer(initial); while (1) { if (buf->len == buf->cap) - fz_growbuffer(buf); + fz_grow_buffer(buf); if (buf->len / 200 > initial) { - fz_dropbuffer(buf); + fz_drop_buffer(buf); return fz_throw("compression bomb detected"); } n = fz_read(stm, buf->data + buf->len, buf->cap - buf->len); if (n < 0) { - fz_dropbuffer(buf); + fz_drop_buffer(buf); return fz_rethrow(n, "read error"); } if (n == 0) @@ -133,19 +133,19 @@ fz_readall(fz_buffer **bufp, fz_stream *stm, int initial) } void -fz_readline(fz_stream *stm, char *mem, int n) +fz_read_line(fz_stream *stm, char *mem, int n) { char *s = mem; int c = EOF; while (n > 1) { - c = fz_readbyte(stm); + c = fz_read_byte(stm); if (c == EOF) break; if (c == '\r') { - c = fz_peekbyte(stm); + c = fz_peek_byte(stm); if (c == '\n') - fz_readbyte(stm); + fz_read_byte(stm); break; } if (c == '\n') @@ -184,7 +184,7 @@ fz_seek(fz_stream *stm, int offset, int whence) fz_warn("cannot seek backwards"); /* dog slow, but rare enough */ while (offset-- > 0) - fz_readbyte(stm); + fz_read_byte(stm); } else fz_warn("cannot seek"); diff --git a/pdf/cmapdump.c b/pdf/cmapdump.c index c609058c..94f3c140 100644 --- a/pdf/cmapdump.c +++ b/pdf/cmapdump.c @@ -75,11 +75,11 @@ main(int argc, char **argv) strcpy(name, realname); clean(name); - fi = fz_openfile(argv[i]); + fi = fz_open_file(argv[i]); if (!fi) fz_throw("cmapdump: could not open input file '%s'\n", argv[i]); - error = pdf_parsecmap(&cmap, fi); + error = pdf_parse_cmap(&cmap, fi); if (error) { fz_catch(error, "cmapdump: could not parse input cmap '%s'\n", argv[i]); @@ -96,7 +96,7 @@ main(int argc, char **argv) if (k % 4 == 0) fprintf(fo, "\n"); fprintf(fo, "{%d,%d,%d},", - cmap->ranges[k].low, cmap->ranges[k].extentflags, cmap->ranges[k].offset); + cmap->ranges[k].low, cmap->ranges[k].extent_flags, cmap->ranges[k].offset); } fprintf(fo, "\n};\n\n"); @@ -119,18 +119,18 @@ main(int argc, char **argv) fprintf(fo, "pdf_cmap pdf_cmap_%s = {\n", name); fprintf(fo, "\t-1, "); - fprintf(fo, "\"%s\", ", cmap->cmapname); - fprintf(fo, "\"%s\", 0, ", cmap->usecmapname); + fprintf(fo, "\"%s\", ", cmap->cmap_name); + fprintf(fo, "\"%s\", 0, ", cmap->usecmap_name); fprintf(fo, "%d, ", cmap->wmode); - fprintf(fo, "%d,\n\t{ ", cmap->ncspace); - if (cmap->ncspace == 0) + fprintf(fo, "%d,\n\t{ ", cmap->codespace_len); + if (cmap->codespace_len == 0) { fprintf(fo, "{0,0,0},"); } - for (k = 0; k < cmap->ncspace; k++) + for (k = 0; k < cmap->codespace_len; k++) { fprintf(fo, "{%d,%d,%d},", - cmap->cspace[k].n, cmap->cspace[k].low, cmap->cspace[k].high); + cmap->codespace[k].n, cmap->codespace[k].low, cmap->codespace[k].high); } fprintf(fo, " },\n"); diff --git a/pdf/fontdump.c b/pdf/fontdump.c index b40558dd..37572bea 100644 --- a/pdf/fontdump.c +++ b/pdf/fontdump.c @@ -23,7 +23,6 @@ hexdump(FILE *fo, FILE *fi) return n; } - int main(int argc, char **argv) { diff --git a/pdf/mupdf.h b/pdf/mupdf.h index 4184a59f..96ac2da3 100644 --- a/pdf/mupdf.h +++ b/pdf/mupdf.h @@ -7,12 +7,12 @@ typedef struct pdf_xref_s pdf_xref; -void pdf_logxref(char *fmt, ...); -void pdf_logrsrc(char *fmt, ...); -void pdf_logfont(char *fmt, ...); -void pdf_logimage(char *fmt, ...); -void pdf_logshade(char *fmt, ...); -void pdf_logpage(char *fmt, ...); +void pdf_log_xref(char *fmt, ...); +void pdf_log_rsrc(char *fmt, ...); +void pdf_log_font(char *fmt, ...); +void pdf_log_image(char *fmt, ...); +void pdf_log_shade(char *fmt, ...); +void pdf_log_page(char *fmt, ...); /* * tokenizer and low-level object parser @@ -20,32 +20,32 @@ void pdf_logpage(char *fmt, ...); enum { - PDF_TERROR, PDF_TEOF, - PDF_TOARRAY, PDF_TCARRAY, - PDF_TODICT, PDF_TCDICT, - PDF_TOBRACE, PDF_TCBRACE, - PDF_TNAME, PDF_TINT, PDF_TREAL, PDF_TSTRING, PDF_TKEYWORD, - PDF_TR, PDF_TTRUE, PDF_TFALSE, PDF_TNULL, - PDF_TOBJ, PDF_TENDOBJ, - PDF_TSTREAM, PDF_TENDSTREAM, - PDF_TXREF, PDF_TTRAILER, PDF_TSTARTXREF, - PDF_NTOKENS + PDF_TOK_ERROR, PDF_TOK_EOF, + PDF_TOK_OPEN_ARRAY, PDF_TOK_CLOSE_ARRAY, + PDF_TOK_OPEN_DICT, PDF_TOK_CLOSE_DICT, + PDF_TOK_OPEN_BRACE, PDF_TOK_CLOSE_BRACE, + PDF_TOK_NAME, PDF_TOK_INT, PDF_TOK_REAL, PDF_TOK_STRING, PDF_TOK_KEYWORD, + PDF_TOK_R, PDF_TOK_TRUE, PDF_TOK_FALSE, PDF_TOK_NULL, + PDF_TOK_OBJ, PDF_TOK_ENDOBJ, + PDF_TOK_STREAM, PDF_TOK_ENDSTREAM, + PDF_TOK_XREF, PDF_TOK_TRAILER, PDF_TOK_STARTXREF, + PDF_NUM_TOKENS }; /* lex.c */ fz_error pdf_lex(int *tok, fz_stream *f, char *buf, int n, int *len); /* parse.c */ -fz_error pdf_parsearray(fz_obj **op, pdf_xref *xref, fz_stream *f, char *buf, int cap); -fz_error pdf_parsedict(fz_obj **op, pdf_xref *xref, fz_stream *f, char *buf, int cap); -fz_error pdf_parsestmobj(fz_obj **op, pdf_xref *xref, fz_stream *f, char *buf, int cap); -fz_error pdf_parseindobj(fz_obj **op, pdf_xref *xref, fz_stream *f, char *buf, int cap, int *num, int *gen, int *stmofs); +fz_error pdf_parse_array(fz_obj **op, pdf_xref *xref, fz_stream *f, char *buf, int cap); +fz_error pdf_parse_dict(fz_obj **op, pdf_xref *xref, fz_stream *f, char *buf, int cap); +fz_error pdf_parse_stm_obj(fz_obj **op, pdf_xref *xref, fz_stream *f, char *buf, int cap); +fz_error pdf_parse_ind_obj(fz_obj **op, pdf_xref *xref, fz_stream *f, char *buf, int cap, int *num, int *gen, int *stm_ofs); -fz_rect pdf_torect(fz_obj *array); -fz_matrix pdf_tomatrix(fz_obj *array); -char *pdf_toutf8(fz_obj *src); -unsigned short *pdf_toucs2(fz_obj *src); -fz_obj *pdf_toutf8name(fz_obj *src); +fz_rect pdf_to_rect(fz_obj *array); +fz_matrix pdf_to_matrix(fz_obj *array); +char *pdf_to_utf8(fz_obj *src); +unsigned short *pdf_to_ucs2(fz_obj *src); +fz_obj *pdf_to_utf8_name(fz_obj *src); /* * Encryption @@ -63,7 +63,7 @@ fz_obj *pdf_toutf8name(fz_obj *src); #define PDF_DEFAULT_PERM_FLAGS 0xfffc typedef struct pdf_crypt_s pdf_crypt; -typedef struct pdf_cryptfilter_s pdf_cryptfilter; +typedef struct pdf_crypt_filter_s pdf_crypt_filter; enum { @@ -74,7 +74,7 @@ enum PDF_CRYPT_UNKNOWN, }; -struct pdf_cryptfilter_s +struct pdf_crypt_filter_s { int method; int length; @@ -82,14 +82,14 @@ struct pdf_cryptfilter_s struct pdf_crypt_s { - unsigned char idstring[32]; - int idlength; + unsigned char id_string[32]; + int id_length; int v; int length; fz_obj *cf; - pdf_cryptfilter stmf; - pdf_cryptfilter strf; + pdf_crypt_filter stmf; + pdf_crypt_filter strf; int r; unsigned char o[48]; @@ -97,35 +97,35 @@ struct pdf_crypt_s unsigned char oe[32]; unsigned char ue[32]; int p; - int encryptmetadata; + int encrypt_metadata; unsigned char key[32]; /* decryption key generated from password */ }; /* crypt.c */ -fz_error pdf_newcrypt(pdf_crypt **cp, fz_obj *enc, fz_obj *id); -void pdf_freecrypt(pdf_crypt *crypt); +fz_error pdf_new_crypt(pdf_crypt **cp, fz_obj *enc, fz_obj *id); +void pdf_free_crypt(pdf_crypt *crypt); -fz_error pdf_parsecryptfilter(pdf_cryptfilter *cf, fz_obj *dict, int defaultlength); -fz_stream *pdf_opencrypt(fz_stream *chain, pdf_crypt *crypt, pdf_cryptfilter *cf, int num, int gen); -void pdf_cryptobj(pdf_crypt *crypt, fz_obj *obj, int num, int gen); +fz_error pdf_parse_crypt_filter(pdf_crypt_filter *cf, fz_obj *dict, int defaultlength); +fz_stream *pdf_open_crypt(fz_stream *chain, pdf_crypt *crypt, pdf_crypt_filter *cf, int num, int gen); +void pdf_crypt_obj(pdf_crypt *crypt, fz_obj *obj, int num, int gen); -int pdf_needspassword(pdf_xref *xref); -int pdf_authenticatepassword(pdf_xref *xref, char *pw); +int pdf_needs_password(pdf_xref *xref); +int pdf_authenticate_password(pdf_xref *xref, char *pw); -void pdf_debugcrypt(pdf_crypt *crypt); +void pdf_debug_crypt(pdf_crypt *crypt); /* * xref and object / stream api */ -typedef struct pdf_xrefentry_s pdf_xrefentry; +typedef struct pdf_xref_entry_s pdf_xref_entry; -struct pdf_xrefentry_s +struct pdf_xref_entry_s { int ofs; /* file offset / objstm object number */ int gen; /* generation / objstm index */ - int stmofs; /* on-disk stream */ + int stm_ofs; /* on-disk stream */ fz_obj *obj; /* stored/cached object */ int type; /* 0=unset (f)ree i(n)use (o)bjstm */ }; @@ -135,45 +135,45 @@ struct pdf_xref_s fz_stream *file; int version; int startxref; - int filesize; + int file_size; pdf_crypt *crypt; fz_obj *trailer; int len; - pdf_xrefentry *table; + pdf_xref_entry *table; - int pagelen; - int pagecap; - fz_obj **pageobjs; - fz_obj **pagerefs; + int page_len; + int page_cap; + fz_obj **page_objs; + fz_obj **page_refs; struct pdf_store_s *store; char scratch[65536]; }; -fz_obj *pdf_resolveindirect(fz_obj *ref); -fz_error pdf_cacheobject(pdf_xref *, int num, int gen); -fz_error pdf_loadobject(fz_obj **objp, pdf_xref *, int num, int gen); -void pdf_updateobject( pdf_xref *xref, int num, int gen, fz_obj *newobj); +fz_obj *pdf_resolve_indirect(fz_obj *ref); +fz_error pdf_cache_object(pdf_xref *, int num, int gen); +fz_error pdf_load_object(fz_obj **objp, pdf_xref *, int num, int gen); +void pdf_update_object( pdf_xref *xref, int num, int gen, fz_obj *newobj); -int pdf_isstream(pdf_xref *xref, int num, int gen); -fz_stream *pdf_openinlinestream(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int length); -fz_error pdf_loadrawstream(fz_buffer **bufp, pdf_xref *xref, int num, int gen); -fz_error pdf_loadstream(fz_buffer **bufp, pdf_xref *xref, int num, int gen); -fz_error pdf_openrawstream(fz_stream **stmp, pdf_xref *, int num, int gen); -fz_error pdf_openstream(fz_stream **stmp, pdf_xref *, int num, int gen); -fz_error pdf_openstreamat(fz_stream **stmp, pdf_xref *xref, int num, int gen, fz_obj *dict, int stmofs); +int pdf_is_stream(pdf_xref *xref, int num, int gen); +fz_stream *pdf_open_inline_stream(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int length); +fz_error pdf_load_raw_stream(fz_buffer **bufp, pdf_xref *xref, int num, int gen); +fz_error pdf_load_stream(fz_buffer **bufp, pdf_xref *xref, int num, int gen); +fz_error pdf_open_raw_stream(fz_stream **stmp, pdf_xref *, int num, int gen); +fz_error pdf_open_stream(fz_stream **stmp, pdf_xref *, int num, int gen); +fz_error pdf_open_stream_at(fz_stream **stmp, pdf_xref *xref, int num, int gen, fz_obj *dict, int stm_ofs); -fz_error pdf_openxrefwithstream(pdf_xref **xrefp, fz_stream *file, char *password); -fz_error pdf_openxref(pdf_xref **xrefp, char *filename, char *password); -void pdf_freexref(pdf_xref *); +fz_error pdf_open_xref_with_stream(pdf_xref **xrefp, fz_stream *file, char *password); +fz_error pdf_open_xref(pdf_xref **xrefp, char *filename, char *password); +void pdf_free_xref(pdf_xref *); /* private */ -fz_error pdf_repairxref(pdf_xref *xref, char *buf, int bufsize); -fz_error pdf_repairobjstms(pdf_xref *xref); -void pdf_debugxref(pdf_xref *); -void pdf_resizexref(pdf_xref *xref, int newcap); +fz_error pdf_repair_xref(pdf_xref *xref, char *buf, int bufsize); +fz_error pdf_repair_obj_stms(pdf_xref *xref); +void pdf_debug_xref(pdf_xref *); +void pdf_resize_xref(pdf_xref *xref, int newcap); /* * Resource store @@ -181,14 +181,14 @@ void pdf_resizexref(pdf_xref *xref, int newcap); typedef struct pdf_store_s pdf_store; -pdf_store *pdf_newstore(void); -void pdf_freestore(pdf_store *store); -void pdf_debugstore(pdf_store *store); +pdf_store *pdf_new_store(void); +void pdf_free_store(pdf_store *store); +void pdf_debug_store(pdf_store *store); -void pdf_storeitem(pdf_store *store, void *keepfn, void *dropfn, fz_obj *key, void *val); -void *pdf_finditem(pdf_store *store, void *dropfn, fz_obj *key); -void pdf_removeitem(pdf_store *store, void *dropfn, fz_obj *key); -void pdf_agestore(pdf_store *store, int maxage); +void pdf_store_item(pdf_store *store, void *keepfn, void *dropfn, fz_obj *key, void *val); +void *pdf_find_item(pdf_store *store, void *dropfn, fz_obj *key); +void pdf_remove_item(pdf_store *store, void *dropfn, fz_obj *key); +void pdf_age_store(pdf_store *store, int maxage); /* * Functions @@ -196,17 +196,17 @@ void pdf_agestore(pdf_store *store, int maxage); typedef struct pdf_function_s pdf_function; -fz_error pdf_loadfunction(pdf_function **func, pdf_xref *xref, fz_obj *ref); -void pdf_evalfunction(pdf_function *func, float *in, int inlen, float *out, int outlen); -pdf_function *pdf_keepfunction(pdf_function *func); -void pdf_dropfunction(pdf_function *func); +fz_error pdf_load_function(pdf_function **func, pdf_xref *xref, fz_obj *ref); +void pdf_eval_function(pdf_function *func, float *in, int inlen, float *out, int outlen); +pdf_function *pdf_keep_function(pdf_function *func); +void pdf_drop_function(pdf_function *func); /* * Colorspace */ -fz_error pdf_loadcolorspace(fz_colorspace **csp, pdf_xref *xref, fz_obj *obj); -fz_pixmap *pdf_expandindexedpixmap(fz_pixmap *src); +fz_error pdf_load_colorspace(fz_colorspace **csp, pdf_xref *xref, fz_obj *obj); +fz_pixmap *pdf_expand_indexed_pixmap(fz_pixmap *src); /* * Pattern @@ -226,15 +226,15 @@ struct pdf_pattern_s fz_buffer *contents; }; -fz_error pdf_loadpattern(pdf_pattern **patp, pdf_xref *xref, fz_obj *obj); -pdf_pattern *pdf_keeppattern(pdf_pattern *pat); -void pdf_droppattern(pdf_pattern *pat); +fz_error pdf_load_pattern(pdf_pattern **patp, pdf_xref *xref, fz_obj *obj); +pdf_pattern *pdf_keep_pattern(pdf_pattern *pat); +void pdf_drop_pattern(pdf_pattern *pat); /* * Shading */ -fz_error pdf_loadshading(fz_shade **shadep, pdf_xref *xref, fz_obj *obj); +fz_error pdf_load_shading(fz_shade **shadep, pdf_xref *xref, fz_obj *obj); /* * XObject @@ -255,17 +255,17 @@ struct pdf_xobject_s fz_buffer *contents; }; -fz_error pdf_loadxobject(pdf_xobject **xobjp, pdf_xref *xref, fz_obj *obj); -pdf_xobject *pdf_keepxobject(pdf_xobject *xobj); -void pdf_dropxobject(pdf_xobject *xobj); +fz_error pdf_load_xobject(pdf_xobject **xobjp, pdf_xref *xref, fz_obj *obj); +pdf_xobject *pdf_keep_xobject(pdf_xobject *xobj); +void pdf_drop_xobject(pdf_xobject *xobj); /* * Image */ -fz_error pdf_loadinlineimage(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz_stream *file); -fz_error pdf_loadimage(fz_pixmap **imgp, pdf_xref *xref, fz_obj *obj); -int pdf_isjpximage(fz_obj *dict); +fz_error pdf_load_inline_image(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz_stream *file); +fz_error pdf_load_image(fz_pixmap **imgp, pdf_xref *xref, fz_obj *obj); +int pdf_is_jpx_image(fz_obj *dict); /* * CMap @@ -282,27 +282,27 @@ struct pdf_range_s /* Next, we pack 2 fields into the same unsigned short. Top 14 bits * are the extent, bottom 2 bits are flags: single, range, table, * multi */ - unsigned short extentflags; + unsigned short extent_flags; unsigned short offset; /* range-delta or table-index */ }; struct pdf_cmap_s { int refs; - char cmapname[32]; + char cmap_name[32]; - char usecmapname[32]; + char usecmap_name[32]; pdf_cmap *usecmap; int wmode; - int ncspace; + int codespace_len; struct { unsigned short n; unsigned short low; unsigned short high; - } cspace[40]; + } codespace[40]; int rlen, rcap; pdf_range *ranges; @@ -311,50 +311,50 @@ struct pdf_cmap_s unsigned short *table; }; -extern pdf_cmap *pdf_cmaptable[]; /* list of builtin system cmaps */ +extern pdf_cmap *pdf_cmap_table[]; /* list of builtin system cmaps */ -pdf_cmap *pdf_newcmap(void); -pdf_cmap *pdf_keepcmap(pdf_cmap *cmap); -void pdf_dropcmap(pdf_cmap *cmap); +pdf_cmap *pdf_new_cmap(void); +pdf_cmap *pdf_keep_cmap(pdf_cmap *cmap); +void pdf_drop_cmap(pdf_cmap *cmap); -void pdf_debugcmap(pdf_cmap *cmap); -int pdf_getwmode(pdf_cmap *cmap); -void pdf_setwmode(pdf_cmap *cmap, int wmode); -void pdf_setusecmap(pdf_cmap *cmap, pdf_cmap *usecmap); +void pdf_debug_cmap(pdf_cmap *cmap); +int pdf_get_wmode(pdf_cmap *cmap); +void pdf_set_wmode(pdf_cmap *cmap, int wmode); +void pdf_set_usecmap(pdf_cmap *cmap, pdf_cmap *usecmap); -void pdf_addcodespace(pdf_cmap *cmap, int low, int high, int n); -void pdf_maprangetotable(pdf_cmap *cmap, int low, int *map, int len); -void pdf_maprangetorange(pdf_cmap *cmap, int srclo, int srchi, int dstlo); -void pdf_maponetomany(pdf_cmap *cmap, int one, int *many, int len); -void pdf_sortcmap(pdf_cmap *cmap); +void pdf_add_codespace(pdf_cmap *cmap, int low, int high, int n); +void pdf_map_range_to_table(pdf_cmap *cmap, int low, int *map, int len); +void pdf_map_range_to_range(pdf_cmap *cmap, int srclo, int srchi, int dstlo); +void pdf_map_one_to_many(pdf_cmap *cmap, int one, int *many, int len); +void pdf_sort_cmap(pdf_cmap *cmap); -int pdf_lookupcmap(pdf_cmap *cmap, int cpt); -int pdf_lookupcmapfull(pdf_cmap *cmap, int cpt, int *out); -unsigned char *pdf_decodecmap(pdf_cmap *cmap, unsigned char *s, int *cpt); +int pdf_lookup_cmap(pdf_cmap *cmap, int cpt); +int pdf_lookup_cmap_full(pdf_cmap *cmap, int cpt, int *out); +unsigned char *pdf_decode_cmap(pdf_cmap *cmap, unsigned char *s, int *cpt); -pdf_cmap *pdf_newidentitycmap(int wmode, int bytes); -fz_error pdf_parsecmap(pdf_cmap **cmapp, fz_stream *file); -fz_error pdf_loadembeddedcmap(pdf_cmap **cmapp, pdf_xref *xref, fz_obj *ref); -fz_error pdf_loadsystemcmap(pdf_cmap **cmapp, char *name); +pdf_cmap *pdf_new_identity_cmap(int wmode, int bytes); +fz_error pdf_parse_cmap(pdf_cmap **cmapp, fz_stream *file); +fz_error pdf_load_embedded_cmap(pdf_cmap **cmapp, pdf_xref *xref, fz_obj *ref); +fz_error pdf_load_system_cmap(pdf_cmap **cmapp, char *name); /* * Font */ -void pdf_loadencoding(char **estrings, char *encoding); -int pdf_lookupagl(char *name); -char **pdf_lookupaglnames(int ucs); +void pdf_load_encoding(char **estrings, char *encoding); +int pdf_lookup_agl(char *name); +char **pdf_lookup_agl_names(int ucs); -extern const unsigned short pdf_docencoding[256]; -extern const char * const pdf_macroman[256]; -extern const char * const pdf_macexpert[256]; -extern const char * const pdf_winansi[256]; +extern const unsigned short pdf_doc_encoding[256]; +extern const char * const pdf_mac_roman[256]; +extern const char * const pdf_mac_expert[256]; +extern const char * const pdf_win_ansi[256]; extern const char * const pdf_standard[256]; extern const char * const pdf_expert[256]; extern const char * const pdf_symbol[256]; extern const char * const pdf_zapfdingbats[256]; -typedef struct pdf_fontdesc_s pdf_fontdesc; +typedef struct pdf_font_desc_s pdf_font_desc; typedef struct pdf_hmtx_s pdf_hmtx; typedef struct pdf_vmtx_s pdf_vmtx; @@ -374,7 +374,7 @@ struct pdf_vmtx_s short w; }; -struct pdf_fontdesc_s +struct pdf_font_desc_s { int refs; @@ -382,32 +382,32 @@ struct pdf_fontdesc_s /* FontDescriptor */ int flags; - float italicangle; + float italic_angle; float ascent; float descent; - float capheight; - float xheight; - float missingwidth; + float cap_height; + float x_height; + float missing_width; /* Encoding (CMap) */ pdf_cmap *encoding; - pdf_cmap *tottfcmap; - int ncidtogid; - unsigned short *cidtogid; + pdf_cmap *to_ttf_cmap; + int cid_to_gid_len; + unsigned short *cid_to_gid; /* ToUnicode */ - pdf_cmap *tounicode; - int ncidtoucs; - unsigned short *cidtoucs; + pdf_cmap *to_unicode; + int cid_to_ucs_len; + unsigned short *cid_to_ucs; /* Metrics (given in the PDF file) */ int wmode; - int nhmtx, hmtxcap; + int hmtx_len, hmtx_cap; pdf_hmtx dhmtx; pdf_hmtx *hmtx; - int nvmtx, vmtxcap; + int vmtx_len, vmtx_cap; pdf_vmtx dvmtx; pdf_vmtx *vmtx; @@ -415,35 +415,35 @@ struct pdf_fontdesc_s }; /* fontmtx.c */ -void pdf_setfontwmode(pdf_fontdesc *font, int wmode); -void pdf_setdefaulthmtx(pdf_fontdesc *font, int w); -void pdf_setdefaultvmtx(pdf_fontdesc *font, int y, int w); -void pdf_addhmtx(pdf_fontdesc *font, int lo, int hi, int w); -void pdf_addvmtx(pdf_fontdesc *font, int lo, int hi, int x, int y, int w); -void pdf_endhmtx(pdf_fontdesc *font); -void pdf_endvmtx(pdf_fontdesc *font); -pdf_hmtx pdf_gethmtx(pdf_fontdesc *font, int cid); -pdf_vmtx pdf_getvmtx(pdf_fontdesc *font, int cid); +void pdf_set_font_wmode(pdf_font_desc *font, int wmode); +void pdf_set_default_hmtx(pdf_font_desc *font, int w); +void pdf_set_default_vmtx(pdf_font_desc *font, int y, int w); +void pdf_add_hmtx(pdf_font_desc *font, int lo, int hi, int w); +void pdf_add_vmtx(pdf_font_desc *font, int lo, int hi, int x, int y, int w); +void pdf_end_hmtx(pdf_font_desc *font); +void pdf_end_vmtx(pdf_font_desc *font); +pdf_hmtx pdf_get_hmtx(pdf_font_desc *font, int cid); +pdf_vmtx pdf_get_vmtx(pdf_font_desc *font, int cid); /* unicode.c */ -fz_error pdf_loadtounicode(pdf_fontdesc *font, pdf_xref *xref, char **strings, char *collection, fz_obj *cmapstm); +fz_error pdf_load_to_unicode(pdf_font_desc *font, pdf_xref *xref, char **strings, char *collection, fz_obj *cmapstm); /* fontfile.c */ -fz_error pdf_loadbuiltinfont(pdf_fontdesc *font, char *basefont); -fz_error pdf_loadembeddedfont(pdf_fontdesc *font, pdf_xref *xref, fz_obj *stmref); -fz_error pdf_loadsystemfont(pdf_fontdesc *font, char *basefont, char *collection); +fz_error pdf_load_builtin_font(pdf_font_desc *font, char *basefont); +fz_error pdf_load_embedded_font(pdf_font_desc *font, pdf_xref *xref, fz_obj *stmref); +fz_error pdf_load_system_font(pdf_font_desc *font, char *basefont, char *collection); /* type3.c */ -fz_error pdf_loadtype3font(pdf_fontdesc **fontp, pdf_xref *xref, fz_obj *rdb, fz_obj *obj); +fz_error pdf_load_type3_font(pdf_font_desc **fontp, pdf_xref *xref, fz_obj *rdb, fz_obj *obj); /* font.c */ -int pdf_fontcidtogid(pdf_fontdesc *fontdesc, int cid); -fz_error pdf_loadfontdescriptor(pdf_fontdesc *font, pdf_xref *xref, fz_obj *desc, char *collection, char *basefont); -fz_error pdf_loadfont(pdf_fontdesc **fontp, pdf_xref *xref, fz_obj *rdb, fz_obj *obj); -pdf_fontdesc *pdf_newfontdesc(void); -pdf_fontdesc *pdf_keepfont(pdf_fontdesc *fontdesc); -void pdf_dropfont(pdf_fontdesc *font); -void pdf_debugfont(pdf_fontdesc *fontdesc); +int pdf_font_cid_to_gid(pdf_font_desc *fontdesc, int cid); +fz_error pdf_load_font_descriptor(pdf_font_desc *font, pdf_xref *xref, fz_obj *desc, char *collection, char *basefont); +fz_error pdf_load_font(pdf_font_desc **fontp, pdf_xref *xref, fz_obj *rdb, fz_obj *obj); +pdf_font_desc *pdf_new_font_desc(void); +pdf_font_desc *pdf_keep_font(pdf_font_desc *fontdesc); +void pdf_drop_font(pdf_font_desc *font); +void pdf_debug_font(pdf_font_desc *fontdesc); /* * Interactive features @@ -453,18 +453,18 @@ typedef struct pdf_link_s pdf_link; typedef struct pdf_annot_s pdf_annot; typedef struct pdf_outline_s pdf_outline; -typedef enum pdf_linkkind_e +typedef enum pdf_link_kind_e { - PDF_LGOTO = 0, - PDF_LURI, - PDF_LLAUNCH, - PDF_LNAMED, - PDF_LACTION, -} pdf_linkkind; + PDF_LINK_GOTO = 0, + PDF_LINK_URI, + PDF_LINK_LAUNCH, + PDF_LINK_NAMED, + PDF_LINK_ACTION, +} pdf_link_kind; struct pdf_link_s { - pdf_linkkind kind; + pdf_link_kind kind; fz_rect rect; fz_obj *dest; pdf_link *next; @@ -488,20 +488,20 @@ struct pdf_outline_s pdf_outline *next; }; -fz_obj *pdf_lookupdest(pdf_xref *xref, fz_obj *needle); -fz_obj *pdf_lookupname(pdf_xref *xref, char *which, fz_obj *needle); -fz_obj *pdf_loadnametree(pdf_xref *xref, char *which); +fz_obj *pdf_lookup_dest(pdf_xref *xref, fz_obj *needle); +fz_obj *pdf_lookup_name(pdf_xref *xref, char *which, fz_obj *needle); +fz_obj *pdf_load_name_tree(pdf_xref *xref, char *which); -pdf_outline *pdf_loadoutline(pdf_xref *xref); -void pdf_debugoutline(pdf_outline *outline, int level); -void pdf_freeoutline(pdf_outline *outline); +pdf_outline *pdf_load_outline(pdf_xref *xref); +void pdf_debug_outline(pdf_outline *outline, int level); +void pdf_free_outline(pdf_outline *outline); -pdf_link *pdf_loadlink(pdf_xref *xref, fz_obj *dict); -void pdf_loadlinks(pdf_link **, pdf_xref *, fz_obj *annots); -void pdf_freelink(pdf_link *link); +pdf_link *pdf_load_link(pdf_xref *xref, fz_obj *dict); +void pdf_load_links(pdf_link **, pdf_xref *, fz_obj *annots); +void pdf_free_link(pdf_link *link); -void pdf_loadannots(pdf_annot **, pdf_xref *, fz_obj *annots); -void pdf_freeannot(pdf_annot *link); +void pdf_load_annots(pdf_annot **, pdf_xref *, fz_obj *annots); +void pdf_free_annot(pdf_annot *link); /* * Page tree, pages and related objects @@ -521,15 +521,15 @@ struct pdf_page_s }; /* pagetree.c */ -fz_error pdf_loadpagetree(pdf_xref *xref); -int pdf_getpagecount(pdf_xref *xref); -fz_obj *pdf_getpageobject(pdf_xref *xref, int p); -fz_obj *pdf_getpageref(pdf_xref *xref, int p); -int pdf_findpageobject(pdf_xref *xref, fz_obj *pageobj); +fz_error pdf_load_page_tree(pdf_xref *xref); +int pdf_get_page_count(pdf_xref *xref); +fz_obj *pdf_get_page_object(pdf_xref *xref, int p); +fz_obj *pdf_get_page_ref(pdf_xref *xref, int p); +int pdf_find_page_object(pdf_xref *xref, fz_obj *pageobj); /* page.c */ -fz_error pdf_loadpage(pdf_page **pagep, pdf_xref *xref, fz_obj *ref); -void pdf_freepage(pdf_page *page); +fz_error pdf_load_page(pdf_page **pagep, pdf_xref *xref, fz_obj *ref); +void pdf_free_page(pdf_page *page); /* * content stream parsing @@ -541,16 +541,16 @@ typedef struct pdf_csi_s pdf_csi; enum { - PDF_MFILL, - PDF_MSTROKE, + PDF_FILL, + PDF_STROKE, }; enum { - PDF_MNONE, - PDF_MCOLOR, - PDF_MPATTERN, - PDF_MSHADE, + PDF_MAT_NONE, + PDF_MAT_COLOR, + PDF_MAT_PATTERN, + PDF_MAT_SHADE, }; struct pdf_material_s @@ -566,21 +566,21 @@ struct pdf_material_s struct pdf_gstate_s { fz_matrix ctm; - int clipdepth; + int clip_depth; /* path stroking */ - fz_strokestate strokestate; + fz_stroke_state stroke_state; /* materials */ pdf_material stroke; pdf_material fill; /* text state */ - float charspace; - float wordspace; + float char_space; + float word_space; float scale; float leading; - pdf_fontdesc *font; + pdf_font_desc *font; float size; int render; float rise; @@ -588,8 +588,8 @@ struct pdf_gstate_s /* transparency */ fz_blendmode blendmode; pdf_xobject *softmask; - fz_matrix softmaskctm; - float softmaskbc[FZ_MAXCOLORS]; + fz_matrix softmask_ctm; + float softmask_bc[FZ_MAX_COLORS]; int luminosity; }; @@ -605,56 +605,56 @@ struct pdf_csi_s fz_obj *obj; char name[256]; unsigned char string[256]; - int stringlen; + int string_len; float stack[32]; int top; int xbalance; - int intext; - int inarray; + int in_text; + int in_array; /* path object state */ fz_path *path; int clip; - int clipevenodd; + int clip_even_odd; /* text object state */ fz_text *text; fz_matrix tlm; fz_matrix tm; - int textmode; + int text_mode; int accumulate; /* graphics state */ - fz_matrix topctm; + fz_matrix top_ctm; pdf_gstate gstate[64]; int gtop; }; /* build.c */ -void pdf_initgstate(pdf_gstate *gs, fz_matrix ctm); -void pdf_setcolorspace(pdf_csi *csi, int what, fz_colorspace *cs); -void pdf_setcolor(pdf_csi *csi, int what, float *v); -void pdf_setpattern(pdf_csi *csi, int what, pdf_pattern *pat, float *v); -void pdf_setshade(pdf_csi *csi, int what, fz_shade *shade); -void pdf_showpath(pdf_csi*, int close, int fill, int stroke, int evenodd); -void pdf_showspace(pdf_csi *csi, float tadj); -void pdf_showstring(pdf_csi *csi, unsigned char *buf, int len); -void pdf_showtext(pdf_csi*, fz_obj *text); -void pdf_flushtext(pdf_csi*); -void pdf_showimage(pdf_csi*, fz_pixmap *image); -void pdf_showshade(pdf_csi*, fz_shade *shade); +void pdf_init_gstate(pdf_gstate *gs, fz_matrix ctm); +void pdf_set_colorspace(pdf_csi *csi, int what, fz_colorspace *cs); +void pdf_set_color(pdf_csi *csi, int what, float *v); +void pdf_set_pattern(pdf_csi *csi, int what, pdf_pattern *pat, float *v); +void pdf_set_shade(pdf_csi *csi, int what, fz_shade *shade); +void pdf_show_path(pdf_csi*, int close, int fill, int stroke, int even_odd); +void pdf_show_space(pdf_csi *csi, float tadj); +void pdf_show_string(pdf_csi *csi, unsigned char *buf, int len); +void pdf_show_text(pdf_csi*, fz_obj *text); +void pdf_flush_text(pdf_csi*); +void pdf_show_image(pdf_csi*, fz_pixmap *image); +void pdf_show_shade(pdf_csi*, fz_shade *shade); /* interpret.c */ void pdf_gsave(pdf_csi *csi); void pdf_grestore(pdf_csi *csi); -fz_error pdf_runcsibuffer(pdf_csi *csi, fz_obj *rdb, fz_buffer *contents); -fz_error pdf_runxobject(pdf_csi *csi, fz_obj *resources, pdf_xobject *xobj, fz_matrix transform); -fz_error pdf_runpagewithtarget(pdf_xref *xref, pdf_page *page, fz_device *dev, fz_matrix ctm, char *target); -fz_error pdf_runpage(pdf_xref *xref, pdf_page *page, fz_device *dev, fz_matrix ctm); -fz_error pdf_runglyph(pdf_xref *xref, fz_obj *resources, fz_buffer *contents, fz_device *dev, fz_matrix ctm); - -pdf_material *pdf_keepmaterial(pdf_material *mat); -pdf_material *pdf_dropmaterial(pdf_material *mat); +fz_error pdf_run_csi_buffer(pdf_csi *csi, fz_obj *rdb, fz_buffer *contents); +fz_error pdf_run_xobject(pdf_csi *csi, fz_obj *resources, pdf_xobject *xobj, fz_matrix transform); +fz_error pdf_run_page_with_usage(pdf_xref *xref, pdf_page *page, fz_device *dev, fz_matrix ctm, char *target); +fz_error pdf_run_page(pdf_xref *xref, pdf_page *page, fz_device *dev, fz_matrix ctm); +fz_error pdf_run_glyph(pdf_xref *xref, fz_obj *resources, fz_buffer *contents, fz_device *dev, fz_matrix ctm); + +pdf_material *pdf_keep_material(pdf_material *mat); +pdf_material *pdf_drop_material(pdf_material *mat); #endif diff --git a/pdf/pdf_annot.c b/pdf/pdf_annot.c index c2c67b62..39ac9d2a 100644 --- a/pdf/pdf_annot.c +++ b/pdf/pdf_annot.c @@ -2,145 +2,145 @@ #include "mupdf.h" void -pdf_freelink(pdf_link *link) +pdf_free_link(pdf_link *link) { if (link->next) - pdf_freelink(link->next); + pdf_free_link(link->next); if (link->dest) - fz_dropobj(link->dest); + fz_drop_obj(link->dest); fz_free(link); } static fz_obj * -resolvedest(pdf_xref *xref, fz_obj *dest) +resolve_dest(pdf_xref *xref, fz_obj *dest) { - if (fz_isname(dest) || fz_isstring(dest)) + if (fz_is_name(dest) || fz_is_string(dest)) { - dest = pdf_lookupdest(xref, dest); - return resolvedest(xref, dest); + dest = pdf_lookup_dest(xref, dest); + return resolve_dest(xref, dest); } - else if (fz_isarray(dest)) + else if (fz_is_array(dest)) { return dest; } - else if (fz_isdict(dest)) + else if (fz_is_dict(dest)) { - dest = fz_dictgets(dest, "D"); - return resolvedest(xref, dest); + dest = fz_dict_gets(dest, "D"); + return resolve_dest(xref, dest); } - else if (fz_isindirect(dest)) + else if (fz_is_indirect(dest)) return dest; - return nil; + return NULL; } pdf_link * -pdf_loadlink(pdf_xref *xref, fz_obj *dict) +pdf_load_link(pdf_xref *xref, fz_obj *dict) { fz_obj *dest; fz_obj *action; fz_obj *obj; fz_rect bbox; - pdf_linkkind kind; + pdf_link_kind kind; - pdf_logpage("load link {\n"); + pdf_log_page("load link {\n"); - dest = nil; + dest = NULL; - obj = fz_dictgets(dict, "Rect"); + obj = fz_dict_gets(dict, "Rect"); if (obj) { - bbox = pdf_torect(obj); - pdf_logpage("rect [%g %g %g %g]\n", + bbox = pdf_to_rect(obj); + pdf_log_page("rect [%g %g %g %g]\n", bbox.x0, bbox.y0, bbox.x1, bbox.y1); } else - bbox = fz_emptyrect; + bbox = fz_empty_rect; - obj = fz_dictgets(dict, "Dest"); + obj = fz_dict_gets(dict, "Dest"); if (obj) { - kind = PDF_LGOTO; - dest = resolvedest(xref, obj); - pdf_logpage("dest (%d %d R)\n", fz_tonum(dest), fz_togen(dest)); + kind = PDF_LINK_GOTO; + dest = resolve_dest(xref, obj); + pdf_log_page("dest (%d %d R)\n", fz_to_num(dest), fz_to_gen(dest)); } - action = fz_dictgets(dict, "A"); + action = fz_dict_gets(dict, "A"); if (action) { - obj = fz_dictgets(action, "S"); - if (fz_isname(obj) && !strcmp(fz_toname(obj), "GoTo")) + obj = fz_dict_gets(action, "S"); + if (fz_is_name(obj) && !strcmp(fz_to_name(obj), "GoTo")) { - kind = PDF_LGOTO; - dest = resolvedest(xref, fz_dictgets(action, "D")); - pdf_logpage("action goto (%d %d R)\n", fz_tonum(dest), fz_togen(dest)); + kind = PDF_LINK_GOTO; + dest = resolve_dest(xref, fz_dict_gets(action, "D")); + pdf_log_page("action goto (%d %d R)\n", fz_to_num(dest), fz_to_gen(dest)); } - else if (fz_isname(obj) && !strcmp(fz_toname(obj), "URI")) + else if (fz_is_name(obj) && !strcmp(fz_to_name(obj), "URI")) { - kind = PDF_LURI; - dest = fz_dictgets(action, "URI"); - pdf_logpage("action uri %s\n", fz_tostrbuf(dest)); + kind = PDF_LINK_URI; + dest = fz_dict_gets(action, "URI"); + pdf_log_page("action uri %s\n", fz_to_str_buf(dest)); } - else if (fz_isname(obj) && !strcmp(fz_toname(obj), "Launch")) + else if (fz_is_name(obj) && !strcmp(fz_to_name(obj), "Launch")) { - kind = PDF_LLAUNCH; - dest = fz_dictgets(action, "F"); - pdf_logpage("action %s (%d %d R)\n", fz_toname(obj), fz_tonum(dest), fz_togen(dest)); + kind = PDF_LINK_LAUNCH; + dest = fz_dict_gets(action, "F"); + pdf_log_page("action %s (%d %d R)\n", fz_to_name(obj), fz_to_num(dest), fz_to_gen(dest)); } - else if (fz_isname(obj) && !strcmp(fz_toname(obj), "Named")) + else if (fz_is_name(obj) && !strcmp(fz_to_name(obj), "Named")) { - kind = PDF_LNAMED; - dest = fz_dictgets(action, "N"); - pdf_logpage("action %s (%d %d R)\n", fz_toname(obj), fz_tonum(dest), fz_togen(dest)); + kind = PDF_LINK_NAMED; + dest = fz_dict_gets(action, "N"); + pdf_log_page("action %s (%d %d R)\n", fz_to_name(obj), fz_to_num(dest), fz_to_gen(dest)); } - else if (fz_isname(obj) && (!strcmp(fz_toname(obj), "GoToR"))) + else if (fz_is_name(obj) && (!strcmp(fz_to_name(obj), "GoToR"))) { - kind = PDF_LACTION; + kind = PDF_LINK_ACTION; dest = action; - pdf_logpage("action %s (%d %d R)\n", fz_toname(obj), fz_tonum(dest), fz_togen(dest)); + pdf_log_page("action %s (%d %d R)\n", fz_to_name(obj), fz_to_num(dest), fz_to_gen(dest)); } else { - pdf_logpage("unhandled link action, ignoring link\n"); - dest = nil; + pdf_log_page("unhandled link action, ignoring link\n"); + dest = NULL; } } - pdf_logpage("}\n"); + pdf_log_page("}\n"); if (dest) { pdf_link *link = fz_malloc(sizeof(pdf_link)); link->kind = kind; link->rect = bbox; - link->dest = fz_keepobj(dest); - link->next = nil; + link->dest = fz_keep_obj(dest); + link->next = NULL; return link; } - return nil; + return NULL; } void -pdf_loadlinks(pdf_link **linkp, pdf_xref *xref, fz_obj *annots) +pdf_load_links(pdf_link **linkp, pdf_xref *xref, fz_obj *annots) { pdf_link *link, *head, *tail; fz_obj *obj; int i; - head = tail = nil; - link = nil; + head = tail = NULL; + link = NULL; - pdf_logpage("load link annotations {\n"); + pdf_log_page("load link annotations {\n"); - for (i = 0; i < fz_arraylen(annots); i++) + for (i = 0; i < fz_array_len(annots); i++) { - obj = fz_arrayget(annots, i); - link = pdf_loadlink(xref, obj); + obj = fz_array_get(annots, i); + link = pdf_load_link(xref, obj); if (link) { if (!head) @@ -153,32 +153,32 @@ pdf_loadlinks(pdf_link **linkp, pdf_xref *xref, fz_obj *annots) } } - pdf_logpage("}\n"); + pdf_log_page("}\n"); *linkp = head; } void -pdf_freeannot(pdf_annot *annot) +pdf_free_annot(pdf_annot *annot) { if (annot->next) - pdf_freeannot(annot->next); + pdf_free_annot(annot->next); if (annot->ap) - pdf_dropxobject(annot->ap); + pdf_drop_xobject(annot->ap); if (annot->obj) - fz_dropobj(annot->obj); + fz_drop_obj(annot->obj); fz_free(annot); } static void -pdf_transformannot(pdf_annot *annot) +pdf_transform_annot(pdf_annot *annot) { fz_matrix matrix = annot->ap->matrix; fz_rect bbox = annot->ap->bbox; fz_rect rect = annot->rect; float w, h, x, y; - bbox = fz_transformrect(matrix, bbox); + bbox = fz_transform_rect(matrix, bbox); w = (rect.x1 - rect.x0) / (bbox.x1 - bbox.x0); h = (rect.y1 - rect.y0) / (bbox.y1 - bbox.y0); x = rect.x0 - bbox.x0; @@ -187,7 +187,7 @@ pdf_transformannot(pdf_annot *annot) } void -pdf_loadannots(pdf_annot **annotp, pdf_xref *xref, fz_obj *annots) +pdf_load_annots(pdf_annot **annotp, pdf_xref *xref, fz_obj *annots) { pdf_annot *annot, *head, *tail; fz_obj *obj, *ap, *as, *n, *rect; @@ -195,29 +195,29 @@ pdf_loadannots(pdf_annot **annotp, pdf_xref *xref, fz_obj *annots) fz_error error; int i; - head = tail = nil; - annot = nil; + head = tail = NULL; + annot = NULL; - pdf_logpage("load appearance annotations {\n"); + pdf_log_page("load appearance annotations {\n"); - for (i = 0; i < fz_arraylen(annots); i++) + for (i = 0; i < fz_array_len(annots); i++) { - obj = fz_arrayget(annots, i); + obj = fz_array_get(annots, i); - rect = fz_dictgets(obj, "Rect"); - ap = fz_dictgets(obj, "AP"); - as = fz_dictgets(obj, "AS"); - if (fz_isdict(ap)) + rect = fz_dict_gets(obj, "Rect"); + ap = fz_dict_gets(obj, "AP"); + as = fz_dict_gets(obj, "AS"); + if (fz_is_dict(ap)) { - n = fz_dictgets(ap, "N"); /* normal state */ + n = fz_dict_gets(ap, "N"); /* normal state */ /* lookup current state in sub-dictionary */ - if (!pdf_isstream(xref, fz_tonum(n), fz_togen(n))) - n = fz_dictget(n, as); + if (!pdf_is_stream(xref, fz_to_num(n), fz_to_gen(n))) + n = fz_dict_get(n, as); - if (pdf_isstream(xref, fz_tonum(n), fz_togen(n))) + if (pdf_is_stream(xref, fz_to_num(n), fz_to_gen(n))) { - error = pdf_loadxobject(&form, xref, n); + error = pdf_load_xobject(&form, xref, n); if (error) { fz_catch(error, "ignoring broken annotation"); @@ -225,12 +225,12 @@ pdf_loadannots(pdf_annot **annotp, pdf_xref *xref, fz_obj *annots) } annot = fz_malloc(sizeof(pdf_annot)); - annot->obj = fz_keepobj(obj); - annot->rect = pdf_torect(rect); + annot->obj = fz_keep_obj(obj); + annot->rect = pdf_to_rect(rect); annot->ap = form; - annot->next = nil; + annot->next = NULL; - pdf_transformannot(annot); + pdf_transform_annot(annot); if (annot) { @@ -246,7 +246,7 @@ pdf_loadannots(pdf_annot **annotp, pdf_xref *xref, fz_obj *annots) } } - pdf_logpage("}\n"); + pdf_log_page("}\n"); *annotp = head; } diff --git a/pdf/pdf_build.c b/pdf/pdf_build.c index 616f1c86..6908da1a 100644 --- a/pdf/pdf_build.c +++ b/pdf/pdf_build.c @@ -4,62 +4,62 @@ #define TILE void -pdf_initgstate(pdf_gstate *gs, fz_matrix ctm) +pdf_init_gstate(pdf_gstate *gs, fz_matrix ctm) { gs->ctm = ctm; - gs->clipdepth = 0; - - gs->strokestate.linewidth = 1; - gs->strokestate.linecap = 0; - gs->strokestate.linejoin = 0; - gs->strokestate.miterlimit = 10; - gs->strokestate.dashphase = 0; - gs->strokestate.dashlen = 0; - memset(gs->strokestate.dashlist, 0, sizeof(gs->strokestate.dashlist)); - - gs->stroke.kind = PDF_MCOLOR; - gs->stroke.colorspace = fz_keepcolorspace(fz_devicegray); + gs->clip_depth = 0; + + gs->stroke_state.linewidth = 1; + gs->stroke_state.linecap = 0; + gs->stroke_state.linejoin = 0; + gs->stroke_state.miterlimit = 10; + gs->stroke_state.dash_phase = 0; + gs->stroke_state.dash_len = 0; + memset(gs->stroke_state.dash_list, 0, sizeof(gs->stroke_state.dash_list)); + + gs->stroke.kind = PDF_MAT_COLOR; + gs->stroke.colorspace = fz_keep_colorspace(fz_device_gray); gs->stroke.v[0] = 0; - gs->stroke.pattern = nil; - gs->stroke.shade = nil; + gs->stroke.pattern = NULL; + gs->stroke.shade = NULL; gs->stroke.alpha = 1; - gs->fill.kind = PDF_MCOLOR; - gs->fill.colorspace = fz_keepcolorspace(fz_devicegray); + gs->fill.kind = PDF_MAT_COLOR; + gs->fill.colorspace = fz_keep_colorspace(fz_device_gray); gs->fill.v[0] = 0; - gs->fill.pattern = nil; - gs->fill.shade = nil; + gs->fill.pattern = NULL; + gs->fill.shade = NULL; gs->fill.alpha = 1; - gs->charspace = 0; - gs->wordspace = 0; + gs->char_space = 0; + gs->word_space = 0; gs->scale = 1; gs->leading = 0; - gs->font = nil; + gs->font = NULL; gs->size = -1; gs->render = 0; gs->rise = 0; - gs->blendmode = FZ_BNORMAL; - gs->softmask = nil; - gs->softmaskctm = fz_identity; + gs->blendmode = FZ_BLEND_NORMAL; + gs->softmask = NULL; + gs->softmask_ctm = fz_identity; gs->luminosity = 0; } void -pdf_setcolorspace(pdf_csi *csi, int what, fz_colorspace *colorspace) +pdf_set_colorspace(pdf_csi *csi, int what, fz_colorspace *colorspace) { pdf_gstate *gs = csi->gstate + csi->gtop; pdf_material *mat; - pdf_flushtext(csi); + pdf_flush_text(csi); - mat = what == PDF_MFILL ? &gs->fill : &gs->stroke; + mat = what == PDF_FILL ? &gs->fill : &gs->stroke; - fz_dropcolorspace(mat->colorspace); + fz_drop_colorspace(mat->colorspace); - mat->kind = PDF_MCOLOR; - mat->colorspace = fz_keepcolorspace(colorspace); + mat->kind = PDF_MAT_COLOR; + mat->colorspace = fz_keep_colorspace(colorspace); mat->v[0] = 0; mat->v[1] = 0; @@ -68,20 +68,20 @@ pdf_setcolorspace(pdf_csi *csi, int what, fz_colorspace *colorspace) } void -pdf_setcolor(pdf_csi *csi, int what, float *v) +pdf_set_color(pdf_csi *csi, int what, float *v) { pdf_gstate *gs = csi->gstate + csi->gtop; pdf_material *mat; int i; - pdf_flushtext(csi); + pdf_flush_text(csi); - mat = what == PDF_MFILL ? &gs->fill : &gs->stroke; + mat = what == PDF_FILL ? &gs->fill : &gs->stroke; switch (mat->kind) { - case PDF_MPATTERN: - case PDF_MCOLOR: + case PDF_MAT_PATTERN: + case PDF_MAT_COLOR: if (!strcmp(mat->colorspace->name, "Lab")) { mat->v[0] = v[0] / 100; @@ -97,62 +97,62 @@ pdf_setcolor(pdf_csi *csi, int what, float *v) } static void -pdf_unsetpattern(pdf_csi *csi, int what) +pdf_unset_pattern(pdf_csi *csi, int what) { pdf_gstate *gs = csi->gstate + csi->gtop; pdf_material *mat; - mat = what == PDF_MFILL ? &gs->fill : &gs->stroke; - if (mat->kind == PDF_MPATTERN) + mat = what == PDF_FILL ? &gs->fill : &gs->stroke; + if (mat->kind == PDF_MAT_PATTERN) { if (mat->pattern) - pdf_droppattern(mat->pattern); - mat->pattern = nil; - mat->kind = PDF_MCOLOR; + pdf_drop_pattern(mat->pattern); + mat->pattern = NULL; + mat->kind = PDF_MAT_COLOR; } } void -pdf_setpattern(pdf_csi *csi, int what, pdf_pattern *pat, float *v) +pdf_set_pattern(pdf_csi *csi, int what, pdf_pattern *pat, float *v) { pdf_gstate *gs = csi->gstate + csi->gtop; pdf_material *mat; - pdf_flushtext(csi); + pdf_flush_text(csi); - mat = what == PDF_MFILL ? &gs->fill : &gs->stroke; + mat = what == PDF_FILL ? &gs->fill : &gs->stroke; if (mat->pattern) - pdf_droppattern(mat->pattern); + pdf_drop_pattern(mat->pattern); - mat->kind = PDF_MPATTERN; + mat->kind = PDF_MAT_PATTERN; if (pat) - mat->pattern = pdf_keeppattern(pat); + mat->pattern = pdf_keep_pattern(pat); else - mat->pattern = nil; + mat->pattern = NULL; if (v) - pdf_setcolor(csi, what, v); + pdf_set_color(csi, what, v); } void -pdf_setshade(pdf_csi *csi, int what, fz_shade *shade) +pdf_set_shade(pdf_csi *csi, int what, fz_shade *shade) { pdf_gstate *gs = csi->gstate + csi->gtop; pdf_material *mat; - pdf_flushtext(csi); + pdf_flush_text(csi); - mat = what == PDF_MFILL ? &gs->fill : &gs->stroke; + mat = what == PDF_FILL ? &gs->fill : &gs->stroke; if (mat->shade) - fz_dropshade(mat->shade); + fz_drop_shade(mat->shade); - mat->kind = PDF_MSHADE; - mat->shade = fz_keepshade(shade); + mat->kind = PDF_MAT_SHADE; + mat->shade = fz_keep_shade(shade); } static void -pdf_showpattern(pdf_csi *csi, pdf_pattern *pat, fz_rect area, int what) +pdf_show_pattern(pdf_csi *csi, pdf_pattern *pat, fz_rect area, int what) { pdf_gstate *gstate; fz_matrix ptm, invptm; @@ -166,60 +166,60 @@ pdf_showpattern(pdf_csi *csi, pdf_pattern *pat, fz_rect area, int what) if (pat->ismask) { - pdf_unsetpattern(csi, PDF_MFILL); - pdf_unsetpattern(csi, PDF_MSTROKE); - if (what == PDF_MFILL) + pdf_unset_pattern(csi, PDF_FILL); + pdf_unset_pattern(csi, PDF_STROKE); + if (what == PDF_FILL) { - pdf_dropmaterial(&gstate->stroke); - pdf_keepmaterial(&gstate->fill); + pdf_drop_material(&gstate->stroke); + pdf_keep_material(&gstate->fill); gstate->stroke = gstate->fill; } - if (what == PDF_MSTROKE) + if (what == PDF_STROKE) { - pdf_dropmaterial(&gstate->fill); - pdf_keepmaterial(&gstate->stroke); + pdf_drop_material(&gstate->fill); + pdf_keep_material(&gstate->stroke); gstate->fill = gstate->stroke; } } else { // TODO: unset only the current fill/stroke or both? - pdf_unsetpattern(csi, what); + pdf_unset_pattern(csi, what); } /* don't apply softmasks to objects in the pattern as well */ if (gstate->softmask) { - pdf_dropxobject(gstate->softmask); - gstate->softmask = nil; + pdf_drop_xobject(gstate->softmask); + gstate->softmask = NULL; } - ptm = fz_concat(pat->matrix, csi->topctm); - invptm = fz_invertmatrix(ptm); + ptm = fz_concat(pat->matrix, csi->top_ctm); + invptm = fz_invert_matrix(ptm); /* patterns are painted using the ctm in effect at the beginning of the content stream */ /* get bbox of shape in pattern space for stamping */ - area = fz_transformrect(invptm, area); + area = fz_transform_rect(invptm, area); x0 = floorf(area.x0 / pat->xstep); y0 = floorf(area.y0 / pat->ystep); x1 = ceilf(area.x1 / pat->xstep); y1 = ceilf(area.y1 / pat->ystep); - oldtopctm = csi->topctm; + oldtopctm = csi->top_ctm; oldtop = csi->gtop; #ifdef TILE if ((x1 - x0) * (y1 - y0) > 0) { - csi->dev->begintile(csi->dev->user, area, pat->bbox, pat->xstep, pat->ystep, ptm); + csi->dev->begin_tile(csi->dev->user, area, pat->bbox, pat->xstep, pat->ystep, ptm); gstate->ctm = ptm; - csi->topctm = gstate->ctm; - error = pdf_runcsibuffer(csi, pat->resources, pat->contents); + csi->top_ctm = gstate->ctm; + error = pdf_run_csi_buffer(csi, pat->resources, pat->contents); if (error) fz_catch(error, "cannot render pattern tile"); while (oldtop < csi->gtop) pdf_grestore(csi); - csi->dev->endtile(csi->dev->user); + csi->dev->end_tile(csi->dev->user); } #else { @@ -229,8 +229,8 @@ pdf_showpattern(pdf_csi *csi, pdf_pattern *pat, fz_rect area, int what) for (x = x0; x < x1; x++) { gstate->ctm = fz_concat(fz_translate(x * pat->xstep, y * pat->ystep), ptm); - csi->topctm = gstate->ctm; - error = pdf_runcsibuffer(csi, pat->resources, pat->contents); + csi->top_ctm = gstate->ctm; + error = pdf_run_csi_buffer(csi, pat->resources, pat->contents); while (oldtop < csi->gtop) pdf_grestore(csi); if (error) @@ -244,13 +244,13 @@ pdf_showpattern(pdf_csi *csi, pdf_pattern *pat, fz_rect area, int what) cleanup: #endif - csi->topctm = oldtopctm; + csi->top_ctm = oldtopctm; pdf_grestore(csi); } static void -pdf_begingroup(pdf_csi *csi, fz_rect bbox) +pdf_begin_group(pdf_csi *csi, fz_rect bbox) { pdf_gstate *gstate = csi->gstate + csi->gtop; fz_error error; @@ -258,164 +258,164 @@ pdf_begingroup(pdf_csi *csi, fz_rect bbox) if (gstate->softmask) { pdf_xobject *softmask = gstate->softmask; - fz_rect bbox = fz_transformrect(gstate->ctm, softmask->bbox); + fz_rect bbox = fz_transform_rect(gstate->ctm, softmask->bbox); - gstate->softmask = nil; + gstate->softmask = NULL; - csi->dev->beginmask(csi->dev->user, bbox, gstate->luminosity, - softmask->colorspace, gstate->softmaskbc); - error = pdf_runxobject(csi, nil, softmask, fz_identity); + csi->dev->begin_mask(csi->dev->user, bbox, gstate->luminosity, + softmask->colorspace, gstate->softmask_bc); + error = pdf_run_xobject(csi, NULL, softmask, fz_identity); if (error) fz_catch(error, "cannot run softmask"); - csi->dev->endmask(csi->dev->user); + csi->dev->end_mask(csi->dev->user); gstate->softmask = softmask; } - if (gstate->blendmode != FZ_BNORMAL) - csi->dev->begingroup(csi->dev->user, bbox, 0, 0, gstate->blendmode, 1); + if (gstate->blendmode != FZ_BLEND_NORMAL) + csi->dev->begin_group(csi->dev->user, bbox, 0, 0, gstate->blendmode, 1); } static void -pdf_endgroup(pdf_csi *csi) +pdf_end_group(pdf_csi *csi) { pdf_gstate *gstate = csi->gstate + csi->gtop; - if (gstate->blendmode != FZ_BNORMAL) - csi->dev->endgroup(csi->dev->user); + if (gstate->blendmode != FZ_BLEND_NORMAL) + csi->dev->end_group(csi->dev->user); if (gstate->softmask) - csi->dev->popclip(csi->dev->user); + csi->dev->pop_clip(csi->dev->user); } void -pdf_showshade(pdf_csi *csi, fz_shade *shd) +pdf_show_shade(pdf_csi *csi, fz_shade *shd) { pdf_gstate *gstate = csi->gstate + csi->gtop; fz_rect bbox; - bbox = fz_boundshade(shd, gstate->ctm); + bbox = fz_bound_shade(shd, gstate->ctm); - pdf_begingroup(csi, bbox); + pdf_begin_group(csi, bbox); - csi->dev->fillshade(csi->dev->user, shd, gstate->ctm, gstate->fill.alpha); + csi->dev->fill_shade(csi->dev->user, shd, gstate->ctm, gstate->fill.alpha); - pdf_endgroup(csi); + pdf_end_group(csi); } void -pdf_showimage(pdf_csi *csi, fz_pixmap *image) +pdf_show_image(pdf_csi *csi, fz_pixmap *image) { pdf_gstate *gstate = csi->gstate + csi->gtop; fz_rect bbox; - bbox = fz_transformrect(gstate->ctm, fz_unitrect); + bbox = fz_transform_rect(gstate->ctm, fz_unit_rect); if (image->mask) { /* apply blend group even though we skip the softmask */ - if (gstate->blendmode != FZ_BNORMAL) - csi->dev->begingroup(csi->dev->user, bbox, 0, 0, gstate->blendmode, 1); - csi->dev->clipimagemask(csi->dev->user, image->mask, gstate->ctm); + if (gstate->blendmode != FZ_BLEND_NORMAL) + csi->dev->begin_group(csi->dev->user, bbox, 0, 0, gstate->blendmode, 1); + csi->dev->clip_image_mask(csi->dev->user, image->mask, gstate->ctm); } else - pdf_begingroup(csi, bbox); + pdf_begin_group(csi, bbox); if (!image->colorspace) { switch (gstate->fill.kind) { - case PDF_MNONE: + case PDF_MAT_NONE: break; - case PDF_MCOLOR: - csi->dev->fillimagemask(csi->dev->user, image, gstate->ctm, + case PDF_MAT_COLOR: + csi->dev->fill_image_mask(csi->dev->user, image, gstate->ctm, gstate->fill.colorspace, gstate->fill.v, gstate->fill.alpha); break; - case PDF_MPATTERN: + case PDF_MAT_PATTERN: if (gstate->fill.pattern) { - csi->dev->clipimagemask(csi->dev->user, image, gstate->ctm); - pdf_showpattern(csi, gstate->fill.pattern, bbox, PDF_MFILL); - csi->dev->popclip(csi->dev->user); + csi->dev->clip_image_mask(csi->dev->user, image, gstate->ctm); + pdf_show_pattern(csi, gstate->fill.pattern, bbox, PDF_FILL); + csi->dev->pop_clip(csi->dev->user); } break; - case PDF_MSHADE: + case PDF_MAT_SHADE: if (gstate->fill.shade) { - csi->dev->clipimagemask(csi->dev->user, image, gstate->ctm); - csi->dev->fillshade(csi->dev->user, gstate->fill.shade, gstate->ctm, gstate->fill.alpha); - csi->dev->popclip(csi->dev->user); + csi->dev->clip_image_mask(csi->dev->user, image, gstate->ctm); + csi->dev->fill_shade(csi->dev->user, gstate->fill.shade, gstate->ctm, gstate->fill.alpha); + csi->dev->pop_clip(csi->dev->user); } break; } } else { - csi->dev->fillimage(csi->dev->user, image, gstate->ctm, gstate->fill.alpha); + csi->dev->fill_image(csi->dev->user, image, gstate->ctm, gstate->fill.alpha); } if (image->mask) { - csi->dev->popclip(csi->dev->user); - if (gstate->blendmode != FZ_BNORMAL) - csi->dev->endgroup(csi->dev->user); + csi->dev->pop_clip(csi->dev->user); + if (gstate->blendmode != FZ_BLEND_NORMAL) + csi->dev->end_group(csi->dev->user); } else - pdf_endgroup(csi); + pdf_end_group(csi); } void -pdf_showpath(pdf_csi *csi, int doclose, int dofill, int dostroke, int evenodd) +pdf_show_path(pdf_csi *csi, int doclose, int dofill, int dostroke, int even_odd) { pdf_gstate *gstate = csi->gstate + csi->gtop; fz_path *path; fz_rect bbox; path = csi->path; - csi->path = fz_newpath(); + csi->path = fz_new_path(); if (doclose) fz_closepath(path); if (dostroke) - bbox = fz_boundpath(path, &gstate->strokestate, gstate->ctm); + bbox = fz_bound_path(path, &gstate->stroke_state, gstate->ctm); else - bbox = fz_boundpath(path, nil, gstate->ctm); + bbox = fz_bound_path(path, NULL, gstate->ctm); if (csi->clip) { - gstate->clipdepth++; - csi->dev->clippath(csi->dev->user, path, evenodd, gstate->ctm); + gstate->clip_depth++; + csi->dev->clip_path(csi->dev->user, path, even_odd, gstate->ctm); csi->clip = 0; } - pdf_begingroup(csi, bbox); + pdf_begin_group(csi, bbox); if (dofill) { switch (gstate->fill.kind) { - case PDF_MNONE: + case PDF_MAT_NONE: break; - case PDF_MCOLOR: - csi->dev->fillpath(csi->dev->user, path, evenodd, gstate->ctm, + case PDF_MAT_COLOR: + csi->dev->fill_path(csi->dev->user, path, even_odd, gstate->ctm, gstate->fill.colorspace, gstate->fill.v, gstate->fill.alpha); break; - case PDF_MPATTERN: + case PDF_MAT_PATTERN: if (gstate->fill.pattern) { - csi->dev->clippath(csi->dev->user, path, evenodd, gstate->ctm); - pdf_showpattern(csi, gstate->fill.pattern, bbox, PDF_MFILL); - csi->dev->popclip(csi->dev->user); + csi->dev->clip_path(csi->dev->user, path, even_odd, gstate->ctm); + pdf_show_pattern(csi, gstate->fill.pattern, bbox, PDF_FILL); + csi->dev->pop_clip(csi->dev->user); } break; - case PDF_MSHADE: + case PDF_MAT_SHADE: if (gstate->fill.shade) { - csi->dev->clippath(csi->dev->user, path, evenodd, gstate->ctm); - csi->dev->fillshade(csi->dev->user, gstate->fill.shade, csi->topctm, gstate->fill.alpha); - csi->dev->popclip(csi->dev->user); + csi->dev->clip_path(csi->dev->user, path, even_odd, gstate->ctm); + csi->dev->fill_shade(csi->dev->user, gstate->fill.shade, csi->top_ctm, gstate->fill.alpha); + csi->dev->pop_clip(csi->dev->user); } break; } @@ -425,38 +425,38 @@ pdf_showpath(pdf_csi *csi, int doclose, int dofill, int dostroke, int evenodd) { switch (gstate->stroke.kind) { - case PDF_MNONE: + case PDF_MAT_NONE: break; - case PDF_MCOLOR: - csi->dev->strokepath(csi->dev->user, path, &gstate->strokestate, gstate->ctm, + case PDF_MAT_COLOR: + csi->dev->stroke_path(csi->dev->user, path, &gstate->stroke_state, gstate->ctm, gstate->stroke.colorspace, gstate->stroke.v, gstate->stroke.alpha); break; - case PDF_MPATTERN: + case PDF_MAT_PATTERN: if (gstate->stroke.pattern) { - csi->dev->clipstrokepath(csi->dev->user, path, &gstate->strokestate, gstate->ctm); - pdf_showpattern(csi, gstate->stroke.pattern, bbox, PDF_MFILL); - csi->dev->popclip(csi->dev->user); + csi->dev->clip_stroke_path(csi->dev->user, path, &gstate->stroke_state, gstate->ctm); + pdf_show_pattern(csi, gstate->stroke.pattern, bbox, PDF_FILL); + csi->dev->pop_clip(csi->dev->user); } break; - case PDF_MSHADE: + case PDF_MAT_SHADE: if (gstate->stroke.shade) { - csi->dev->clipstrokepath(csi->dev->user, path, &gstate->strokestate, gstate->ctm); - csi->dev->fillshade(csi->dev->user, gstate->stroke.shade, csi->topctm, gstate->stroke.alpha); - csi->dev->popclip(csi->dev->user); + csi->dev->clip_stroke_path(csi->dev->user, path, &gstate->stroke_state, gstate->ctm); + csi->dev->fill_shade(csi->dev->user, gstate->stroke.shade, csi->top_ctm, gstate->stroke.alpha); + csi->dev->pop_clip(csi->dev->user); } break; } } - pdf_endgroup(csi); + pdf_end_group(csi); - fz_freepath(path); + fz_free_path(path); } void -pdf_flushtext(pdf_csi *csi) +pdf_flush_text(pdf_csi *csi) { pdf_gstate *gstate = csi->gstate + csi->gtop; fz_text *text; @@ -469,10 +469,10 @@ pdf_flushtext(pdf_csi *csi) if (!csi->text) return; text = csi->text; - csi->text = nil; + csi->text = NULL; dofill = dostroke = doclip = doinvisible = 0; - switch (csi->textmode) + switch (csi->text_mode) { case 0: dofill = 1; break; case 1: dostroke = 1; break; @@ -484,18 +484,18 @@ pdf_flushtext(pdf_csi *csi) case 7: doclip = 1; break; } - bbox = fz_boundtext(text, gstate->ctm); + bbox = fz_bound_text(text, gstate->ctm); - pdf_begingroup(csi, bbox); + pdf_begin_group(csi, bbox); if (doinvisible) - csi->dev->ignoretext(csi->dev->user, text, gstate->ctm); + csi->dev->ignore_text(csi->dev->user, text, gstate->ctm); if (doclip) { if (csi->accumulate < 2) - gstate->clipdepth++; - csi->dev->cliptext(csi->dev->user, text, gstate->ctm, csi->accumulate); + gstate->clip_depth++; + csi->dev->clip_text(csi->dev->user, text, gstate->ctm, csi->accumulate); csi->accumulate = 2; } @@ -503,26 +503,26 @@ pdf_flushtext(pdf_csi *csi) { switch (gstate->fill.kind) { - case PDF_MNONE: + case PDF_MAT_NONE: break; - case PDF_MCOLOR: - csi->dev->filltext(csi->dev->user, text, gstate->ctm, + case PDF_MAT_COLOR: + csi->dev->fill_text(csi->dev->user, text, gstate->ctm, gstate->fill.colorspace, gstate->fill.v, gstate->fill.alpha); break; - case PDF_MPATTERN: + case PDF_MAT_PATTERN: if (gstate->fill.pattern) { - csi->dev->cliptext(csi->dev->user, text, gstate->ctm, 0); - pdf_showpattern(csi, gstate->fill.pattern, bbox, PDF_MFILL); - csi->dev->popclip(csi->dev->user); + csi->dev->clip_text(csi->dev->user, text, gstate->ctm, 0); + pdf_show_pattern(csi, gstate->fill.pattern, bbox, PDF_FILL); + csi->dev->pop_clip(csi->dev->user); } break; - case PDF_MSHADE: + case PDF_MAT_SHADE: if (gstate->fill.shade) { - csi->dev->cliptext(csi->dev->user, text, gstate->ctm, 0); - csi->dev->fillshade(csi->dev->user, gstate->fill.shade, csi->topctm, gstate->fill.alpha); - csi->dev->popclip(csi->dev->user); + csi->dev->clip_text(csi->dev->user, text, gstate->ctm, 0); + csi->dev->fill_shade(csi->dev->user, gstate->fill.shade, csi->top_ctm, gstate->fill.alpha); + csi->dev->pop_clip(csi->dev->user); } break; } @@ -532,41 +532,41 @@ pdf_flushtext(pdf_csi *csi) { switch (gstate->stroke.kind) { - case PDF_MNONE: + case PDF_MAT_NONE: break; - case PDF_MCOLOR: - csi->dev->stroketext(csi->dev->user, text, &gstate->strokestate, gstate->ctm, + case PDF_MAT_COLOR: + csi->dev->stroke_text(csi->dev->user, text, &gstate->stroke_state, gstate->ctm, gstate->stroke.colorspace, gstate->stroke.v, gstate->stroke.alpha); break; - case PDF_MPATTERN: + case PDF_MAT_PATTERN: if (gstate->stroke.pattern) { - csi->dev->clipstroketext(csi->dev->user, text, &gstate->strokestate, gstate->ctm); - pdf_showpattern(csi, gstate->stroke.pattern, bbox, PDF_MFILL); - csi->dev->popclip(csi->dev->user); + csi->dev->clip_stroke_text(csi->dev->user, text, &gstate->stroke_state, gstate->ctm); + pdf_show_pattern(csi, gstate->stroke.pattern, bbox, PDF_FILL); + csi->dev->pop_clip(csi->dev->user); } break; - case PDF_MSHADE: + case PDF_MAT_SHADE: if (gstate->stroke.shade) { - csi->dev->clipstroketext(csi->dev->user, text, &gstate->strokestate, gstate->ctm); - csi->dev->fillshade(csi->dev->user, gstate->stroke.shade, csi->topctm, gstate->stroke.alpha); - csi->dev->popclip(csi->dev->user); + csi->dev->clip_stroke_text(csi->dev->user, text, &gstate->stroke_state, gstate->ctm); + csi->dev->fill_shade(csi->dev->user, gstate->stroke.shade, csi->top_ctm, gstate->stroke.alpha); + csi->dev->pop_clip(csi->dev->user); } break; } } - pdf_endgroup(csi); + pdf_end_group(csi); - fz_freetext(text); + fz_free_text(text); } static void -pdf_showglyph(pdf_csi *csi, int cid) +pdf_show_glyph(pdf_csi *csi, int cid) { pdf_gstate *gstate = csi->gstate + csi->gtop; - pdf_fontdesc *fontdesc = gstate->font; + pdf_font_desc *fontdesc = gstate->font; fz_matrix tsm, trm; float w0, w1, tx, ty; pdf_hmtx h; @@ -584,11 +584,11 @@ pdf_showglyph(pdf_csi *csi, int cid) tsm.f = gstate->rise; ucslen = 0; - if (fontdesc->tounicode) - ucslen = pdf_lookupcmapfull(fontdesc->tounicode, cid, ucsbuf); - if (ucslen == 0 && cid < fontdesc->ncidtoucs) + if (fontdesc->to_unicode) + ucslen = pdf_lookup_cmap_full(fontdesc->to_unicode, cid, ucsbuf); + if (ucslen == 0 && cid < fontdesc->cid_to_ucs_len) { - ucsbuf[0] = fontdesc->cidtoucs[cid]; + ucsbuf[0] = fontdesc->cid_to_ucs[cid]; ucslen = 1; } if (ucslen == 0 || (ucslen == 1 && ucsbuf[0] == 0)) @@ -597,11 +597,11 @@ pdf_showglyph(pdf_csi *csi, int cid) ucslen = 1; } - gid = pdf_fontcidtogid(fontdesc, cid); + gid = pdf_font_cid_to_gid(fontdesc, cid); if (fontdesc->wmode == 1) { - v = pdf_getvmtx(fontdesc, cid); + v = pdf_get_vmtx(fontdesc, cid); tsm.e -= v.x * gstate->size * 0.001f; tsm.f -= v.y * gstate->size * 0.001f; } @@ -616,44 +616,44 @@ pdf_showglyph(pdf_csi *csi, int cid) fabsf(trm.b - csi->text->trm.b) > FLT_EPSILON || fabsf(trm.c - csi->text->trm.c) > FLT_EPSILON || fabsf(trm.d - csi->text->trm.d) > FLT_EPSILON || - gstate->render != csi->textmode) + gstate->render != csi->text_mode) { - pdf_flushtext(csi); + pdf_flush_text(csi); - csi->text = fz_newtext(fontdesc->font, trm, fontdesc->wmode); + csi->text = fz_new_text(fontdesc->font, trm, fontdesc->wmode); csi->text->trm.e = 0; csi->text->trm.f = 0; - csi->textmode = gstate->render; + csi->text_mode = gstate->render; } /* add glyph to textobject */ - fz_addtext(csi->text, gid, ucsbuf[0], trm.e, trm.f); + fz_add_text(csi->text, gid, ucsbuf[0], trm.e, trm.f); /* add filler glyphs for one-to-many unicode mapping */ for (i = 1; i < ucslen; i++) - fz_addtext(csi->text, -1, ucsbuf[i], trm.e, trm.f); + fz_add_text(csi->text, -1, ucsbuf[i], trm.e, trm.f); if (fontdesc->wmode == 0) { - h = pdf_gethmtx(fontdesc, cid); + h = pdf_get_hmtx(fontdesc, cid); w0 = h.w * 0.001f; - tx = (w0 * gstate->size + gstate->charspace) * gstate->scale; + tx = (w0 * gstate->size + gstate->char_space) * gstate->scale; csi->tm = fz_concat(fz_translate(tx, 0), csi->tm); } if (fontdesc->wmode == 1) { w1 = v.w * 0.001f; - ty = w1 * gstate->size + gstate->charspace; + ty = w1 * gstate->size + gstate->char_space; csi->tm = fz_concat(fz_translate(0, ty), csi->tm); } } void -pdf_showspace(pdf_csi *csi, float tadj) +pdf_show_space(pdf_csi *csi, float tadj) { pdf_gstate *gstate = csi->gstate + csi->gtop; - pdf_fontdesc *fontdesc = gstate->font; + pdf_font_desc *fontdesc = gstate->font; if (!fontdesc) { @@ -668,10 +668,10 @@ pdf_showspace(pdf_csi *csi, float tadj) } void -pdf_showstring(pdf_csi *csi, unsigned char *buf, int len) +pdf_show_string(pdf_csi *csi, unsigned char *buf, int len) { pdf_gstate *gstate = csi->gstate + csi->gtop; - pdf_fontdesc *fontdesc = gstate->font; + pdf_font_desc *fontdesc = gstate->font; unsigned char *end = buf + len; int cpt, cid; @@ -683,36 +683,36 @@ pdf_showstring(pdf_csi *csi, unsigned char *buf, int len) while (buf < end) { - buf = pdf_decodecmap(fontdesc->encoding, buf, &cpt); - cid = pdf_lookupcmap(fontdesc->encoding, cpt); + buf = pdf_decode_cmap(fontdesc->encoding, buf, &cpt); + cid = pdf_lookup_cmap(fontdesc->encoding, cpt); if (cid >= 0) - pdf_showglyph(csi, cid); + pdf_show_glyph(csi, cid); else fz_warn("cannot encode character with code point %#x", cpt); if (cpt == 32) - pdf_showspace(csi, gstate->wordspace); + pdf_show_space(csi, gstate->word_space); } } void -pdf_showtext(pdf_csi *csi, fz_obj *text) +pdf_show_text(pdf_csi *csi, fz_obj *text) { pdf_gstate *gstate = csi->gstate + csi->gtop; int i; - if (fz_isarray(text)) + if (fz_is_array(text)) { - for (i = 0; i < fz_arraylen(text); i++) + for (i = 0; i < fz_array_len(text); i++) { - fz_obj *item = fz_arrayget(text, i); - if (fz_isstring(item)) - pdf_showstring(csi, (unsigned char *)fz_tostrbuf(item), fz_tostrlen(item)); + fz_obj *item = fz_array_get(text, i); + if (fz_is_string(item)) + pdf_show_string(csi, (unsigned char *)fz_to_str_buf(item), fz_to_str_len(item)); else - pdf_showspace(csi, - fz_toreal(item) * gstate->size * 0.001f); + pdf_show_space(csi, - fz_to_real(item) * gstate->size * 0.001f); } } - else if (fz_isstring(text)) + else if (fz_is_string(text)) { - pdf_showstring(csi, (unsigned char *)fz_tostrbuf(text), fz_tostrlen(text)); + pdf_show_string(csi, (unsigned char *)fz_to_str_buf(text), fz_to_str_len(text)); } } diff --git a/pdf/pdf_cmap.c b/pdf/pdf_cmap.c index aab6bd60..a526dc4e 100644 --- a/pdf/pdf_cmap.c +++ b/pdf/pdf_cmap.c @@ -18,43 +18,43 @@ #include "fitz.h" #include "mupdf.h" -/* Macros for accessing the combined extentflags field */ -#define pdf_range_high(r) ((r)->low + ((r)->extentflags >> 2)) -#define pdf_range_flags(r) ((r)->extentflags & 3) -#define pdf_range_set_high(r, h) ((r)->extentflags = (((r)->extentflags & 3) | ((h - (r)->low) << 2))) -#define pdf_range_set_flags(r, f) ((r)->extentflags = (((r)->extentflags & ~3) | f)) +/* Macros for accessing the combined extent_flags field */ +#define pdf_range_high(r) ((r)->low + ((r)->extent_flags >> 2)) +#define pdf_range_flags(r) ((r)->extent_flags & 3) +#define pdf_range_set_high(r, h) ((r)->extent_flags = (((r)->extent_flags & 3) | ((h - (r)->low) << 2))) +#define pdf_range_set_flags(r, f) ((r)->extent_flags = (((r)->extent_flags & ~3) | f)) /* * Allocate, destroy and simple parameters. */ pdf_cmap * -pdf_newcmap(void) +pdf_new_cmap(void) { pdf_cmap *cmap; cmap = fz_malloc(sizeof(pdf_cmap)); cmap->refs = 1; - strcpy(cmap->cmapname, ""); - strcpy(cmap->usecmapname, ""); - cmap->usecmap = nil; + strcpy(cmap->cmap_name, ""); + strcpy(cmap->usecmap_name, ""); + cmap->usecmap = NULL; cmap->wmode = 0; - cmap->ncspace = 0; + cmap->codespace_len = 0; cmap->rlen = 0; cmap->rcap = 0; - cmap->ranges = nil; + cmap->ranges = NULL; cmap->tlen = 0; cmap->tcap = 0; - cmap->table = nil; + cmap->table = NULL; return cmap; } pdf_cmap * -pdf_keepcmap(pdf_cmap *cmap) +pdf_keep_cmap(pdf_cmap *cmap) { if (cmap->refs >= 0) cmap->refs ++; @@ -62,14 +62,14 @@ pdf_keepcmap(pdf_cmap *cmap) } void -pdf_dropcmap(pdf_cmap *cmap) +pdf_drop_cmap(pdf_cmap *cmap) { if (cmap->refs >= 0) { if (--cmap->refs == 0) { if (cmap->usecmap) - pdf_dropcmap(cmap->usecmap); + pdf_drop_cmap(cmap->usecmap); fz_free(cmap->ranges); fz_free(cmap->table); fz_free(cmap); @@ -78,52 +78,52 @@ pdf_dropcmap(pdf_cmap *cmap) } void -pdf_setusecmap(pdf_cmap *cmap, pdf_cmap *usecmap) +pdf_set_usecmap(pdf_cmap *cmap, pdf_cmap *usecmap) { int i; if (cmap->usecmap) - pdf_dropcmap(cmap->usecmap); - cmap->usecmap = pdf_keepcmap(usecmap); + pdf_drop_cmap(cmap->usecmap); + cmap->usecmap = pdf_keep_cmap(usecmap); - if (cmap->ncspace == 0) + if (cmap->codespace_len == 0) { - cmap->ncspace = usecmap->ncspace; - for (i = 0; i < usecmap->ncspace; i++) - cmap->cspace[i] = usecmap->cspace[i]; + cmap->codespace_len = usecmap->codespace_len; + for (i = 0; i < usecmap->codespace_len; i++) + cmap->codespace[i] = usecmap->codespace[i]; } } int -pdf_getwmode(pdf_cmap *cmap) +pdf_get_wmode(pdf_cmap *cmap) { return cmap->wmode; } void -pdf_setwmode(pdf_cmap *cmap, int wmode) +pdf_set_wmode(pdf_cmap *cmap, int wmode) { cmap->wmode = wmode; } void -pdf_debugcmap(pdf_cmap *cmap) +pdf_debug_cmap(pdf_cmap *cmap) { int i, k, n; - printf("cmap $%p /%s {\n", (void *) cmap, cmap->cmapname); + printf("cmap $%p /%s {\n", (void *) cmap, cmap->cmap_name); - if (cmap->usecmapname[0]) - printf("\tusecmap /%s\n", cmap->usecmapname); + if (cmap->usecmap_name[0]) + printf("\tusecmap /%s\n", cmap->usecmap_name); if (cmap->usecmap) printf("\tusecmap $%p\n", (void *) cmap->usecmap); printf("\twmode %d\n", cmap->wmode); printf("\tcodespaces {\n"); - for (i = 0; i < cmap->ncspace; i++) + for (i = 0; i < cmap->codespace_len; i++) { - printf("\t\t<%x> <%x>\n", cmap->cspace[i].low, cmap->cspace[i].high); + printf("\t\t<%x> <%x>\n", cmap->codespace[i].low, cmap->codespace[i].high); } printf("\t}\n"); @@ -155,29 +155,29 @@ pdf_debugcmap(pdf_cmap *cmap) /* * Add a codespacerange section. - * These ranges are used by pdf_decodecmap to decode + * These ranges are used by pdf_decode_cmap to decode * multi-byte encoded strings. */ void -pdf_addcodespace(pdf_cmap *cmap, int low, int high, int n) +pdf_add_codespace(pdf_cmap *cmap, int low, int high, int n) { - if (cmap->ncspace + 1 == nelem(cmap->cspace)) + if (cmap->codespace_len + 1 == nelem(cmap->codespace)) { fz_warn("assert: too many code space ranges"); return; } - cmap->cspace[cmap->ncspace].n = n; - cmap->cspace[cmap->ncspace].low = low; - cmap->cspace[cmap->ncspace].high = high; - cmap->ncspace ++; + cmap->codespace[cmap->codespace_len].n = n; + cmap->codespace[cmap->codespace_len].low = low; + cmap->codespace[cmap->codespace_len].high = high; + cmap->codespace_len ++; } /* * Add an integer to the table. */ static void -addtable(pdf_cmap *cmap, int value) +add_table(pdf_cmap *cmap, int value) { if (cmap->tlen + 1 > cmap->tcap) { @@ -191,13 +191,13 @@ addtable(pdf_cmap *cmap, int value) * Add a range. */ static void -addrange(pdf_cmap *cmap, int low, int high, int flag, int offset) +add_range(pdf_cmap *cmap, int low, int high, int flag, int offset) { /* If the range is too large to be represented, split it */ if (high - low > 0x3fff) { - addrange(cmap, low, low+0x3fff, flag, offset); - addrange(cmap, low+0x3fff, high, flag, offset+0x3fff); + add_range(cmap, low, low+0x3fff, flag, offset); + add_range(cmap, low+0x3fff, high, flag, offset+0x3fff); return; } if (cmap->rlen + 1 > cmap->rcap) @@ -216,36 +216,36 @@ addrange(pdf_cmap *cmap, int low, int high, int flag, int offset) * Add a range-to-table mapping. */ void -pdf_maprangetotable(pdf_cmap *cmap, int low, int *table, int len) +pdf_map_range_to_table(pdf_cmap *cmap, int low, int *table, int len) { int i; int high = low + len; int offset = cmap->tlen; for (i = 0; i < len; i++) - addtable(cmap, table[i]); - addrange(cmap, low, high, PDF_CMAP_TABLE, offset); + add_table(cmap, table[i]); + add_range(cmap, low, high, PDF_CMAP_TABLE, offset); } /* * Add a range of contiguous one-to-one mappings (ie 1..5 maps to 21..25) */ void -pdf_maprangetorange(pdf_cmap *cmap, int low, int high, int offset) +pdf_map_range_to_range(pdf_cmap *cmap, int low, int high, int offset) { - addrange(cmap, low, high, high - low == 0 ? PDF_CMAP_SINGLE : PDF_CMAP_RANGE, offset); + add_range(cmap, low, high, high - low == 0 ? PDF_CMAP_SINGLE : PDF_CMAP_RANGE, offset); } /* * Add a single one-to-many mapping. */ void -pdf_maponetomany(pdf_cmap *cmap, int low, int *values, int len) +pdf_map_one_to_many(pdf_cmap *cmap, int low, int *values, int len) { int offset, i; if (len == 1) { - addrange(cmap, low, low, PDF_CMAP_SINGLE, values[0]); + add_range(cmap, low, low, PDF_CMAP_SINGLE, values[0]); return; } @@ -256,10 +256,10 @@ pdf_maponetomany(pdf_cmap *cmap, int low, int *values, int len) } offset = cmap->tlen; - addtable(cmap, len); + add_table(cmap, len); for (i = 0; i < len; i++) - addtable(cmap, values[i]); - addrange(cmap, low, low, PDF_CMAP_MULTI, offset); + add_table(cmap, values[i]); + add_range(cmap, low, low, PDF_CMAP_MULTI, offset); } /* @@ -274,7 +274,7 @@ static int cmprange(const void *va, const void *vb) } void -pdf_sortcmap(pdf_cmap *cmap) +pdf_sort_cmap(pdf_cmap *cmap) { pdf_range *a; /* last written range on output */ pdf_range *b; /* current range examined on input */ @@ -312,7 +312,7 @@ pdf_sortcmap(pdf_cmap *cmap) else if (pdf_range_flags(a) == PDF_CMAP_TABLE && pdf_range_flags(b) == PDF_CMAP_SINGLE) { pdf_range_set_high(a, pdf_range_high(b)); - addtable(cmap, b->offset); + add_table(cmap, b->offset); } /* LR -> LR */ @@ -336,8 +336,8 @@ pdf_sortcmap(pdf_cmap *cmap) { pdf_range_set_flags(a, PDF_CMAP_TABLE); pdf_range_set_high(a, pdf_range_high(b)); - addtable(cmap, a->offset); - addtable(cmap, b->offset); + add_table(cmap, a->offset); + add_table(cmap, b->offset); a->offset = cmap->tlen - 2; } @@ -345,7 +345,7 @@ pdf_sortcmap(pdf_cmap *cmap) else if (pdf_range_flags(a) == PDF_CMAP_TABLE && pdf_range_flags(b) == PDF_CMAP_SINGLE) { pdf_range_set_high(a, pdf_range_high(b)); - addtable(cmap, b->offset); + add_table(cmap, b->offset); } /* XX -> XX */ @@ -370,7 +370,7 @@ pdf_sortcmap(pdf_cmap *cmap) * Lookup the mapping of a codepoint. */ int -pdf_lookupcmap(pdf_cmap *cmap, int cpt) +pdf_lookup_cmap(pdf_cmap *cmap, int cpt) { int l = 0; int r = cmap->rlen - 1; @@ -395,13 +395,13 @@ pdf_lookupcmap(pdf_cmap *cmap, int cpt) } if (cmap->usecmap) - return pdf_lookupcmap(cmap->usecmap, cpt); + return pdf_lookup_cmap(cmap->usecmap, cpt); return -1; } int -pdf_lookupcmapfull(pdf_cmap *cmap, int cpt, int *out) +pdf_lookup_cmap_full(pdf_cmap *cmap, int cpt, int *out) { int i, k, n; int l = 0; @@ -439,7 +439,7 @@ pdf_lookupcmapfull(pdf_cmap *cmap, int cpt, int *out) } if (cmap->usecmap) - return pdf_lookupcmapfull(cmap->usecmap, cpt, out); + return pdf_lookup_cmap_full(cmap->usecmap, cpt, out); return 0; } @@ -449,7 +449,7 @@ pdf_lookupcmapfull(pdf_cmap *cmap, int cpt, int *out) * multi-byte encoded string. */ unsigned char * -pdf_decodecmap(pdf_cmap *cmap, unsigned char *buf, int *cpt) +pdf_decode_cmap(pdf_cmap *cmap, unsigned char *buf, int *cpt) { int k, n, c; @@ -457,11 +457,11 @@ pdf_decodecmap(pdf_cmap *cmap, unsigned char *buf, int *cpt) for (n = 0; n < 4; n++) { c = (c << 8) | buf[n]; - for (k = 0; k < cmap->ncspace; k++) + for (k = 0; k < cmap->codespace_len; k++) { - if (cmap->cspace[k].n == n + 1) + if (cmap->codespace[k].n == n + 1) { - if (c >= cmap->cspace[k].low && c <= cmap->cspace[k].high) + if (c >= cmap->codespace[k].low && c <= cmap->codespace[k].high) { *cpt = c; return buf + n + 1; diff --git a/pdf/pdf_cmap_load.c b/pdf/pdf_cmap_load.c index eae52d8d..f6ea4bf8 100644 --- a/pdf/pdf_cmap_load.c +++ b/pdf/pdf_cmap_load.c @@ -5,75 +5,75 @@ * Load CMap stream in PDF file */ fz_error -pdf_loadembeddedcmap(pdf_cmap **cmapp, pdf_xref *xref, fz_obj *stmobj) +pdf_load_embedded_cmap(pdf_cmap **cmapp, pdf_xref *xref, fz_obj *stmobj) { fz_error error = fz_okay; - fz_stream *file = nil; - pdf_cmap *cmap = nil; + fz_stream *file = NULL; + pdf_cmap *cmap = NULL; pdf_cmap *usecmap; fz_obj *wmode; fz_obj *obj; - if ((*cmapp = pdf_finditem(xref->store, pdf_dropcmap, stmobj))) + if ((*cmapp = pdf_find_item(xref->store, pdf_drop_cmap, stmobj))) { - pdf_keepcmap(*cmapp); + pdf_keep_cmap(*cmapp); return fz_okay; } - pdf_logfont("load embedded cmap (%d %d R) {\n", fz_tonum(stmobj), fz_togen(stmobj)); + pdf_log_font("load embedded cmap (%d %d R) {\n", fz_to_num(stmobj), fz_to_gen(stmobj)); - error = pdf_openstream(&file, xref, fz_tonum(stmobj), fz_togen(stmobj)); + error = pdf_open_stream(&file, xref, fz_to_num(stmobj), fz_to_gen(stmobj)); if (error) { - error = fz_rethrow(error, "cannot open cmap stream (%d %d R)", fz_tonum(stmobj), fz_togen(stmobj)); + error = fz_rethrow(error, "cannot open cmap stream (%d %d R)", fz_to_num(stmobj), fz_to_gen(stmobj)); goto cleanup; } - error = pdf_parsecmap(&cmap, file); + error = pdf_parse_cmap(&cmap, file); if (error) { - error = fz_rethrow(error, "cannot parse cmap stream (%d %d R)", fz_tonum(stmobj), fz_togen(stmobj)); + error = fz_rethrow(error, "cannot parse cmap stream (%d %d R)", fz_to_num(stmobj), fz_to_gen(stmobj)); goto cleanup; } fz_close(file); - wmode = fz_dictgets(stmobj, "WMode"); - if (fz_isint(wmode)) + wmode = fz_dict_gets(stmobj, "WMode"); + if (fz_is_int(wmode)) { - pdf_logfont("wmode %d\n", wmode); - pdf_setwmode(cmap, fz_toint(wmode)); + pdf_log_font("wmode %d\n", wmode); + pdf_set_wmode(cmap, fz_to_int(wmode)); } - obj = fz_dictgets(stmobj, "UseCMap"); - if (fz_isname(obj)) + obj = fz_dict_gets(stmobj, "UseCMap"); + if (fz_is_name(obj)) { - pdf_logfont("usecmap /%s\n", fz_toname(obj)); - error = pdf_loadsystemcmap(&usecmap, fz_toname(obj)); + pdf_log_font("usecmap /%s\n", fz_to_name(obj)); + error = pdf_load_system_cmap(&usecmap, fz_to_name(obj)); if (error) { - error = fz_rethrow(error, "cannot load system usecmap '%s'", fz_toname(obj)); + error = fz_rethrow(error, "cannot load system usecmap '%s'", fz_to_name(obj)); goto cleanup; } - pdf_setusecmap(cmap, usecmap); - pdf_dropcmap(usecmap); + pdf_set_usecmap(cmap, usecmap); + pdf_drop_cmap(usecmap); } - else if (fz_isindirect(obj)) + else if (fz_is_indirect(obj)) { - pdf_logfont("usecmap (%d %d R)\n", fz_tonum(obj), fz_togen(obj)); - error = pdf_loadembeddedcmap(&usecmap, xref, obj); + pdf_log_font("usecmap (%d %d R)\n", fz_to_num(obj), fz_to_gen(obj)); + error = pdf_load_embedded_cmap(&usecmap, xref, obj); if (error) { - error = fz_rethrow(error, "cannot load embedded usecmap (%d %d R)", fz_tonum(obj), fz_togen(obj)); + error = fz_rethrow(error, "cannot load embedded usecmap (%d %d R)", fz_to_num(obj), fz_to_gen(obj)); goto cleanup; } - pdf_setusecmap(cmap, usecmap); - pdf_dropcmap(usecmap); + pdf_set_usecmap(cmap, usecmap); + pdf_drop_cmap(usecmap); } - pdf_logfont("}\n"); + pdf_log_font("}\n"); - pdf_storeitem(xref->store, pdf_keepcmap, pdf_dropcmap, stmobj, cmap); + pdf_store_item(xref->store, pdf_keep_cmap, pdf_drop_cmap, stmobj, cmap); *cmapp = cmap; return fz_okay; @@ -82,7 +82,7 @@ cleanup: if (file) fz_close(file); if (cmap) - pdf_dropcmap(cmap); + pdf_drop_cmap(cmap); return error; /* already rethrown */ } @@ -90,14 +90,14 @@ cleanup: * Create an Identity-* CMap (for both 1 and 2-byte encodings) */ pdf_cmap * -pdf_newidentitycmap(int wmode, int bytes) +pdf_new_identity_cmap(int wmode, int bytes) { - pdf_cmap *cmap = pdf_newcmap(); - sprintf(cmap->cmapname, "Identity-%c", wmode ? 'V' : 'H'); - pdf_addcodespace(cmap, 0x0000, 0xffff, bytes); - pdf_maprangetorange(cmap, 0x0000, 0xffff, 0); - pdf_sortcmap(cmap); - pdf_setwmode(cmap, wmode); + pdf_cmap *cmap = pdf_new_cmap(); + sprintf(cmap->cmap_name, "Identity-%c", wmode ? 'V' : 'H'); + pdf_add_codespace(cmap, 0x0000, 0xffff, bytes); + pdf_map_range_to_range(cmap, 0x0000, 0xffff, 0); + pdf_sort_cmap(cmap); + pdf_set_wmode(cmap, wmode); return cmap; } @@ -105,31 +105,31 @@ pdf_newidentitycmap(int wmode, int bytes) * Load predefined CMap from system. */ fz_error -pdf_loadsystemcmap(pdf_cmap **cmapp, char *cmapname) +pdf_load_system_cmap(pdf_cmap **cmapp, char *cmap_name) { fz_error error; pdf_cmap *usecmap; pdf_cmap *cmap; int i; - pdf_logfont("loading system cmap %s\n", cmapname); + pdf_log_font("loading system cmap %s\n", cmap_name); - for (i = 0; pdf_cmaptable[i]; i++) + for (i = 0; pdf_cmap_table[i]; i++) { - if (!strcmp(cmapname, pdf_cmaptable[i]->cmapname)) + if (!strcmp(cmap_name, pdf_cmap_table[i]->cmap_name)) { - cmap = pdf_cmaptable[i]; - if (cmap->usecmapname[0] && !cmap->usecmap) + cmap = pdf_cmap_table[i]; + if (cmap->usecmap_name[0] && !cmap->usecmap) { - error = pdf_loadsystemcmap(&usecmap, cmap->usecmapname); + error = pdf_load_system_cmap(&usecmap, cmap->usecmap_name); if (error) - return fz_rethrow(error, "cannot load usecmap: %s", cmap->usecmapname); - pdf_setusecmap(cmap, usecmap); + return fz_rethrow(error, "cannot load usecmap: %s", cmap->usecmap_name); + pdf_set_usecmap(cmap, usecmap); } *cmapp = cmap; return fz_okay; } } - return fz_throw("no builtin cmap file: %s", cmapname); + return fz_throw("no builtin cmap file: %s", cmap_name); } diff --git a/pdf/pdf_cmap_parse.c b/pdf/pdf_cmap_parse.c index d899af0e..edd97de8 100644 --- a/pdf/pdf_cmap_parse.c +++ b/pdf/pdf_cmap_parse.c @@ -7,40 +7,40 @@ enum { - TUSECMAP = PDF_NTOKENS, - TBEGINCODESPACERANGE, - TENDCODESPACERANGE, - TBEGINBFCHAR, - TENDBFCHAR, - TBEGINBFRANGE, - TENDBFRANGE, - TBEGINCIDCHAR, - TENDCIDCHAR, - TBEGINCIDRANGE, - TENDCIDRANGE, - TENDCMAP + TOK_USECMAP = PDF_NUM_TOKENS, + TOK_BEGIN_CODESPACE_RANGE, + TOK_END_CODESPACE_RANGE, + TOK_BEGIN_BF_CHAR, + TOK_END_BF_CHAR, + TOK_BEGIN_BF_RANGE, + TOK_END_BF_RANGE, + TOK_BEGIN_CID_CHAR, + TOK_END_CID_CHAR, + TOK_BEGIN_CID_RANGE, + TOK_END_CID_RANGE, + TOK_END_CMAP }; static int -pdf_cmaptokenfromkeyword(char *key) +pdf_cmap_token_from_keyword(char *key) { - if (!strcmp(key, "usecmap")) return TUSECMAP; - if (!strcmp(key, "begincodespacerange")) return TBEGINCODESPACERANGE; - if (!strcmp(key, "endcodespacerange")) return TENDCODESPACERANGE; - if (!strcmp(key, "beginbfchar")) return TBEGINBFCHAR; - if (!strcmp(key, "endbfchar")) return TENDBFCHAR; - if (!strcmp(key, "beginbfrange")) return TBEGINBFRANGE; - if (!strcmp(key, "endbfrange")) return TENDBFRANGE; - if (!strcmp(key, "begincidchar")) return TBEGINCIDCHAR; - if (!strcmp(key, "endcidchar")) return TENDCIDCHAR; - if (!strcmp(key, "begincidrange")) return TBEGINCIDRANGE; - if (!strcmp(key, "endcidrange")) return TENDCIDRANGE; - if (!strcmp(key, "endcmap")) return TENDCMAP; - return PDF_TKEYWORD; + if (!strcmp(key, "usecmap")) return TOK_USECMAP; + if (!strcmp(key, "begincodespacerange")) return TOK_BEGIN_CODESPACE_RANGE; + if (!strcmp(key, "endcodespacerange")) return TOK_END_CODESPACE_RANGE; + if (!strcmp(key, "beginbfchar")) return TOK_BEGIN_BF_CHAR; + if (!strcmp(key, "endbfchar")) return TOK_END_BF_CHAR; + if (!strcmp(key, "beginbfrange")) return TOK_BEGIN_BF_RANGE; + if (!strcmp(key, "endbfrange")) return TOK_END_BF_RANGE; + if (!strcmp(key, "begincidchar")) return TOK_BEGIN_CID_CHAR; + if (!strcmp(key, "endcidchar")) return TOK_END_CID_CHAR; + if (!strcmp(key, "begincidrange")) return TOK_BEGIN_CID_RANGE; + if (!strcmp(key, "endcidrange")) return TOK_END_CID_RANGE; + if (!strcmp(key, "endcmap")) return TOK_END_CMAP; + return PDF_TOK_KEYWORD; } static int -pdf_codefromstring(char *buf, int len) +pdf_code_from_string(char *buf, int len) { int a = 0; while (len--) @@ -49,7 +49,7 @@ pdf_codefromstring(char *buf, int len) } static fz_error -pdf_lexcmap(int *tok, fz_stream *file, char *buf, int n, int *sl) +pdf_lex_cmap(int *tok, fz_stream *file, char *buf, int n, int *sl) { fz_error error; @@ -57,26 +57,26 @@ pdf_lexcmap(int *tok, fz_stream *file, char *buf, int n, int *sl) if (error) return fz_rethrow(error, "cannot parse cmap token"); - if (*tok == PDF_TKEYWORD) - *tok = pdf_cmaptokenfromkeyword(buf); + if (*tok == PDF_TOK_KEYWORD) + *tok = pdf_cmap_token_from_keyword(buf); return fz_okay; } static fz_error -pdf_parsecmapname(pdf_cmap *cmap, fz_stream *file) +pdf_parse_cmap_name(pdf_cmap *cmap, fz_stream *file) { fz_error error; char buf[256]; int tok; int len; - error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len); + error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "syntaxerror in cmap"); - if (tok == PDF_TNAME) - fz_strlcpy(cmap->cmapname, buf, sizeof(cmap->cmapname)); + if (tok == PDF_TOK_NAME) + fz_strlcpy(cmap->cmap_name, buf, sizeof(cmap->cmap_name)); else fz_warn("expected name after CMapName in cmap"); @@ -84,19 +84,19 @@ pdf_parsecmapname(pdf_cmap *cmap, fz_stream *file) } static fz_error -pdf_parsewmode(pdf_cmap *cmap, fz_stream *file) +pdf_parse_wmode(pdf_cmap *cmap, fz_stream *file) { fz_error error; char buf[256]; int tok; int len; - error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len); + error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "syntaxerror in cmap"); - if (tok == PDF_TINT) - pdf_setwmode(cmap, atoi(buf)); + if (tok == PDF_TOK_INT) + pdf_set_wmode(cmap, atoi(buf)); else fz_warn("expected integer after WMode in cmap"); @@ -104,7 +104,7 @@ pdf_parsewmode(pdf_cmap *cmap, fz_stream *file) } static fz_error -pdf_parsecodespacerange(pdf_cmap *cmap, fz_stream *file) +pdf_parse_codespace_range(pdf_cmap *cmap, fz_stream *file) { fz_error error; char buf[256]; @@ -114,23 +114,23 @@ pdf_parsecodespacerange(pdf_cmap *cmap, fz_stream *file) while (1) { - error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len); + error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "syntaxerror in cmap"); - if (tok == TENDCODESPACERANGE) + if (tok == TOK_END_CODESPACE_RANGE) return fz_okay; - else if (tok == PDF_TSTRING) + else if (tok == PDF_TOK_STRING) { - lo = pdf_codefromstring(buf, len); - error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len); + lo = pdf_code_from_string(buf, len); + error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "syntaxerror in cmap"); - if (tok == PDF_TSTRING) + if (tok == PDF_TOK_STRING) { - hi = pdf_codefromstring(buf, len); - pdf_addcodespace(cmap, lo, hi, len); + hi = pdf_code_from_string(buf, len); + pdf_add_codespace(cmap, lo, hi, len); } else break; } @@ -142,7 +142,7 @@ pdf_parsecodespacerange(pdf_cmap *cmap, fz_stream *file) } static fz_error -pdf_parsecidrange(pdf_cmap *cmap, fz_stream *file) +pdf_parse_cid_range(pdf_cmap *cmap, fz_stream *file) { fz_error error; char buf[256]; @@ -152,40 +152,40 @@ pdf_parsecidrange(pdf_cmap *cmap, fz_stream *file) while (1) { - error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len); + error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "syntaxerror in cmap"); - if (tok == TENDCIDRANGE) + if (tok == TOK_END_CID_RANGE) return fz_okay; - else if (tok != PDF_TSTRING) + else if (tok != PDF_TOK_STRING) return fz_throw("expected string or endcidrange"); - lo = pdf_codefromstring(buf, len); + lo = pdf_code_from_string(buf, len); - error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len); + error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "syntaxerror in cmap"); - if (tok != PDF_TSTRING) + if (tok != PDF_TOK_STRING) return fz_throw("expected string"); - hi = pdf_codefromstring(buf, len); + hi = pdf_code_from_string(buf, len); - error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len); + error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "syntaxerror in cmap"); - if (tok != PDF_TINT) + if (tok != PDF_TOK_INT) return fz_throw("expected integer"); dst = atoi(buf); - pdf_maprangetorange(cmap, lo, hi, dst); + pdf_map_range_to_range(cmap, lo, hi, dst); } } static fz_error -pdf_parsecidchar(pdf_cmap *cmap, fz_stream *file) +pdf_parse_cid_char(pdf_cmap *cmap, fz_stream *file) { fz_error error; char buf[256]; @@ -195,32 +195,32 @@ pdf_parsecidchar(pdf_cmap *cmap, fz_stream *file) while (1) { - error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len); + error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "syntaxerror in cmap"); - if (tok == TENDCIDCHAR) + if (tok == TOK_END_CID_CHAR) return fz_okay; - else if (tok != PDF_TSTRING) + else if (tok != PDF_TOK_STRING) return fz_throw("expected string or endcidchar"); - src = pdf_codefromstring(buf, len); + src = pdf_code_from_string(buf, len); - error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len); + error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "syntaxerror in cmap"); - if (tok != PDF_TINT) + if (tok != PDF_TOK_INT) return fz_throw("expected integer"); dst = atoi(buf); - pdf_maprangetorange(cmap, src, src, dst); + pdf_map_range_to_range(cmap, src, src, dst); } } static fz_error -pdf_parsebfrangearray(pdf_cmap *cmap, fz_stream *file, int lo, int hi) +pdf_parse_bf_range_array(pdf_cmap *cmap, fz_stream *file, int lo, int hi) { fz_error error; char buf[256]; @@ -231,23 +231,23 @@ pdf_parsebfrangearray(pdf_cmap *cmap, fz_stream *file, int lo, int hi) while (1) { - error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len); + error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "syntaxerror in cmap"); - if (tok == PDF_TCARRAY) + if (tok == PDF_TOK_CLOSE_ARRAY) return fz_okay; /* Note: does not handle [ /Name /Name ... ] */ - else if (tok != PDF_TSTRING) + else if (tok != PDF_TOK_STRING) return fz_throw("expected string or ]"); if (len / 2) { for (i = 0; i < len / 2; i++) - dst[i] = pdf_codefromstring(buf + i * 2, 2); + dst[i] = pdf_code_from_string(buf + i * 2, 2); - pdf_maponetomany(cmap, lo, dst, len / 2); + pdf_map_one_to_many(cmap, lo, dst, len / 2); } lo ++; @@ -255,7 +255,7 @@ pdf_parsebfrangearray(pdf_cmap *cmap, fz_stream *file, int lo, int hi) } static fz_error -pdf_parsebfrange(pdf_cmap *cmap, fz_stream *file) +pdf_parse_bf_range(pdf_cmap *cmap, fz_stream *file) { fz_error error; char buf[256]; @@ -265,36 +265,36 @@ pdf_parsebfrange(pdf_cmap *cmap, fz_stream *file) while (1) { - error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len); + error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "syntaxerror in cmap"); - if (tok == TENDBFRANGE) + if (tok == TOK_END_BF_RANGE) return fz_okay; - else if (tok != PDF_TSTRING) + else if (tok != PDF_TOK_STRING) return fz_throw("expected string or endbfrange"); - lo = pdf_codefromstring(buf, len); + lo = pdf_code_from_string(buf, len); - error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len); + error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "syntaxerror in cmap"); - if (tok != PDF_TSTRING) + if (tok != PDF_TOK_STRING) return fz_throw("expected string"); - hi = pdf_codefromstring(buf, len); + hi = pdf_code_from_string(buf, len); - error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len); + error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "syntaxerror in cmap"); - if (tok == PDF_TSTRING) + if (tok == PDF_TOK_STRING) { if (len == 2) { - dst = pdf_codefromstring(buf, len); - pdf_maprangetorange(cmap, lo, hi, dst); + dst = pdf_code_from_string(buf, len); + pdf_map_range_to_range(cmap, lo, hi, dst); } else { @@ -304,21 +304,21 @@ pdf_parsebfrange(pdf_cmap *cmap, fz_stream *file) if (len / 2) { for (i = 0; i < len / 2; i++) - dststr[i] = pdf_codefromstring(buf + i * 2, 2); + dststr[i] = pdf_code_from_string(buf + i * 2, 2); while (lo <= hi) { dststr[i-1] ++; - pdf_maponetomany(cmap, lo, dststr, i); + pdf_map_one_to_many(cmap, lo, dststr, i); lo ++; } } } } - else if (tok == PDF_TOARRAY) + else if (tok == PDF_TOK_OPEN_ARRAY) { - error = pdf_parsebfrangearray(cmap, file, lo, hi); + error = pdf_parse_bf_range_array(cmap, file, lo, hi); if (error) return fz_rethrow(error, "cannot map bfrange"); } @@ -331,7 +331,7 @@ pdf_parsebfrange(pdf_cmap *cmap, fz_stream *file) } static fz_error -pdf_parsebfchar(pdf_cmap *cmap, fz_stream *file) +pdf_parse_bf_char(pdf_cmap *cmap, fz_stream *file) { fz_error error; char buf[256]; @@ -343,36 +343,36 @@ pdf_parsebfchar(pdf_cmap *cmap, fz_stream *file) while (1) { - error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len); + error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "syntaxerror in cmap"); - if (tok == TENDBFCHAR) + if (tok == TOK_END_BF_CHAR) return fz_okay; - else if (tok != PDF_TSTRING) + else if (tok != PDF_TOK_STRING) return fz_throw("expected string or endbfchar"); - src = pdf_codefromstring(buf, len); + src = pdf_code_from_string(buf, len); - error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len); + error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len); if (error) return fz_rethrow(error, "syntaxerror in cmap"); /* Note: does not handle /dstName */ - if (tok != PDF_TSTRING) + if (tok != PDF_TOK_STRING) return fz_throw("expected string"); if (len / 2) { for (i = 0; i < len / 2; i++) - dst[i] = pdf_codefromstring(buf + i * 2, 2); - pdf_maponetomany(cmap, src, dst, i); + dst[i] = pdf_code_from_string(buf + i * 2, 2); + pdf_map_one_to_many(cmap, src, dst, i); } } } fz_error -pdf_parsecmap(pdf_cmap **cmapp, fz_stream *file) +pdf_parse_cmap(pdf_cmap **cmapp, fz_stream *file) { fz_error error; pdf_cmap *cmap; @@ -381,27 +381,27 @@ pdf_parsecmap(pdf_cmap **cmapp, fz_stream *file) int tok; int len; - cmap = pdf_newcmap(); + cmap = pdf_new_cmap(); strcpy(key, ".notdef"); while (1) { - error = pdf_lexcmap(&tok, file, buf, sizeof buf, &len); + error = pdf_lex_cmap(&tok, file, buf, sizeof buf, &len); if (error) { error = fz_rethrow(error, "syntaxerror in cmap"); goto cleanup; } - if (tok == PDF_TEOF || tok == TENDCMAP) + if (tok == PDF_TOK_EOF || tok == TOK_END_CMAP) break; - else if (tok == PDF_TNAME) + else if (tok == PDF_TOK_NAME) { if (!strcmp(buf, "CMapName")) { - error = pdf_parsecmapname(cmap, file); + error = pdf_parse_cmap_name(cmap, file); if (error) { error = fz_rethrow(error, "syntaxerror in cmap after CMapName"); @@ -410,7 +410,7 @@ pdf_parsecmap(pdf_cmap **cmapp, fz_stream *file) } else if (!strcmp(buf, "WMode")) { - error = pdf_parsewmode(cmap, file); + error = pdf_parse_wmode(cmap, file); if (error) { error = fz_rethrow(error, "syntaxerror in cmap after WMode"); @@ -421,14 +421,14 @@ pdf_parsecmap(pdf_cmap **cmapp, fz_stream *file) fz_strlcpy(key, buf, sizeof key); } - else if (tok == TUSECMAP) + else if (tok == TOK_USECMAP) { - fz_strlcpy(cmap->usecmapname, key, sizeof(cmap->usecmapname)); + fz_strlcpy(cmap->usecmap_name, key, sizeof(cmap->usecmap_name)); } - else if (tok == TBEGINCODESPACERANGE) + else if (tok == TOK_BEGIN_CODESPACE_RANGE) { - error = pdf_parsecodespacerange(cmap, file); + error = pdf_parse_codespace_range(cmap, file); if (error) { error = fz_rethrow(error, "syntaxerror in cmap codespacerange"); @@ -436,9 +436,9 @@ pdf_parsecmap(pdf_cmap **cmapp, fz_stream *file) } } - else if (tok == TBEGINBFCHAR) + else if (tok == TOK_BEGIN_BF_CHAR) { - error = pdf_parsebfchar(cmap, file); + error = pdf_parse_bf_char(cmap, file); if (error) { error = fz_rethrow(error, "syntaxerror in cmap bfchar"); @@ -446,9 +446,9 @@ pdf_parsecmap(pdf_cmap **cmapp, fz_stream *file) } } - else if (tok == TBEGINCIDCHAR) + else if (tok == TOK_BEGIN_CID_CHAR) { - error = pdf_parsecidchar(cmap, file); + error = pdf_parse_cid_char(cmap, file); if (error) { error = fz_rethrow(error, "syntaxerror in cmap cidchar"); @@ -456,9 +456,9 @@ pdf_parsecmap(pdf_cmap **cmapp, fz_stream *file) } } - else if (tok == TBEGINBFRANGE) + else if (tok == TOK_BEGIN_BF_RANGE) { - error = pdf_parsebfrange(cmap, file); + error = pdf_parse_bf_range(cmap, file); if (error) { error = fz_rethrow(error, "syntaxerror in cmap bfrange"); @@ -466,9 +466,9 @@ pdf_parsecmap(pdf_cmap **cmapp, fz_stream *file) } } - else if (tok == TBEGINCIDRANGE) + else if (tok == TOK_BEGIN_CID_RANGE) { - error = pdf_parsecidrange(cmap, file); + error = pdf_parse_cid_range(cmap, file); if (error) { error = fz_rethrow(error, "syntaxerror in cmap cidrange"); @@ -479,12 +479,12 @@ pdf_parsecmap(pdf_cmap **cmapp, fz_stream *file) /* ignore everything else */ } - pdf_sortcmap(cmap); + pdf_sort_cmap(cmap); *cmapp = cmap; return fz_okay; cleanup: - pdf_dropcmap(cmap); + pdf_drop_cmap(cmap); return error; /* already rethrown */ } diff --git a/pdf/pdf_cmap_table.c b/pdf/pdf_cmap_table.c index a1f61365..1413de25 100644 --- a/pdf/pdf_cmap_table.c +++ b/pdf/pdf_cmap_table.c @@ -158,7 +158,7 @@ extern pdf_cmap pdf_cmap_Adobe_GB1_UCS2; extern pdf_cmap pdf_cmap_Adobe_Japan1_UCS2; extern pdf_cmap pdf_cmap_Adobe_Korea1_UCS2; -pdf_cmap *pdf_cmaptable[] = +pdf_cmap *pdf_cmap_table[] = { #ifndef NOCJK &pdf_cmap_Adobe_CNS1_0, diff --git a/pdf/pdf_colorspace.c b/pdf/pdf_colorspace.c index 6203e1bb..11316fbe 100644 --- a/pdf/pdf_colorspace.c +++ b/pdf/pdf_colorspace.c @@ -4,19 +4,19 @@ /* ICCBased */ static fz_error -loadiccbased(fz_colorspace **csp, pdf_xref *xref, fz_obj *dict) +load_icc_based(fz_colorspace **csp, pdf_xref *xref, fz_obj *dict) { int n; - pdf_logrsrc("load ICCBased\n"); + pdf_log_rsrc("load ICCBased\n"); - n = fz_toint(fz_dictgets(dict, "N")); + n = fz_to_int(fz_dict_gets(dict, "N")); switch (n) { - case 1: *csp = fz_devicegray; return fz_okay; - case 3: *csp = fz_devicergb; return fz_okay; - case 4: *csp = fz_devicecmyk; return fz_okay; + case 1: *csp = fz_device_gray; return fz_okay; + case 3: *csp = fz_device_rgb; return fz_okay; + case 4: *csp = fz_device_cmyk; return fz_okay; } return fz_throw("syntaxerror: ICCBased must have 1, 3 or 4 components"); @@ -39,7 +39,7 @@ static inline float invg(float x) } static void -labtoxyz(fz_colorspace *cs, float *lab, float *xyz) +lab_to_xyz(fz_colorspace *cs, float *lab, float *xyz) { /* input is in range (0..100, -128..127, -128..127) not (0..1, 0..1, 0..1) */ float lstar, astar, bstar, l, m, n; @@ -55,7 +55,7 @@ labtoxyz(fz_colorspace *cs, float *lab, float *xyz) } static void -xyztolab(fz_colorspace *cs, float *xyz, float *lab) +xyz_to_lab(fz_colorspace *cs, float *xyz, float *lab) { float lstar, astar, bstar; float yyn = xyz[1]; @@ -70,8 +70,8 @@ xyztolab(fz_colorspace *cs, float *xyz, float *lab) lab[2] = bstar; } -static fz_colorspace kdevicelab = { -1, "Lab", 3, labtoxyz, xyztolab }; -static fz_colorspace *fz_devicelab = &kdevicelab; +static fz_colorspace k_device_lab = { -1, "Lab", 3, lab_to_xyz, xyz_to_lab }; +static fz_colorspace *fz_device_lab = &k_device_lab; /* Separation and DeviceN */ @@ -82,69 +82,69 @@ struct separation }; static void -separationtoxyz(fz_colorspace *cs, float *color, float *xyz) +separation_to_xyz(fz_colorspace *cs, float *color, float *xyz) { struct separation *sep = cs->data; - float alt[FZ_MAXCOLORS]; - pdf_evalfunction(sep->tint, color, cs->n, alt, sep->base->n); - sep->base->toxyz(sep->base, alt, xyz); + float alt[FZ_MAX_COLORS]; + pdf_eval_function(sep->tint, color, cs->n, alt, sep->base->n); + sep->base->to_xyz(sep->base, alt, xyz); } static void -freeseparation(fz_colorspace *cs) +free_separation(fz_colorspace *cs) { struct separation *sep = cs->data; - fz_dropcolorspace(sep->base); - pdf_dropfunction(sep->tint); + fz_drop_colorspace(sep->base); + pdf_drop_function(sep->tint); fz_free(sep); } static fz_error -loadseparation(fz_colorspace **csp, pdf_xref *xref, fz_obj *array) +load_separation(fz_colorspace **csp, pdf_xref *xref, fz_obj *array) { fz_error error; fz_colorspace *cs; struct separation *sep; - fz_obj *nameobj = fz_arrayget(array, 1); - fz_obj *baseobj = fz_arrayget(array, 2); - fz_obj *tintobj = fz_arrayget(array, 3); + fz_obj *nameobj = fz_array_get(array, 1); + fz_obj *baseobj = fz_array_get(array, 2); + fz_obj *tintobj = fz_array_get(array, 3); fz_colorspace *base; pdf_function *tint; int n; - pdf_logrsrc("load Separation {\n"); + pdf_log_rsrc("load Separation {\n"); - if (fz_isarray(nameobj)) - n = fz_arraylen(nameobj); + if (fz_is_array(nameobj)) + n = fz_array_len(nameobj); else n = 1; - if (n > FZ_MAXCOLORS) + if (n > FZ_MAX_COLORS) return fz_throw("too many components in colorspace"); - pdf_logrsrc("n = %d\n", n); + pdf_log_rsrc("n = %d\n", n); - error = pdf_loadcolorspace(&base, xref, baseobj); + error = pdf_load_colorspace(&base, xref, baseobj); if (error) - return fz_rethrow(error, "cannot load base colorspace (%d %d R)", fz_tonum(baseobj), fz_togen(baseobj)); + return fz_rethrow(error, "cannot load base colorspace (%d %d R)", fz_to_num(baseobj), fz_to_gen(baseobj)); - error = pdf_loadfunction(&tint, xref, tintobj); + error = pdf_load_function(&tint, xref, tintobj); if (error) { - fz_dropcolorspace(base); - return fz_rethrow(error, "cannot load tint function (%d %d R)", fz_tonum(tintobj), fz_togen(tintobj)); + fz_drop_colorspace(base); + return fz_rethrow(error, "cannot load tint function (%d %d R)", fz_to_num(tintobj), fz_to_gen(tintobj)); } sep = fz_malloc(sizeof(struct separation)); sep->base = base; sep->tint = tint; - cs = fz_newcolorspace(n == 1 ? "Separation" : "DeviceN", n); - cs->toxyz = separationtoxyz; - cs->freedata = freeseparation; + cs = fz_new_colorspace(n == 1 ? "Separation" : "DeviceN", n); + cs->to_xyz = separation_to_xyz; + cs->free_data = free_separation; cs->data = sep; - pdf_logrsrc("}\n"); + pdf_log_rsrc("}\n"); *csp = cs; return fz_okay; @@ -160,30 +160,30 @@ struct indexed }; static void -indexedtoxyz(fz_colorspace *cs, float *color, float *xyz) +indexed_to_xyz(fz_colorspace *cs, float *color, float *xyz) { struct indexed *idx = cs->data; - float alt[FZ_MAXCOLORS]; + float alt[FZ_MAX_COLORS]; int i, k; i = color[0] * 255; i = CLAMP(i, 0, idx->high); for (k = 0; k < idx->base->n; k++) alt[k] = idx->lookup[i * idx->base->n + k] / 255.0f; - idx->base->toxyz(idx->base, alt, xyz); + idx->base->to_xyz(idx->base, alt, xyz); } static void -freeindexed(fz_colorspace *cs) +free_indexed(fz_colorspace *cs) { struct indexed *idx = cs->data; if (idx->base) - fz_dropcolorspace(idx->base); + fz_drop_colorspace(idx->base); fz_free(idx->lookup); fz_free(idx); } fz_pixmap * -pdf_expandindexedpixmap(fz_pixmap *src) +pdf_expand_indexed_pixmap(fz_pixmap *src) { struct indexed *idx; fz_pixmap *dst; @@ -191,7 +191,7 @@ pdf_expandindexedpixmap(fz_pixmap *src) int y, x, k, n, high; unsigned char *lookup; - assert(src->colorspace->toxyz == indexedtoxyz); + assert(src->colorspace->to_xyz == indexed_to_xyz); assert(src->n == 2); idx = src->colorspace->data; @@ -199,7 +199,7 @@ pdf_expandindexedpixmap(fz_pixmap *src) lookup = idx->lookup; n = idx->base->n; - dst = fz_newpixmap(idx->base, src->x, src->y, src->w, src->h); + dst = fz_new_pixmap(idx->base, src->x, src->y, src->w, src->h); s = src->samples; d = dst->samples; @@ -217,84 +217,84 @@ pdf_expandindexedpixmap(fz_pixmap *src) } if (src->mask) - dst->mask = fz_keeppixmap(src->mask); + dst->mask = fz_keep_pixmap(src->mask); dst->interpolate = src->interpolate; return dst; } static fz_error -loadindexed(fz_colorspace **csp, pdf_xref *xref, fz_obj *array) +load_indexed(fz_colorspace **csp, pdf_xref *xref, fz_obj *array) { fz_error error; fz_colorspace *cs; struct indexed *idx; - fz_obj *baseobj = fz_arrayget(array, 1); - fz_obj *highobj = fz_arrayget(array, 2); - fz_obj *lookup = fz_arrayget(array, 3); + fz_obj *baseobj = fz_array_get(array, 1); + fz_obj *highobj = fz_array_get(array, 2); + fz_obj *lookup = fz_array_get(array, 3); fz_colorspace *base; int i, n; - pdf_logrsrc("load Indexed {\n"); + pdf_log_rsrc("load Indexed {\n"); - error = pdf_loadcolorspace(&base, xref, baseobj); + error = pdf_load_colorspace(&base, xref, baseobj); if (error) - return fz_rethrow(error, "cannot load base colorspace (%d %d R)", fz_tonum(baseobj), fz_togen(baseobj)); + return fz_rethrow(error, "cannot load base colorspace (%d %d R)", fz_to_num(baseobj), fz_to_gen(baseobj)); - pdf_logrsrc("base %s\n", base->name); + pdf_log_rsrc("base %s\n", base->name); idx = fz_malloc(sizeof(struct indexed)); idx->base = base; - idx->high = fz_toint(highobj); + idx->high = fz_to_int(highobj); idx->high = CLAMP(idx->high, 0, 255); n = base->n * (idx->high + 1); idx->lookup = fz_malloc(n); memset(idx->lookup, 0, n); - cs = fz_newcolorspace("Indexed", 1); - cs->toxyz = indexedtoxyz; - cs->freedata = freeindexed; + cs = fz_new_colorspace("Indexed", 1); + cs->to_xyz = indexed_to_xyz; + cs->free_data = free_indexed; cs->data = idx; - if (fz_isstring(lookup) && fz_tostrlen(lookup) == n) + if (fz_is_string(lookup) && fz_to_str_len(lookup) == n) { unsigned char *buf; - pdf_logrsrc("string lookup\n"); + pdf_log_rsrc("string lookup\n"); - buf = (unsigned char *) fz_tostrbuf(lookup); + buf = (unsigned char *) fz_to_str_buf(lookup); for (i = 0; i < n; i++) idx->lookup[i] = buf[i]; } - else if (fz_isindirect(lookup)) + else if (fz_is_indirect(lookup)) { fz_stream *file; - pdf_logrsrc("stream lookup\n"); + pdf_log_rsrc("stream lookup\n"); - error = pdf_openstream(&file, xref, fz_tonum(lookup), fz_togen(lookup)); + error = pdf_open_stream(&file, xref, fz_to_num(lookup), fz_to_gen(lookup)); if (error) { - fz_dropcolorspace(cs); - return fz_rethrow(error, "cannot open colorspace lookup table (%d 0 R)", fz_tonum(lookup)); + fz_drop_colorspace(cs); + return fz_rethrow(error, "cannot open colorspace lookup table (%d 0 R)", fz_to_num(lookup)); } i = fz_read(file, idx->lookup, n); if (i < 0) { - fz_dropcolorspace(cs); - return fz_throw("cannot read colorspace lookup table (%d 0 R)", fz_tonum(lookup)); + fz_drop_colorspace(cs); + return fz_throw("cannot read colorspace lookup table (%d 0 R)", fz_to_num(lookup)); } fz_close(file); } else { - fz_dropcolorspace(cs); + fz_drop_colorspace(cs); return fz_throw("cannot parse colorspace lookup table"); } - pdf_logrsrc("}\n"); + pdf_log_rsrc("}\n"); *csp = cs; return fz_okay; @@ -303,113 +303,113 @@ loadindexed(fz_colorspace **csp, pdf_xref *xref, fz_obj *array) /* Parse and create colorspace from PDF object */ static fz_error -pdf_loadcolorspaceimp(fz_colorspace **csp, pdf_xref *xref, fz_obj *obj) +pdf_load_colorspace_imp(fz_colorspace **csp, pdf_xref *xref, fz_obj *obj) { - if (fz_isname(obj)) + if (fz_is_name(obj)) { - if (!strcmp(fz_toname(obj), "Pattern")) - *csp = fz_devicegray; - else if (!strcmp(fz_toname(obj), "G")) - *csp = fz_devicegray; - else if (!strcmp(fz_toname(obj), "RGB")) - *csp = fz_devicergb; - else if (!strcmp(fz_toname(obj), "CMYK")) - *csp = fz_devicecmyk; - else if (!strcmp(fz_toname(obj), "DeviceGray")) - *csp = fz_devicegray; - else if (!strcmp(fz_toname(obj), "DeviceRGB")) - *csp = fz_devicergb; - else if (!strcmp(fz_toname(obj), "DeviceCMYK")) - *csp = fz_devicecmyk; + if (!strcmp(fz_to_name(obj), "Pattern")) + *csp = fz_device_gray; + else if (!strcmp(fz_to_name(obj), "G")) + *csp = fz_device_gray; + else if (!strcmp(fz_to_name(obj), "RGB")) + *csp = fz_device_rgb; + else if (!strcmp(fz_to_name(obj), "CMYK")) + *csp = fz_device_cmyk; + else if (!strcmp(fz_to_name(obj), "DeviceGray")) + *csp = fz_device_gray; + else if (!strcmp(fz_to_name(obj), "DeviceRGB")) + *csp = fz_device_rgb; + else if (!strcmp(fz_to_name(obj), "DeviceCMYK")) + *csp = fz_device_cmyk; else - return fz_throw("unknown colorspace: %s", fz_toname(obj)); + return fz_throw("unknown colorspace: %s", fz_to_name(obj)); return fz_okay; } - else if (fz_isarray(obj)) + else if (fz_is_array(obj)) { - fz_obj *name = fz_arrayget(obj, 0); + fz_obj *name = fz_array_get(obj, 0); - if (fz_isname(name)) + if (fz_is_name(name)) { /* load base colorspace instead */ - if (!strcmp(fz_toname(name), "Pattern")) + if (!strcmp(fz_to_name(name), "Pattern")) { fz_error error; - obj = fz_arrayget(obj, 1); + obj = fz_array_get(obj, 1); if (!obj) { - *csp = fz_devicegray; + *csp = fz_device_gray; return fz_okay; } - error = pdf_loadcolorspace(csp, xref, obj); + error = pdf_load_colorspace(csp, xref, obj); if (error) - return fz_rethrow(error, "cannot load pattern (%d %d R)", fz_tonum(obj), fz_togen(obj)); + return fz_rethrow(error, "cannot load pattern (%d %d R)", fz_to_num(obj), fz_to_gen(obj)); } - else if (!strcmp(fz_toname(name), "G")) - *csp = fz_devicegray; - else if (!strcmp(fz_toname(name), "RGB")) - *csp = fz_devicergb; - else if (!strcmp(fz_toname(name), "CMYK")) - *csp = fz_devicecmyk; - else if (!strcmp(fz_toname(name), "DeviceGray")) - *csp = fz_devicegray; - else if (!strcmp(fz_toname(name), "DeviceRGB")) - *csp = fz_devicergb; - else if (!strcmp(fz_toname(name), "DeviceCMYK")) - *csp = fz_devicecmyk; - else if (!strcmp(fz_toname(name), "CalGray")) - *csp = fz_devicegray; - else if (!strcmp(fz_toname(name), "CalRGB")) - *csp = fz_devicergb; - else if (!strcmp(fz_toname(name), "CalCMYK")) - *csp = fz_devicecmyk; - else if (!strcmp(fz_toname(name), "Lab")) - *csp = fz_devicelab; - - else if (!strcmp(fz_toname(name), "ICCBased")) - return loadiccbased(csp, xref, fz_arrayget(obj, 1)); - - else if (!strcmp(fz_toname(name), "Indexed")) - return loadindexed(csp, xref, obj); - else if (!strcmp(fz_toname(name), "I")) - return loadindexed(csp, xref, obj); - - else if (!strcmp(fz_toname(name), "Separation")) - return loadseparation(csp, xref, obj); - - else if (!strcmp(fz_toname(name), "DeviceN")) - return loadseparation(csp, xref, obj); + else if (!strcmp(fz_to_name(name), "G")) + *csp = fz_device_gray; + else if (!strcmp(fz_to_name(name), "RGB")) + *csp = fz_device_rgb; + else if (!strcmp(fz_to_name(name), "CMYK")) + *csp = fz_device_cmyk; + else if (!strcmp(fz_to_name(name), "DeviceGray")) + *csp = fz_device_gray; + else if (!strcmp(fz_to_name(name), "DeviceRGB")) + *csp = fz_device_rgb; + else if (!strcmp(fz_to_name(name), "DeviceCMYK")) + *csp = fz_device_cmyk; + else if (!strcmp(fz_to_name(name), "CalGray")) + *csp = fz_device_gray; + else if (!strcmp(fz_to_name(name), "CalRGB")) + *csp = fz_device_rgb; + else if (!strcmp(fz_to_name(name), "CalCMYK")) + *csp = fz_device_cmyk; + else if (!strcmp(fz_to_name(name), "Lab")) + *csp = fz_device_lab; + + else if (!strcmp(fz_to_name(name), "ICCBased")) + return load_icc_based(csp, xref, fz_array_get(obj, 1)); + + else if (!strcmp(fz_to_name(name), "Indexed")) + return load_indexed(csp, xref, obj); + else if (!strcmp(fz_to_name(name), "I")) + return load_indexed(csp, xref, obj); + + else if (!strcmp(fz_to_name(name), "Separation")) + return load_separation(csp, xref, obj); + + else if (!strcmp(fz_to_name(name), "DeviceN")) + return load_separation(csp, xref, obj); else - return fz_throw("syntaxerror: unknown colorspace %s", fz_toname(name)); + return fz_throw("syntaxerror: unknown colorspace %s", fz_to_name(name)); return fz_okay; } } - return fz_throw("syntaxerror: could not parse color space (%d %d R)", fz_tonum(obj), fz_togen(obj)); + return fz_throw("syntaxerror: could not parse color space (%d %d R)", fz_to_num(obj), fz_to_gen(obj)); } fz_error -pdf_loadcolorspace(fz_colorspace **csp, pdf_xref *xref, fz_obj *obj) +pdf_load_colorspace(fz_colorspace **csp, pdf_xref *xref, fz_obj *obj) { fz_error error; - if ((*csp = pdf_finditem(xref->store, fz_dropcolorspace, obj))) + if ((*csp = pdf_find_item(xref->store, fz_drop_colorspace, obj))) { - fz_keepcolorspace(*csp); + fz_keep_colorspace(*csp); return fz_okay; } - error = pdf_loadcolorspaceimp(csp, xref, obj); + error = pdf_load_colorspace_imp(csp, xref, obj); if (error) - return fz_rethrow(error, "cannot load colorspace (%d %d R)", fz_tonum(obj), fz_togen(obj)); + return fz_rethrow(error, "cannot load colorspace (%d %d R)", fz_to_num(obj), fz_to_gen(obj)); - pdf_storeitem(xref->store, fz_keepcolorspace, fz_dropcolorspace, obj, *csp); + pdf_store_item(xref->store, fz_keep_colorspace, fz_drop_colorspace, obj, *csp); return fz_okay; } diff --git a/pdf/pdf_crypt.c b/pdf/pdf_crypt.c index 6266e188..cdf35d70 100644 --- a/pdf/pdf_crypt.c +++ b/pdf/pdf_crypt.c @@ -7,7 +7,7 @@ */ fz_error -pdf_newcrypt(pdf_crypt **cryptp, fz_obj *dict, fz_obj *id) +pdf_new_crypt(pdf_crypt **cryptp, fz_obj *dict, fz_obj *id) { pdf_crypt *crypt; fz_error error; @@ -15,38 +15,38 @@ pdf_newcrypt(pdf_crypt **cryptp, fz_obj *dict, fz_obj *id) crypt = fz_malloc(sizeof(pdf_crypt)); memset(crypt, 0x00, sizeof(pdf_crypt)); - crypt->cf = nil; + crypt->cf = NULL; /* Common to all security handlers (PDF 1.7 table 3.18) */ - obj = fz_dictgets(dict, "Filter"); - if (!fz_isname(obj)) + obj = fz_dict_gets(dict, "Filter"); + if (!fz_is_name(obj)) { - pdf_freecrypt(crypt); + pdf_free_crypt(crypt); return fz_throw("unspecified encryption handler"); } - if (strcmp(fz_toname(obj), "Standard") != 0) + if (strcmp(fz_to_name(obj), "Standard") != 0) { - pdf_freecrypt(crypt); - return fz_throw("unknown encryption handler: '%s'", fz_toname(obj)); + pdf_free_crypt(crypt); + return fz_throw("unknown encryption handler: '%s'", fz_to_name(obj)); } crypt->v = 0; - obj = fz_dictgets(dict, "V"); - if (fz_isint(obj)) - crypt->v = fz_toint(obj); + obj = fz_dict_gets(dict, "V"); + if (fz_is_int(obj)) + crypt->v = fz_to_int(obj); if (crypt->v != 1 && crypt->v != 2 && crypt->v != 4 && crypt->v != 5) { - pdf_freecrypt(crypt); + pdf_free_crypt(crypt); return fz_throw("unknown encryption version"); } crypt->length = 40; if (crypt->v == 2 || crypt->v == 4) { - obj = fz_dictgets(dict, "Length"); - if (fz_isint(obj)) - crypt->length = fz_toint(obj); + obj = fz_dict_gets(dict, "Length"); + if (fz_is_int(obj)) + crypt->length = fz_to_int(obj); /* work-around for pdf generators that assume length is in bytes */ if (crypt->length < 40) @@ -54,12 +54,12 @@ pdf_newcrypt(pdf_crypt **cryptp, fz_obj *dict, fz_obj *id) if (crypt->length % 8 != 0) { - pdf_freecrypt(crypt); + pdf_free_crypt(crypt); return fz_throw("invalid encryption key length"); } if (crypt->length > 256) { - pdf_freecrypt(crypt); + pdf_free_crypt(crypt); return fz_throw("invalid encryption key length"); } } @@ -84,39 +84,39 @@ pdf_newcrypt(pdf_crypt **cryptp, fz_obj *dict, fz_obj *id) crypt->strf.method = PDF_CRYPT_NONE; crypt->strf.length = crypt->length; - obj = fz_dictgets(dict, "CF"); - if (fz_isdict(obj)) + obj = fz_dict_gets(dict, "CF"); + if (fz_is_dict(obj)) { - crypt->cf = fz_keepobj(obj); + crypt->cf = fz_keep_obj(obj); - obj = fz_dictgets(dict, "StmF"); - if (fz_isname(obj)) + obj = fz_dict_gets(dict, "StmF"); + if (fz_is_name(obj)) { /* should verify that it is either Identity or StdCF */ - obj = fz_dictgets(crypt->cf, fz_toname(obj)); - if (fz_isdict(obj)) + obj = fz_dict_gets(crypt->cf, fz_to_name(obj)); + if (fz_is_dict(obj)) { - error = pdf_parsecryptfilter(&crypt->stmf, obj, crypt->length); + error = pdf_parse_crypt_filter(&crypt->stmf, obj, crypt->length); if (error) { - pdf_freecrypt(crypt); - return fz_rethrow(error, "cannot parse stream crypt filter (%d %d R)", fz_tonum(obj), fz_togen(obj)); + pdf_free_crypt(crypt); + return fz_rethrow(error, "cannot parse stream crypt filter (%d %d R)", fz_to_num(obj), fz_to_gen(obj)); } } } - obj = fz_dictgets(dict, "StrF"); - if (fz_isname(obj)) + obj = fz_dict_gets(dict, "StrF"); + if (fz_is_name(obj)) { /* should verify that it is either Identity or StdCF */ - obj = fz_dictgets(crypt->cf, fz_toname(obj)); - if (fz_isdict(obj)) + obj = fz_dict_gets(crypt->cf, fz_to_name(obj)); + if (fz_is_dict(obj)) { - error = pdf_parsecryptfilter(&crypt->strf, obj, crypt->length); + error = pdf_parse_crypt_filter(&crypt->strf, obj, crypt->length); if (error) { - pdf_freecrypt(crypt); - return fz_rethrow(error, "cannot parse string crypt filter (%d %d R)", fz_tonum(obj), fz_togen(obj)); + pdf_free_crypt(crypt); + return fz_rethrow(error, "cannot parse string crypt filter (%d %d R)", fz_to_num(obj), fz_to_gen(obj)); } } } @@ -129,84 +129,84 @@ pdf_newcrypt(pdf_crypt **cryptp, fz_obj *dict, fz_obj *id) /* Standard security handler (PDF 1.7 table 3.19) */ - obj = fz_dictgets(dict, "R"); - if (fz_isint(obj)) - crypt->r = fz_toint(obj); + obj = fz_dict_gets(dict, "R"); + if (fz_is_int(obj)) + crypt->r = fz_to_int(obj); else { - pdf_freecrypt(crypt); + pdf_free_crypt(crypt); return fz_throw("encryption dictionary missing revision value"); } - obj = fz_dictgets(dict, "O"); - if (fz_isstring(obj) && fz_tostrlen(obj) == 32) - memcpy(crypt->o, fz_tostrbuf(obj), 32); + obj = fz_dict_gets(dict, "O"); + if (fz_is_string(obj) && fz_to_str_len(obj) == 32) + memcpy(crypt->o, fz_to_str_buf(obj), 32); /* /O and /U are supposed to be 48 bytes long for revision 5, they're often longer, though */ - else if (crypt->r == 5 && fz_isstring(obj) && fz_tostrlen(obj) >= 48) - memcpy(crypt->o, fz_tostrbuf(obj), 48); + else if (crypt->r == 5 && fz_is_string(obj) && fz_to_str_len(obj) >= 48) + memcpy(crypt->o, fz_to_str_buf(obj), 48); else { - pdf_freecrypt(crypt); + pdf_free_crypt(crypt); return fz_throw("encryption dictionary missing owner password"); } - obj = fz_dictgets(dict, "U"); - if (fz_isstring(obj) && fz_tostrlen(obj) == 32) - memcpy(crypt->u, fz_tostrbuf(obj), 32); - else if (fz_isstring(obj) && fz_tostrlen(obj) >= 48 && crypt->r == 5) - memcpy(crypt->u, fz_tostrbuf(obj), 48); + obj = fz_dict_gets(dict, "U"); + if (fz_is_string(obj) && fz_to_str_len(obj) == 32) + memcpy(crypt->u, fz_to_str_buf(obj), 32); + else if (fz_is_string(obj) && fz_to_str_len(obj) >= 48 && crypt->r == 5) + memcpy(crypt->u, fz_to_str_buf(obj), 48); else { - pdf_freecrypt(crypt); + pdf_free_crypt(crypt); return fz_throw("encryption dictionary missing user password"); } - obj = fz_dictgets(dict, "P"); - if (fz_isint(obj)) - crypt->p = fz_toint(obj); + obj = fz_dict_gets(dict, "P"); + if (fz_is_int(obj)) + crypt->p = fz_to_int(obj); else { - pdf_freecrypt(crypt); + pdf_free_crypt(crypt); return fz_throw("encryption dictionary missing permissions value"); } if (crypt->r == 5) { - obj = fz_dictgets(dict, "OE"); - if (!fz_isstring(obj) || fz_tostrlen(obj) != 32) + obj = fz_dict_gets(dict, "OE"); + if (!fz_is_string(obj) || fz_to_str_len(obj) != 32) { - pdf_freecrypt(crypt); + pdf_free_crypt(crypt); return fz_throw("encryption dictionary missing owner encryption key"); } - memcpy(crypt->oe, fz_tostrbuf(obj), 32); + memcpy(crypt->oe, fz_to_str_buf(obj), 32); - obj = fz_dictgets(dict, "UE"); - if (!fz_isstring(obj) || fz_tostrlen(obj) != 32) + obj = fz_dict_gets(dict, "UE"); + if (!fz_is_string(obj) || fz_to_str_len(obj) != 32) { - pdf_freecrypt(crypt); + pdf_free_crypt(crypt); return fz_throw("encryption dictionary missing user encryption key"); } - memcpy(crypt->ue, fz_tostrbuf(obj), 32); + memcpy(crypt->ue, fz_to_str_buf(obj), 32); } - crypt->encryptmetadata = 1; - obj = fz_dictgets(dict, "EncryptMetadata"); - if (fz_isbool(obj)) - crypt->encryptmetadata = fz_tobool(obj); + crypt->encrypt_metadata = 1; + obj = fz_dict_gets(dict, "EncryptMetadata"); + if (fz_is_bool(obj)) + crypt->encrypt_metadata = fz_to_bool(obj); /* Extract file identifier string */ - crypt->idlength = 0; + crypt->id_length = 0; - if (fz_isarray(id) && fz_arraylen(id) == 2) + if (fz_is_array(id) && fz_array_len(id) == 2) { - obj = fz_arrayget(id, 0); - if (fz_isstring(obj)) + obj = fz_array_get(id, 0); + if (fz_is_string(obj)) { - if (fz_tostrlen(obj) <= sizeof(crypt->idstring)) + if (fz_to_str_len(obj) <= sizeof(crypt->id_string)) { - memcpy(crypt->idstring, fz_tostrbuf(obj), fz_tostrlen(obj)); - crypt->idlength = fz_tostrlen(obj); + memcpy(crypt->id_string, fz_to_str_buf(obj), fz_to_str_len(obj)); + crypt->id_length = fz_to_str_len(obj); } } } @@ -218,9 +218,9 @@ pdf_newcrypt(pdf_crypt **cryptp, fz_obj *dict, fz_obj *id) } void -pdf_freecrypt(pdf_crypt *crypt) +pdf_free_crypt(pdf_crypt *crypt) { - if (crypt->cf) fz_dropobj(crypt->cf); + if (crypt->cf) fz_drop_obj(crypt->cf); fz_free(crypt); } @@ -229,31 +229,31 @@ pdf_freecrypt(pdf_crypt *crypt) */ fz_error -pdf_parsecryptfilter(pdf_cryptfilter *cf, fz_obj *dict, int defaultlength) +pdf_parse_crypt_filter(pdf_crypt_filter *cf, fz_obj *dict, int defaultlength) { fz_obj *obj; cf->method = PDF_CRYPT_NONE; cf->length = defaultlength; - obj = fz_dictgets(dict, "CFM"); - if (fz_isname(obj)) + obj = fz_dict_gets(dict, "CFM"); + if (fz_is_name(obj)) { - if (!strcmp(fz_toname(obj), "None")) + if (!strcmp(fz_to_name(obj), "None")) cf->method = PDF_CRYPT_NONE; - else if (!strcmp(fz_toname(obj), "V2")) + else if (!strcmp(fz_to_name(obj), "V2")) cf->method = PDF_CRYPT_RC4; - else if (!strcmp(fz_toname(obj), "AESV2")) + else if (!strcmp(fz_to_name(obj), "AESV2")) cf->method = PDF_CRYPT_AESV2; - else if (!strcmp(fz_toname(obj), "AESV3")) + else if (!strcmp(fz_to_name(obj), "AESV3")) cf->method = PDF_CRYPT_AESV3; else - fz_throw("unknown encryption method: %s", fz_toname(obj)); + fz_throw("unknown encryption method: %s", fz_to_name(obj)); } - obj = fz_dictgets(dict, "Length"); - if (fz_isint(obj)) - cf->length = fz_toint(obj); + obj = fz_dict_gets(dict, "Length"); + if (fz_is_int(obj)) + cf->length = fz_to_int(obj); /* the length for crypt filters is supposed to be in bytes not bits */ if (cf->length < 40) @@ -278,7 +278,7 @@ static const unsigned char padding[32] = }; static void -pdf_computeencryptionkey(pdf_crypt *crypt, unsigned char *password, int pwlen, unsigned char *key) +pdf_compute_encryption_key(pdf_crypt *crypt, unsigned char *password, int pwlen, unsigned char *key) { unsigned char buf[32]; unsigned int p; @@ -294,11 +294,11 @@ pdf_computeencryptionkey(pdf_crypt *crypt, unsigned char *password, int pwlen, u memcpy(buf + pwlen, padding, 32 - pwlen); /* Step 2 - init md5 and pass value of step 1 */ - fz_md5init(&md5); - fz_md5update(&md5, buf, 32); + fz_md5_init(&md5); + fz_md5_update(&md5, buf, 32); /* Step 3 - pass O value */ - fz_md5update(&md5, crypt->o, 32); + fz_md5_update(&md5, crypt->o, 32); /* Step 4 - pass P value as unsigned int, low-order byte first */ p = (unsigned int) crypt->p; @@ -306,35 +306,35 @@ pdf_computeencryptionkey(pdf_crypt *crypt, unsigned char *password, int pwlen, u buf[1] = (p >> 8) & 0xFF; buf[2] = (p >> 16) & 0xFF; buf[3] = (p >> 24) & 0xFF; - fz_md5update(&md5, buf, 4); + fz_md5_update(&md5, buf, 4); /* Step 5 - pass first element of ID array */ - fz_md5update(&md5, crypt->idstring, crypt->idlength); + fz_md5_update(&md5, crypt->id_string, crypt->id_length); /* Step 6 (revision 4 or greater) - if metadata is not encrypted pass 0xFFFFFFFF */ if (crypt->r >= 4) { - if (!crypt->encryptmetadata) + if (!crypt->encrypt_metadata) { buf[0] = 0xFF; buf[1] = 0xFF; buf[2] = 0xFF; buf[3] = 0xFF; - fz_md5update(&md5, buf, 4); + fz_md5_update(&md5, buf, 4); } } /* Step 7 - finish the hash */ - fz_md5final(&md5, buf); + fz_md5_final(&md5, buf); /* Step 8 (revision 3 or greater) - do some voodoo 50 times */ if (crypt->r >= 3) { for (i = 0; i < 50; i++) { - fz_md5init(&md5); - fz_md5update(&md5, buf, n); - fz_md5final(&md5, buf); + fz_md5_init(&md5); + fz_md5_update(&md5, buf, n); + fz_md5_final(&md5, buf); } } @@ -347,7 +347,7 @@ pdf_computeencryptionkey(pdf_crypt *crypt, unsigned char *password, int pwlen, u */ static void -pdf_computeencryptionkey_r5(pdf_crypt *crypt, unsigned char *password, int pwlen, int ownerkey, unsigned char *validationkey) +pdf_compute_encryption_key_r5(pdf_crypt *crypt, unsigned char *password, int pwlen, int ownerkey, unsigned char *validationkey) { unsigned char buffer[128 + 8 + 48]; fz_sha256 sha256; @@ -369,17 +369,17 @@ pdf_computeencryptionkey_r5(pdf_crypt *crypt, unsigned char *password, int pwlen else memcpy(buffer + pwlen, crypt->u + 32, 8); - fz_sha256init(&sha256); - fz_sha256update(&sha256, buffer, pwlen + 8 + (ownerkey ? 48 : 0)); - fz_sha256final(&sha256, validationkey); + fz_sha256_init(&sha256); + fz_sha256_update(&sha256, buffer, pwlen + 8 + (ownerkey ? 48 : 0)); + fz_sha256_final(&sha256, validationkey); /* Step 3.5/4.5 - compute file encryption key from OE/UE */ memcpy(buffer + pwlen, crypt->u + 40, 8); - fz_sha256init(&sha256); - fz_sha256update(&sha256, buffer, pwlen + 8); - fz_sha256final(&sha256, buffer); + fz_sha256_init(&sha256); + fz_sha256_update(&sha256, buffer, pwlen + 8); + fz_sha256_final(&sha256, buffer); // clear password buffer and use it as iv memset(buffer + 32, 0, sizeof(buffer) - 32); @@ -393,15 +393,15 @@ pdf_computeencryptionkey_r5(pdf_crypt *crypt, unsigned char *password, int pwlen */ static void -pdf_computeuserpassword(pdf_crypt *crypt, unsigned char *password, int pwlen, unsigned char *output) +pdf_compute_user_password(pdf_crypt *crypt, unsigned char *password, int pwlen, unsigned char *output) { if (crypt->r == 2) { fz_arc4 arc4; - pdf_computeencryptionkey(crypt, password, pwlen, crypt->key); - fz_arc4init(&arc4, crypt->key, crypt->length / 8); - fz_arc4encrypt(&arc4, output, padding, 32); + pdf_compute_encryption_key(crypt, password, pwlen, crypt->key); + fz_arc4_init(&arc4, crypt->key, crypt->length / 8); + fz_arc4_encrypt(&arc4, output, padding, 32); } if (crypt->r == 3 || crypt->r == 4) @@ -414,22 +414,22 @@ pdf_computeuserpassword(pdf_crypt *crypt, unsigned char *password, int pwlen, un n = crypt->length / 8; - pdf_computeencryptionkey(crypt, password, pwlen, crypt->key); + pdf_compute_encryption_key(crypt, password, pwlen, crypt->key); - fz_md5init(&md5); - fz_md5update(&md5, padding, 32); - fz_md5update(&md5, crypt->idstring, crypt->idlength); - fz_md5final(&md5, digest); + fz_md5_init(&md5); + fz_md5_update(&md5, padding, 32); + fz_md5_update(&md5, crypt->id_string, crypt->id_length); + fz_md5_final(&md5, digest); - fz_arc4init(&arc4, crypt->key, n); - fz_arc4encrypt(&arc4, output, digest, 16); + fz_arc4_init(&arc4, crypt->key, n); + fz_arc4_encrypt(&arc4, output, digest, 16); for (x = 1; x <= 19; x++) { for (i = 0; i < n; i++) xor[i] = crypt->key[i] ^ x; - fz_arc4init(&arc4, xor, n); - fz_arc4encrypt(&arc4, output, output, 16); + fz_arc4_init(&arc4, xor, n); + fz_arc4_encrypt(&arc4, output, output, 16); } memcpy(output + 16, padding, 16); @@ -437,7 +437,7 @@ pdf_computeuserpassword(pdf_crypt *crypt, unsigned char *password, int pwlen, un if (crypt->r == 5) { - pdf_computeencryptionkey_r5(crypt, password, pwlen, 0, output); + pdf_compute_encryption_key_r5(crypt, password, pwlen, 0, output); } } @@ -449,10 +449,10 @@ pdf_computeuserpassword(pdf_crypt *crypt, unsigned char *password, int pwlen, un */ static int -pdf_authenticateuserpassword(pdf_crypt *crypt, unsigned char *password, int pwlen) +pdf_authenticate_user_password(pdf_crypt *crypt, unsigned char *password, int pwlen) { unsigned char output[32]; - pdf_computeuserpassword(crypt, password, pwlen, output); + pdf_compute_user_password(crypt, password, pwlen, output); if (crypt->r == 2 || crypt->r == 5) return memcmp(output, crypt->u, 32) == 0; if (crypt->r == 3 || crypt->r == 4) @@ -464,11 +464,11 @@ pdf_authenticateuserpassword(pdf_crypt *crypt, unsigned char *password, int pwle * Authenticating the owner password (PDF 1.7 algorithm 3.7 * and ExtensionLevel 3 algorithm 3.12) * Generates the user password from the owner password - * and calls pdf_authenticateuserpassword. + * and calls pdf_authenticate_user_password. */ static int -pdf_authenticateownerpassword(pdf_crypt *crypt, unsigned char *ownerpass, int pwlen) +pdf_authenticate_owner_password(pdf_crypt *crypt, unsigned char *ownerpass, int pwlen) { unsigned char pwbuf[32]; unsigned char key[32]; @@ -482,7 +482,7 @@ pdf_authenticateownerpassword(pdf_crypt *crypt, unsigned char *ownerpass, int pw { /* PDF 1.7 ExtensionLevel 3 algorithm 3.12 */ - pdf_computeencryptionkey_r5(crypt, ownerpass, pwlen, 1, key); + pdf_compute_encryption_key_r5(crypt, ownerpass, pwlen, 1, key); return !memcmp(key, crypt->o, 32); } @@ -498,26 +498,26 @@ pdf_authenticateownerpassword(pdf_crypt *crypt, unsigned char *ownerpass, int pw memcpy(pwbuf + pwlen, padding, 32 - pwlen); /* take md5 hash of padded password */ - fz_md5init(&md5); - fz_md5update(&md5, pwbuf, 32); - fz_md5final(&md5, key); + fz_md5_init(&md5); + fz_md5_update(&md5, pwbuf, 32); + fz_md5_final(&md5, key); /* do some voodoo 50 times (Revision 3 or greater) */ if (crypt->r >= 3) { for (i = 0; i < 50; i++) { - fz_md5init(&md5); - fz_md5update(&md5, key, 16); - fz_md5final(&md5, key); + fz_md5_init(&md5); + fz_md5_update(&md5, key, 16); + fz_md5_final(&md5, key); } } /* Step 2 (Revision 2) */ if (crypt->r == 2) { - fz_arc4init(&arc4, key, n); - fz_arc4encrypt(&arc4, userpass, crypt->o, 32); + fz_arc4_init(&arc4, key, n); + fz_arc4_encrypt(&arc4, userpass, crypt->o, 32); } /* Step 2 (Revision 3 or greater) */ @@ -528,22 +528,22 @@ pdf_authenticateownerpassword(pdf_crypt *crypt, unsigned char *ownerpass, int pw { for (i = 0; i < n; i++) xor[i] = key[i] ^ (19 - x); - fz_arc4init(&arc4, xor, n); - fz_arc4encrypt(&arc4, userpass, userpass, 32); + fz_arc4_init(&arc4, xor, n); + fz_arc4_encrypt(&arc4, userpass, userpass, 32); } } - return pdf_authenticateuserpassword(crypt, userpass, 32); + return pdf_authenticate_user_password(crypt, userpass, 32); } int -pdf_authenticatepassword(pdf_xref *xref, char *password) +pdf_authenticate_password(pdf_xref *xref, char *password) { if (xref->crypt) { - if (pdf_authenticateuserpassword(xref->crypt, (unsigned char *)password, strlen(password))) + if (pdf_authenticate_user_password(xref->crypt, (unsigned char *)password, strlen(password))) return 1; - if (pdf_authenticateownerpassword(xref->crypt, (unsigned char *)password, strlen(password))) + if (pdf_authenticate_owner_password(xref->crypt, (unsigned char *)password, strlen(password))) return 1; return 0; } @@ -551,11 +551,11 @@ pdf_authenticatepassword(pdf_xref *xref, char *password) } int -pdf_needspassword(pdf_xref *xref) +pdf_needs_password(pdf_xref *xref) { if (!xref->crypt) return 0; - if (pdf_authenticatepassword(xref, "")) + if (pdf_authenticate_password(xref, "")) return 0; return 1; } @@ -570,7 +570,7 @@ pdf_needspassword(pdf_xref *xref) */ static int -pdf_computeobjectkey(pdf_crypt *crypt, pdf_cryptfilter *cf, int num, int gen, unsigned char *key) +pdf_compute_object_key(pdf_crypt *crypt, pdf_crypt_filter *cf, int num, int gen, unsigned char *key) { fz_md5 md5; unsigned char message[5]; @@ -581,19 +581,19 @@ pdf_computeobjectkey(pdf_crypt *crypt, pdf_cryptfilter *cf, int num, int gen, un return crypt->length / 8; } - fz_md5init(&md5); - fz_md5update(&md5, crypt->key, crypt->length / 8); + fz_md5_init(&md5); + fz_md5_update(&md5, crypt->key, crypt->length / 8); message[0] = (num) & 0xFF; message[1] = (num >> 8) & 0xFF; message[2] = (num >> 16) & 0xFF; message[3] = (gen) & 0xFF; message[4] = (gen >> 8) & 0xFF; - fz_md5update(&md5, message, 5); + fz_md5_update(&md5, message, 5); if (cf->method == PDF_CRYPT_AESV2) - fz_md5update(&md5, (unsigned char *)"sAlT", 4); + fz_md5_update(&md5, (unsigned char *)"sAlT", 4); - fz_md5final(&md5, key); + fz_md5_final(&md5, key); if (crypt->length / 8 + 5 > 16) return 16; @@ -609,24 +609,24 @@ pdf_computeobjectkey(pdf_crypt *crypt, pdf_cryptfilter *cf, int num, int gen, un */ static void -pdf_cryptobjimp(pdf_crypt *crypt, fz_obj *obj, unsigned char *key, int keylen) +pdf_crypt_obj_imp(pdf_crypt *crypt, fz_obj *obj, unsigned char *key, int keylen) { unsigned char *s; int i, n; - if (fz_isindirect(obj)) + if (fz_is_indirect(obj)) return; - if (fz_isstring(obj)) + if (fz_is_string(obj)) { - s = (unsigned char *) fz_tostrbuf(obj); - n = fz_tostrlen(obj); + s = (unsigned char *) fz_to_str_buf(obj); + n = fz_to_str_len(obj); if (crypt->strf.method == PDF_CRYPT_RC4) { fz_arc4 arc4; - fz_arc4init(&arc4, key, keylen); - fz_arc4encrypt(&arc4, s, s, n); + fz_arc4_init(&arc4, key, keylen); + fz_arc4_encrypt(&arc4, s, s, n); } if (crypt->strf.method == PDF_CRYPT_AESV2 || crypt->strf.method == PDF_CRYPT_AESV3) @@ -644,34 +644,34 @@ pdf_cryptobjimp(pdf_crypt *crypt, fz_obj *obj, unsigned char *key, int keylen) } } - else if (fz_isarray(obj)) + else if (fz_is_array(obj)) { - n = fz_arraylen(obj); + n = fz_array_len(obj); for (i = 0; i < n; i++) { - pdf_cryptobjimp(crypt, fz_arrayget(obj, i), key, keylen); + pdf_crypt_obj_imp(crypt, fz_array_get(obj, i), key, keylen); } } - else if (fz_isdict(obj)) + else if (fz_is_dict(obj)) { - n = fz_dictlen(obj); + n = fz_dict_len(obj); for (i = 0; i < n; i++) { - pdf_cryptobjimp(crypt, fz_dictgetval(obj, i), key, keylen); + pdf_crypt_obj_imp(crypt, fz_dict_get_val(obj, i), key, keylen); } } } void -pdf_cryptobj(pdf_crypt *crypt, fz_obj *obj, int num, int gen) +pdf_crypt_obj(pdf_crypt *crypt, fz_obj *obj, int num, int gen) { unsigned char key[32]; int len; - len = pdf_computeobjectkey(crypt, &crypt->strf, num, gen, key); + len = pdf_compute_object_key(crypt, &crypt->strf, num, gen, key); - pdf_cryptobjimp(crypt, obj, key, len); + pdf_crypt_obj_imp(crypt, obj, key, len); } /* @@ -680,23 +680,23 @@ pdf_cryptobj(pdf_crypt *crypt, fz_obj *obj, int num, int gen) * Create filter suitable for de/encrypting a stream. */ fz_stream * -pdf_opencrypt(fz_stream *chain, pdf_crypt *crypt, pdf_cryptfilter *stmf, int num, int gen) +pdf_open_crypt(fz_stream *chain, pdf_crypt *crypt, pdf_crypt_filter *stmf, int num, int gen) { unsigned char key[32]; int len; - len = pdf_computeobjectkey(crypt, stmf, num, gen, key); + len = pdf_compute_object_key(crypt, stmf, num, gen, key); if (stmf->method == PDF_CRYPT_RC4) - return fz_openarc4(chain, key, len); + return fz_open_arc4(chain, key, len); if (stmf->method == PDF_CRYPT_AESV2 || stmf->method == PDF_CRYPT_AESV3) - return fz_openaesd(chain, key, len); + return fz_open_aesd(chain, key, len); - return fz_opencopy(chain); + return fz_open_copy(chain); } -void pdf_debugcrypt(pdf_crypt *crypt) +void pdf_debug_crypt(pdf_crypt *crypt) { int i; diff --git a/pdf/pdf_debug.c b/pdf/pdf_debug.c index 9d7f1f56..e2223b2d 100644 --- a/pdf/pdf_debug.c +++ b/pdf/pdf_debug.c @@ -72,20 +72,20 @@ static inline void pdflog(int tag, char *name, char *fmt, va_list ap) fflush(stdout); } -void pdf_logxref(char *fmt, ...) +void pdf_log_xref(char *fmt, ...) {va_list ap;va_start(ap,fmt);pdflog(PDF_LXREF,"xref",fmt,ap);va_end(ap);} -void pdf_logrsrc(char *fmt, ...) +void pdf_log_rsrc(char *fmt, ...) {va_list ap;va_start(ap,fmt);pdflog(PDF_LRSRC,"rsrc",fmt,ap);va_end(ap);} -void pdf_logfont(char *fmt, ...) +void pdf_log_font(char *fmt, ...) {va_list ap;va_start(ap,fmt);pdflog(PDF_LFONT,"font",fmt,ap);va_end(ap);} -void pdf_logimage(char *fmt, ...) +void pdf_log_image(char *fmt, ...) {va_list ap;va_start(ap,fmt);pdflog(PDF_LIMAGE,"imag",fmt,ap);va_end(ap);} -void pdf_logshade(char *fmt, ...) +void pdf_log_shade(char *fmt, ...) {va_list ap;va_start(ap,fmt);pdflog(PDF_LSHADE,"shad",fmt,ap);va_end(ap);} -void pdf_logpage(char *fmt, ...) +void pdf_log_page(char *fmt, ...) {va_list ap;va_start(ap,fmt);pdflog(PDF_LPAGE,"page",fmt,ap);va_end(ap);} diff --git a/pdf/pdf_font.c b/pdf/pdf_font.c index 75bc141f..60d6e824 100644 --- a/pdf/pdf_font.c +++ b/pdf/pdf_font.c @@ -5,34 +5,34 @@ #include FT_FREETYPE_H #include FT_XFREE86_H -static char *basefontnames[14][7] = +static char *base_font_names[14][7] = { - { "Courier", "CourierNew", "CourierNewPSMT", nil }, + { "Courier", "CourierNew", "CourierNewPSMT", NULL }, { "Courier-Bold", "CourierNew,Bold", "Courier,Bold", - "CourierNewPS-BoldMT", "CourierNew-Bold", nil }, + "CourierNewPS-BoldMT", "CourierNew-Bold", NULL }, { "Courier-Oblique", "CourierNew,Italic", "Courier,Italic", - "CourierNewPS-ItalicMT", "CourierNew-Italic", nil }, + "CourierNewPS-ItalicMT", "CourierNew-Italic", NULL }, { "Courier-BoldOblique", "CourierNew,BoldItalic", "Courier,BoldItalic", - "CourierNewPS-BoldItalicMT", "CourierNew-BoldItalic", nil }, - { "Helvetica", "ArialMT", "Arial", nil }, + "CourierNewPS-BoldItalicMT", "CourierNew-BoldItalic", NULL }, + { "Helvetica", "ArialMT", "Arial", NULL }, { "Helvetica-Bold", "Arial-BoldMT", "Arial,Bold", "Arial-Bold", - "Helvetica,Bold", nil }, + "Helvetica,Bold", NULL }, { "Helvetica-Oblique", "Arial-ItalicMT", "Arial,Italic", "Arial-Italic", - "Helvetica,Italic", "Helvetica-Italic", nil }, + "Helvetica,Italic", "Helvetica-Italic", NULL }, { "Helvetica-BoldOblique", "Arial-BoldItalicMT", "Arial,BoldItalic", "Arial-BoldItalic", - "Helvetica,BoldItalic", "Helvetica-BoldItalic", nil }, + "Helvetica,BoldItalic", "Helvetica-BoldItalic", NULL }, { "Times-Roman", "TimesNewRomanPSMT", "TimesNewRoman", - "TimesNewRomanPS", nil }, + "TimesNewRomanPS", NULL }, { "Times-Bold", "TimesNewRomanPS-BoldMT", "TimesNewRoman,Bold", - "TimesNewRomanPS-Bold", "TimesNewRoman-Bold", nil }, + "TimesNewRomanPS-Bold", "TimesNewRoman-Bold", NULL }, { "Times-Italic", "TimesNewRomanPS-ItalicMT", "TimesNewRoman,Italic", - "TimesNewRomanPS-Italic", "TimesNewRoman-Italic", nil }, + "TimesNewRomanPS-Italic", "TimesNewRoman-Italic", NULL }, { "Times-BoldItalic", "TimesNewRomanPS-BoldItalicMT", "TimesNewRoman,BoldItalic", "TimesNewRomanPS-BoldItalic", - "TimesNewRoman-BoldItalic", nil }, - { "Symbol", nil }, - { "ZapfDingbats", nil } + "TimesNewRoman-BoldItalic", NULL }, + { "Symbol", NULL }, + { "ZapfDingbats", NULL } }; static int isdynalab(char *name) @@ -48,7 +48,7 @@ static int isdynalab(char *name) return 0; } -static int strcmpignorespace(char *a, char *b) +static int strcmp_ignore_space(char *a, char *b) { while (1) { @@ -67,13 +67,13 @@ static int strcmpignorespace(char *a, char *b) } } -static char *cleanfontname(char *fontname) +static char *clean_font_name(char *fontname) { int i, k; for (i = 0; i < 14; i++) - for (k = 0; basefontnames[i][k]; k++) - if (!strcmpignorespace(basefontnames[i][k], fontname)) - return basefontnames[i][0]; + for (k = 0; base_font_names[i][k]; k++) + if (!strcmp_ignore_space(base_font_names[i][k], fontname)) + return base_font_names[i][0]; return fontname; } @@ -83,10 +83,10 @@ static char *cleanfontname(char *fontname) enum { UNKNOWN, TYPE1, TRUETYPE }; -static int ftkind(FT_Face face) +static int ft_kind(FT_Face face) { const char *kind = FT_Get_X11_Font_Format(face); - pdf_logfont("ft font format %s\n", kind); + pdf_log_font("ft font format %s\n", kind); if (!strcmp(kind, "TrueType")) return TRUETYPE; if (!strcmp(kind, "Type 1")) @@ -98,7 +98,7 @@ static int ftkind(FT_Face face) return UNKNOWN; } -static int ftcharindex(FT_Face face, int cid) +static int ft_char_index(FT_Face face, int cid) { int gid = FT_Get_Char_Index(face, cid); if (gid == 0) @@ -106,53 +106,53 @@ static int ftcharindex(FT_Face face, int cid) return gid; } -static inline int ftcidtogid(pdf_fontdesc *fontdesc, int cid) +static inline int ft_cid_to_gid(pdf_font_desc *fontdesc, int cid) { - if (fontdesc->tottfcmap) + if (fontdesc->to_ttf_cmap) { - cid = pdf_lookupcmap(fontdesc->tottfcmap, cid); - return ftcharindex(fontdesc->font->ftface, cid); + cid = pdf_lookup_cmap(fontdesc->to_ttf_cmap, cid); + return ft_char_index(fontdesc->font->ft_face, cid); } - if (fontdesc->cidtogid) - return fontdesc->cidtogid[cid]; + if (fontdesc->cid_to_gid) + return fontdesc->cid_to_gid[cid]; return cid; } int -pdf_fontcidtogid(pdf_fontdesc *fontdesc, int cid) +pdf_font_cid_to_gid(pdf_font_desc *fontdesc, int cid) { - if (fontdesc->font->ftface) - return ftcidtogid(fontdesc, cid); + if (fontdesc->font->ft_face) + return ft_cid_to_gid(fontdesc, cid); return cid; } -static int ftwidth(pdf_fontdesc *fontdesc, int cid) +static int ft_width(pdf_font_desc *fontdesc, int cid) { int gid, fterr; - gid = ftcidtogid(fontdesc, cid); + gid = ft_cid_to_gid(fontdesc, cid); - fterr = FT_Load_Glyph(fontdesc->font->ftface, gid, + fterr = FT_Load_Glyph(fontdesc->font->ft_face, gid, FT_LOAD_NO_HINTING | FT_LOAD_NO_BITMAP | FT_LOAD_IGNORE_TRANSFORM); if (fterr) { - fz_warn("freetype load glyph (gid %d): %s", gid, ft_errorstring(fterr)); + fz_warn("freetype load glyph (gid %d): %s", gid, ft_error_string(fterr)); return 0; } - return ((FT_Face)fontdesc->font->ftface)->glyph->advance.x; + return ((FT_Face)fontdesc->font->ft_face)->glyph->advance.x; } /* * Basic encoding tables */ -static int mrecode(char *name) +static int mre_code(char *name) { int i; for (i = 0; i < 256; i++) - if (pdf_macroman[i] && !strcmp(name, pdf_macroman[i])) + if (pdf_mac_roman[i] && !strcmp(name, pdf_mac_roman[i])) return i; return -1; } @@ -161,69 +161,69 @@ static int mrecode(char *name) * Create and destroy */ -pdf_fontdesc * -pdf_keepfont(pdf_fontdesc *fontdesc) +pdf_font_desc * +pdf_keep_font(pdf_font_desc *fontdesc) { fontdesc->refs ++; return fontdesc; } void -pdf_dropfont(pdf_fontdesc *fontdesc) +pdf_drop_font(pdf_font_desc *fontdesc) { if (fontdesc && --fontdesc->refs == 0) { if (fontdesc->font) - fz_dropfont(fontdesc->font); + fz_drop_font(fontdesc->font); if (fontdesc->encoding) - pdf_dropcmap(fontdesc->encoding); - if (fontdesc->tottfcmap) - pdf_dropcmap(fontdesc->tottfcmap); - if (fontdesc->tounicode) - pdf_dropcmap(fontdesc->tounicode); - fz_free(fontdesc->cidtogid); - fz_free(fontdesc->cidtoucs); + pdf_drop_cmap(fontdesc->encoding); + if (fontdesc->to_ttf_cmap) + pdf_drop_cmap(fontdesc->to_ttf_cmap); + if (fontdesc->to_unicode) + pdf_drop_cmap(fontdesc->to_unicode); + fz_free(fontdesc->cid_to_gid); + fz_free(fontdesc->cid_to_ucs); fz_free(fontdesc->hmtx); fz_free(fontdesc->vmtx); fz_free(fontdesc); } } -pdf_fontdesc * -pdf_newfontdesc(void) +pdf_font_desc * +pdf_new_font_desc(void) { - pdf_fontdesc *fontdesc; + pdf_font_desc *fontdesc; - fontdesc = fz_malloc(sizeof(pdf_fontdesc)); + fontdesc = fz_malloc(sizeof(pdf_font_desc)); fontdesc->refs = 1; - fontdesc->font = nil; + fontdesc->font = NULL; fontdesc->flags = 0; - fontdesc->italicangle = 0; + fontdesc->italic_angle = 0; fontdesc->ascent = 0; fontdesc->descent = 0; - fontdesc->capheight = 0; - fontdesc->xheight = 0; - fontdesc->missingwidth = 0; + fontdesc->cap_height = 0; + fontdesc->x_height = 0; + fontdesc->missing_width = 0; - fontdesc->encoding = nil; - fontdesc->tottfcmap = nil; - fontdesc->ncidtogid = 0; - fontdesc->cidtogid = nil; + fontdesc->encoding = NULL; + fontdesc->to_ttf_cmap = NULL; + fontdesc->cid_to_gid_len = 0; + fontdesc->cid_to_gid = NULL; - fontdesc->tounicode = nil; - fontdesc->ncidtoucs = 0; - fontdesc->cidtoucs = nil; + fontdesc->to_unicode = NULL; + fontdesc->cid_to_ucs_len = 0; + fontdesc->cid_to_ucs = NULL; fontdesc->wmode = 0; - fontdesc->hmtxcap = 0; - fontdesc->vmtxcap = 0; - fontdesc->nhmtx = 0; - fontdesc->nvmtx = 0; - fontdesc->hmtx = nil; - fontdesc->vmtx = nil; + fontdesc->hmtx_cap = 0; + fontdesc->vmtx_cap = 0; + fontdesc->hmtx_len = 0; + fontdesc->vmtx_len = 0; + fontdesc->hmtx = NULL; + fontdesc->vmtx = NULL; fontdesc->dhmtx.lo = 0x0000; fontdesc->dhmtx.hi = 0xFFFF; @@ -245,14 +245,14 @@ pdf_newfontdesc(void) */ static fz_error -loadsimplefont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict) +load_simple_font(pdf_font_desc **fontdescp, pdf_xref *xref, fz_obj *dict) { fz_error error; fz_obj *descriptor; fz_obj *encoding; fz_obj *widths; - unsigned short *etable = nil; - pdf_fontdesc *fontdesc; + unsigned short *etable = NULL; + pdf_font_desc *fontdesc; FT_Face face; FT_CharMap cmap; int kind; @@ -265,31 +265,31 @@ loadsimplefont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict) int i, k, n; int fterr; - basefont = fz_toname(fz_dictgets(dict, "BaseFont")); - fontname = cleanfontname(basefont); + basefont = fz_to_name(fz_dict_gets(dict, "BaseFont")); + fontname = clean_font_name(basefont); /* Load font file */ - fontdesc = pdf_newfontdesc(); + fontdesc = pdf_new_font_desc(); - pdf_logfont("load simple font (%d %d R) ptr=%p {\n", fz_tonum(dict), fz_togen(dict), fontdesc); - pdf_logfont("basefont %s -> %s\n", basefont, fontname); + pdf_log_font("load simple font (%d %d R) ptr=%p {\n", fz_to_num(dict), fz_to_gen(dict), fontdesc); + pdf_log_font("basefont %s -> %s\n", basefont, fontname); - descriptor = fz_dictgets(dict, "FontDescriptor"); + descriptor = fz_dict_gets(dict, "FontDescriptor"); if (descriptor) - error = pdf_loadfontdescriptor(fontdesc, xref, descriptor, nil, basefont); + error = pdf_load_font_descriptor(fontdesc, xref, descriptor, NULL, basefont); else - error = pdf_loadbuiltinfont(fontdesc, fontname); + error = pdf_load_builtin_font(fontdesc, fontname); if (error) goto cleanup; /* Some chinese documents mistakenly consider WinAnsiEncoding to be codepage 936 */ if (!*fontdesc->font->name && - !fz_dictgets(dict, "ToUnicode") && - !strcmp(fz_toname(fz_dictgets(dict, "Encoding")), "WinAnsiEncoding") && - fz_toint(fz_dictgets(descriptor, "Flags")) == 4) + !fz_dict_gets(dict, "ToUnicode") && + !strcmp(fz_to_name(fz_dict_gets(dict, "Encoding")), "WinAnsiEncoding") && + fz_to_int(fz_dict_gets(descriptor, "Flags")) == 4) { - /* note: without the comma, pdf_loadfontdescriptor would prefer /FontName over /BaseFont */ + /* note: without the comma, pdf_load_font_descriptor would prefer /FontName over /BaseFont */ char *cp936fonts[] = { "\xCB\xCE\xCC\xE5", "SimSun,Regular", "\xBA\xDA\xCC\xE5", "SimHei,Regular", @@ -304,34 +304,34 @@ loadsimplefont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict) if (cp936fonts[i]) { fz_warn("workaround for S22PDF lying about chinese font encodings"); - pdf_dropfont(fontdesc); - fontdesc = pdf_newfontdesc(); - error = pdf_loadfontdescriptor(fontdesc, xref, descriptor, "Adobe-GB1", cp936fonts[i+1]); - error |= pdf_loadsystemcmap(&fontdesc->encoding, "GBK-EUC-H"); - error |= pdf_loadsystemcmap(&fontdesc->tounicode, "Adobe-GB1-UCS2"); - error |= pdf_loadsystemcmap(&fontdesc->tottfcmap, "Adobe-GB1-UCS2"); + pdf_drop_font(fontdesc); + fontdesc = pdf_new_font_desc(); + error = pdf_load_font_descriptor(fontdesc, xref, descriptor, "Adobe-GB1", cp936fonts[i+1]); + error |= pdf_load_system_cmap(&fontdesc->encoding, "GBK-EUC-H"); + error |= pdf_load_system_cmap(&fontdesc->to_unicode, "Adobe-GB1-UCS2"); + error |= pdf_load_system_cmap(&fontdesc->to_ttf_cmap, "Adobe-GB1-UCS2"); if (error) return fz_rethrow(error, "cannot load font"); - face = fontdesc->font->ftface; - kind = ftkind(face); + face = fontdesc->font->ft_face; + kind = ft_kind(face); goto skip_encoding; } } - face = fontdesc->font->ftface; - kind = ftkind(face); + face = fontdesc->font->ft_face; + kind = ft_kind(face); /* Encoding */ - pdf_logfont("ft name '%s' '%s'\n", face->family_name, face->style_name); + pdf_log_font("ft name '%s' '%s'\n", face->family_name, face->style_name); symbolic = fontdesc->flags & 4; if (face->num_charmaps > 0) cmap = face->charmaps[0]; else - cmap = nil; + cmap = NULL; for (i = 0; i < face->num_charmaps; i++) { @@ -356,7 +356,7 @@ loadsimplefont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict) { fterr = FT_Set_Charmap(face, cmap); if (fterr) - fz_warn("freetype could not set cmap: %s", ft_errorstring(fterr)); + fz_warn("freetype could not set cmap: %s", ft_error_string(fterr)); } else fz_warn("freetype could not find any cmaps"); @@ -364,38 +364,38 @@ loadsimplefont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict) etable = fz_calloc(256, sizeof(unsigned short)); for (i = 0; i < 256; i++) { - estrings[i] = nil; + estrings[i] = NULL; etable[i] = 0; } - encoding = fz_dictgets(dict, "Encoding"); + encoding = fz_dict_gets(dict, "Encoding"); if (encoding) { - if (fz_isname(encoding)) - pdf_loadencoding(estrings, fz_toname(encoding)); + if (fz_is_name(encoding)) + pdf_load_encoding(estrings, fz_to_name(encoding)); - if (fz_isdict(encoding)) + if (fz_is_dict(encoding)) { fz_obj *base, *diff, *item; - base = fz_dictgets(encoding, "BaseEncoding"); - if (fz_isname(base)) - pdf_loadencoding(estrings, fz_toname(base)); + base = fz_dict_gets(encoding, "BaseEncoding"); + if (fz_is_name(base)) + pdf_load_encoding(estrings, fz_to_name(base)); else if (!fontdesc->isembedded && !symbolic) - pdf_loadencoding(estrings, "StandardEncoding"); + pdf_load_encoding(estrings, "StandardEncoding"); - diff = fz_dictgets(encoding, "Differences"); - if (fz_isarray(diff)) + diff = fz_dict_gets(encoding, "Differences"); + if (fz_is_array(diff)) { - n = fz_arraylen(diff); + n = fz_array_len(diff); k = 0; for (i = 0; i < n; i++) { - item = fz_arrayget(diff, i); - if (fz_isint(item)) - k = fz_toint(item); - if (fz_isname(item)) - estrings[k++] = fz_toname(item); + item = fz_array_get(diff, i); + if (fz_is_int(item)) + k = fz_to_int(item); + if (fz_is_name(item)) + estrings[k++] = fz_to_name(item); if (k < 0) k = 0; if (k > 255) k = 255; } @@ -405,12 +405,12 @@ loadsimplefont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict) /* start with the builtin encoding */ for (i = 0; i < 256; i++) - etable[i] = ftcharindex(face, i); + etable[i] = ft_char_index(face, i); /* encode by glyph name where we can */ if (kind == TYPE1) { - pdf_logfont("encode type1/cff by strings\n"); + pdf_log_font("encode type1/cff by strings\n"); for (i = 0; i < 256; i++) { if (estrings[i]) @@ -418,8 +418,8 @@ loadsimplefont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict) etable[i] = FT_Get_Name_Index(face, estrings[i]); if (etable[i] == 0) { - int aglcode = pdf_lookupagl(estrings[i]); - char **aglnames = pdf_lookupaglnames(aglcode); + int aglcode = pdf_lookup_agl(estrings[i]); + char **aglnames = pdf_lookup_agl_names(aglcode); while (*aglnames) { etable[i] = FT_Get_Name_Index(face, *aglnames); @@ -438,16 +438,16 @@ loadsimplefont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict) /* Unicode cmap */ if (!symbolic && face->charmap && face->charmap->platform_id == 3) { - pdf_logfont("encode truetype via unicode\n"); + pdf_log_font("encode truetype via unicode\n"); for (i = 0; i < 256; i++) { if (estrings[i]) { - int aglcode = pdf_lookupagl(estrings[i]); + int aglcode = pdf_lookup_agl(estrings[i]); if (!aglcode) etable[i] = FT_Get_Name_Index(face, estrings[i]); else - etable[i] = ftcharindex(face, aglcode); + etable[i] = ft_char_index(face, aglcode); } } } @@ -455,16 +455,16 @@ loadsimplefont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict) /* MacRoman cmap */ else if (!symbolic && face->charmap && face->charmap->platform_id == 1) { - pdf_logfont("encode truetype via macroman\n"); + pdf_log_font("encode truetype via macroman\n"); for (i = 0; i < 256; i++) { if (estrings[i]) { - k = mrecode(estrings[i]); + k = mre_code(estrings[i]); if (k <= 0) etable[i] = FT_Get_Name_Index(face, estrings[i]); else - etable[i] = ftcharindex(face, k); + etable[i] = ft_char_index(face, k); } } } @@ -472,14 +472,14 @@ loadsimplefont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict) /* Symbolic cmap */ else { - pdf_logfont("encode truetype symbolic\n"); + pdf_log_font("encode truetype symbolic\n"); for (i = 0; i < 256; i++) { if (estrings[i]) { etable[i] = FT_Get_Name_Index(face, estrings[i]); if (etable[i] == 0) - etable[i] = ftcharindex(face, i); + etable[i] = ft_char_index(face, i); } } } @@ -494,71 +494,71 @@ loadsimplefont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict) { fterr = FT_Get_Glyph_Name(face, etable[i], ebuffer[i], 32); if (fterr) - fz_warn("freetype get glyph name (gid %d): %s", etable[i], ft_errorstring(fterr)); + fz_warn("freetype get glyph name (gid %d): %s", etable[i], ft_error_string(fterr)); if (ebuffer[i][0]) estrings[i] = ebuffer[i]; } else { - estrings[i] = (char*) pdf_winansi[i]; /* discard const */ + estrings[i] = (char*) pdf_win_ansi[i]; /* discard const */ } } } - fontdesc->encoding = pdf_newidentitycmap(0, 1); - fontdesc->ncidtogid = 256; - fontdesc->cidtogid = etable; + fontdesc->encoding = pdf_new_identity_cmap(0, 1); + fontdesc->cid_to_gid_len = 256; + fontdesc->cid_to_gid = etable; - error = pdf_loadtounicode(fontdesc, xref, estrings, nil, fz_dictgets(dict, "ToUnicode")); + error = pdf_load_to_unicode(fontdesc, xref, estrings, NULL, fz_dict_gets(dict, "ToUnicode")); if (error) - fz_catch(error, "cannot load tounicode"); + fz_catch(error, "cannot load to_unicode"); skip_encoding: /* Widths */ - pdf_setdefaulthmtx(fontdesc, fontdesc->missingwidth); + pdf_set_default_hmtx(fontdesc, fontdesc->missing_width); - widths = fz_dictgets(dict, "Widths"); + widths = fz_dict_gets(dict, "Widths"); if (widths) { int first, last; - first = fz_toint(fz_dictgets(dict, "FirstChar")); - last = fz_toint(fz_dictgets(dict, "LastChar")); + first = fz_to_int(fz_dict_gets(dict, "FirstChar")); + last = fz_to_int(fz_dict_gets(dict, "LastChar")); if (first < 0 || last > 255 || first > last) first = last = 0; for (i = 0; i < last - first + 1; i++) { - int wid = fz_toint(fz_arrayget(widths, i)); - pdf_addhmtx(fontdesc, i + first, i + first, wid); + int wid = fz_to_int(fz_array_get(widths, i)); + pdf_add_hmtx(fontdesc, i + first, i + first, wid); } } else { fterr = FT_Set_Char_Size(face, 1000, 1000, 72, 72); if (fterr) - fz_warn("freetype set character size: %s", ft_errorstring(fterr)); + fz_warn("freetype set character size: %s", ft_error_string(fterr)); for (i = 0; i < 256; i++) { - pdf_addhmtx(fontdesc, i, i, ftwidth(fontdesc, i)); + pdf_add_hmtx(fontdesc, i, i, ft_width(fontdesc, i)); } } - pdf_endhmtx(fontdesc); + pdf_end_hmtx(fontdesc); - pdf_logfont("}\n"); + pdf_log_font("}\n"); *fontdescp = fontdesc; return fz_okay; cleanup: - if (etable != fontdesc->cidtogid) + if (etable != fontdesc->cid_to_gid) fz_free(etable); - pdf_dropfont(fontdesc); - return fz_rethrow(error, "cannot load simple font (%d %d R)", fz_tonum(dict), fz_togen(dict)); + pdf_drop_font(fontdesc); + return fz_rethrow(error, "cannot load simple font (%d %d R)", fz_to_num(dict), fz_to_gen(dict)); } /* @@ -566,12 +566,12 @@ cleanup: */ static fz_error -loadcidfont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict, fz_obj *encoding, fz_obj *tounicode) +load_cid_font(pdf_font_desc **fontdescp, pdf_xref *xref, fz_obj *dict, fz_obj *encoding, fz_obj *to_unicode) { fz_error error; fz_obj *widths; fz_obj *descriptor; - pdf_fontdesc *fontdesc; + pdf_font_desc *fontdesc; FT_Face face; int kind; char collection[256]; @@ -582,78 +582,78 @@ loadcidfont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict, fz_obj *enco /* Get font name and CID collection */ - basefont = fz_toname(fz_dictgets(dict, "BaseFont")); + basefont = fz_to_name(fz_dict_gets(dict, "BaseFont")); { fz_obj *cidinfo; char tmpstr[64]; int tmplen; - cidinfo = fz_dictgets(dict, "CIDSystemInfo"); + cidinfo = fz_dict_gets(dict, "CIDSystemInfo"); if (!cidinfo) return fz_throw("cid font is missing info"); - obj = fz_dictgets(cidinfo, "Registry"); - tmplen = MIN(sizeof tmpstr - 1, fz_tostrlen(obj)); - memcpy(tmpstr, fz_tostrbuf(obj), tmplen); + obj = fz_dict_gets(cidinfo, "Registry"); + tmplen = MIN(sizeof tmpstr - 1, fz_to_str_len(obj)); + memcpy(tmpstr, fz_to_str_buf(obj), tmplen); tmpstr[tmplen] = '\0'; fz_strlcpy(collection, tmpstr, sizeof collection); fz_strlcat(collection, "-", sizeof collection); - obj = fz_dictgets(cidinfo, "Ordering"); - tmplen = MIN(sizeof tmpstr - 1, fz_tostrlen(obj)); - memcpy(tmpstr, fz_tostrbuf(obj), tmplen); + obj = fz_dict_gets(cidinfo, "Ordering"); + tmplen = MIN(sizeof tmpstr - 1, fz_to_str_len(obj)); + memcpy(tmpstr, fz_to_str_buf(obj), tmplen); tmpstr[tmplen] = '\0'; fz_strlcat(collection, tmpstr, sizeof collection); } /* Load font file */ - fontdesc = pdf_newfontdesc(); + fontdesc = pdf_new_font_desc(); - pdf_logfont("load cid font (%d %d R) ptr=%p {\n", fz_tonum(dict), fz_togen(dict), fontdesc); - pdf_logfont("basefont %s\n", basefont); - pdf_logfont("collection %s\n", collection); + pdf_log_font("load cid font (%d %d R) ptr=%p {\n", fz_to_num(dict), fz_to_gen(dict), fontdesc); + pdf_log_font("basefont %s\n", basefont); + pdf_log_font("collection %s\n", collection); - descriptor = fz_dictgets(dict, "FontDescriptor"); + descriptor = fz_dict_gets(dict, "FontDescriptor"); if (descriptor) - error = pdf_loadfontdescriptor(fontdesc, xref, descriptor, collection, basefont); + error = pdf_load_font_descriptor(fontdesc, xref, descriptor, collection, basefont); else error = fz_throw("syntaxerror: missing font descriptor"); if (error) goto cleanup; - face = fontdesc->font->ftface; - kind = ftkind(face); + face = fontdesc->font->ft_face; + kind = ft_kind(face); /* Check for DynaLab fonts that must use hinting */ if (kind == TRUETYPE) { if (FT_IS_TRICKY(face) || isdynalab(fontdesc->font->name)) { - fontdesc->font->fthint = 1; - pdf_logfont("forced hinting for dynalab font\n"); + fontdesc->font->ft_hint = 1; + pdf_log_font("forced hinting for dynalab font\n"); } } /* Encoding */ error = fz_okay; - if (fz_isname(encoding)) + if (fz_is_name(encoding)) { - pdf_logfont("encoding /%s\n", fz_toname(encoding)); - if (!strcmp(fz_toname(encoding), "Identity-H")) - fontdesc->encoding = pdf_newidentitycmap(0, 2); - else if (!strcmp(fz_toname(encoding), "Identity-V")) - fontdesc->encoding = pdf_newidentitycmap(1, 2); + pdf_log_font("encoding /%s\n", fz_to_name(encoding)); + if (!strcmp(fz_to_name(encoding), "Identity-H")) + fontdesc->encoding = pdf_new_identity_cmap(0, 2); + else if (!strcmp(fz_to_name(encoding), "Identity-V")) + fontdesc->encoding = pdf_new_identity_cmap(1, 2); else - error = pdf_loadsystemcmap(&fontdesc->encoding, fz_toname(encoding)); + error = pdf_load_system_cmap(&fontdesc->encoding, fz_to_name(encoding)); } - else if (fz_isindirect(encoding)) + else if (fz_is_indirect(encoding)) { - pdf_logfont("encoding %d %d R\n", fz_tonum(encoding), fz_togen(encoding)); - error = pdf_loadembeddedcmap(&fontdesc->encoding, xref, encoding); + pdf_log_font("encoding %d %d R\n", fz_to_num(encoding), fz_to_gen(encoding)); + error = pdf_load_embedded_cmap(&fontdesc->encoding, xref, encoding); } else { @@ -662,56 +662,56 @@ loadcidfont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict, fz_obj *enco if (error) goto cleanup; - pdf_setfontwmode(fontdesc, pdf_getwmode(fontdesc->encoding)); - pdf_logfont("wmode %d\n", pdf_getwmode(fontdesc->encoding)); + pdf_set_font_wmode(fontdesc, pdf_get_wmode(fontdesc->encoding)); + pdf_log_font("wmode %d\n", pdf_get_wmode(fontdesc->encoding)); if (kind == TRUETYPE) { fz_obj *cidtogidmap; - cidtogidmap = fz_dictgets(dict, "CIDToGIDMap"); - if (fz_isindirect(cidtogidmap)) + cidtogidmap = fz_dict_gets(dict, "CIDToGIDMap"); + if (fz_is_indirect(cidtogidmap)) { fz_buffer *buf; - pdf_logfont("cidtogidmap stream\n"); + pdf_log_font("cidtogidmap stream\n"); - error = pdf_loadstream(&buf, xref, fz_tonum(cidtogidmap), fz_togen(cidtogidmap)); + error = pdf_load_stream(&buf, xref, fz_to_num(cidtogidmap), fz_to_gen(cidtogidmap)); if (error) goto cleanup; - fontdesc->ncidtogid = (buf->len) / 2; - fontdesc->cidtogid = fz_calloc(fontdesc->ncidtogid, sizeof(unsigned short)); - for (i = 0; i < fontdesc->ncidtogid; i++) - fontdesc->cidtogid[i] = (buf->data[i * 2] << 8) + buf->data[i * 2 + 1]; + fontdesc->cid_to_gid_len = (buf->len) / 2; + fontdesc->cid_to_gid = fz_calloc(fontdesc->cid_to_gid_len, sizeof(unsigned short)); + for (i = 0; i < fontdesc->cid_to_gid_len; i++) + fontdesc->cid_to_gid[i] = (buf->data[i * 2] << 8) + buf->data[i * 2 + 1]; - fz_dropbuffer(buf); + fz_drop_buffer(buf); } /* if truetype font is external, cidtogidmap should not be identity */ /* so we map from cid to unicode and then map that through the (3 1) */ /* unicode cmap to get a glyph id */ - else if (fontdesc->font->ftsubstitute) + else if (fontdesc->font->ft_substitute) { - pdf_logfont("emulate ttf cidfont\n"); + pdf_log_font("emulate ttf cidfont\n"); fterr = FT_Select_Charmap(face, ft_encoding_unicode); if (fterr) { - error = fz_throw("fonterror: no unicode cmap when emulating CID font: %s", ft_errorstring(fterr)); + error = fz_throw("fonterror: no unicode cmap when emulating CID font: %s", ft_error_string(fterr)); goto cleanup; } if (!strcmp(collection, "Adobe-CNS1")) - error = pdf_loadsystemcmap(&fontdesc->tottfcmap, "Adobe-CNS1-UCS2"); + error = pdf_load_system_cmap(&fontdesc->to_ttf_cmap, "Adobe-CNS1-UCS2"); else if (!strcmp(collection, "Adobe-GB1")) - error = pdf_loadsystemcmap(&fontdesc->tottfcmap, "Adobe-GB1-UCS2"); + error = pdf_load_system_cmap(&fontdesc->to_ttf_cmap, "Adobe-GB1-UCS2"); else if (!strcmp(collection, "Adobe-Japan1")) - error = pdf_loadsystemcmap(&fontdesc->tottfcmap, "Adobe-Japan1-UCS2"); + error = pdf_load_system_cmap(&fontdesc->to_ttf_cmap, "Adobe-Japan1-UCS2"); else if (!strcmp(collection, "Adobe-Japan2")) - error = pdf_loadsystemcmap(&fontdesc->tottfcmap, "Adobe-Japan2-UCS2"); + error = pdf_load_system_cmap(&fontdesc->to_ttf_cmap, "Adobe-Japan2-UCS2"); else if (!strcmp(collection, "Adobe-Korea1")) - error = pdf_loadsystemcmap(&fontdesc->tottfcmap, "Adobe-Korea1-UCS2"); + error = pdf_load_system_cmap(&fontdesc->to_ttf_cmap, "Adobe-Korea1-UCS2"); else error = fz_okay; @@ -723,137 +723,137 @@ loadcidfont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict, fz_obj *enco } } - error = pdf_loadtounicode(fontdesc, xref, nil, collection, tounicode); + error = pdf_load_to_unicode(fontdesc, xref, NULL, collection, to_unicode); if (error) - fz_catch(error, "cannot load tounicode"); + fz_catch(error, "cannot load to_unicode"); /* Horizontal */ dw = 1000; - obj = fz_dictgets(dict, "DW"); + obj = fz_dict_gets(dict, "DW"); if (obj) - dw = fz_toint(obj); - pdf_setdefaulthmtx(fontdesc, dw); + dw = fz_to_int(obj); + pdf_set_default_hmtx(fontdesc, dw); - widths = fz_dictgets(dict, "W"); + widths = fz_dict_gets(dict, "W"); if (widths) { int c0, c1, w; - for (i = 0; i < fz_arraylen(widths); ) + for (i = 0; i < fz_array_len(widths); ) { - c0 = fz_toint(fz_arrayget(widths, i)); - obj = fz_arrayget(widths, i + 1); - if (fz_isarray(obj)) + c0 = fz_to_int(fz_array_get(widths, i)); + obj = fz_array_get(widths, i + 1); + if (fz_is_array(obj)) { - for (k = 0; k < fz_arraylen(obj); k++) + for (k = 0; k < fz_array_len(obj); k++) { - w = fz_toint(fz_arrayget(obj, k)); - pdf_addhmtx(fontdesc, c0 + k, c0 + k, w); + w = fz_to_int(fz_array_get(obj, k)); + pdf_add_hmtx(fontdesc, c0 + k, c0 + k, w); } i += 2; } else { - c1 = fz_toint(obj); - w = fz_toint(fz_arrayget(widths, i + 2)); - pdf_addhmtx(fontdesc, c0, c1, w); + c1 = fz_to_int(obj); + w = fz_to_int(fz_array_get(widths, i + 2)); + pdf_add_hmtx(fontdesc, c0, c1, w); i += 3; } } } - pdf_endhmtx(fontdesc); + pdf_end_hmtx(fontdesc); /* Vertical */ - if (pdf_getwmode(fontdesc->encoding) == 1) + if (pdf_get_wmode(fontdesc->encoding) == 1) { int dw2y = 880; int dw2w = -1000; - obj = fz_dictgets(dict, "DW2"); + obj = fz_dict_gets(dict, "DW2"); if (obj) { - dw2y = fz_toint(fz_arrayget(obj, 0)); - dw2w = fz_toint(fz_arrayget(obj, 1)); + dw2y = fz_to_int(fz_array_get(obj, 0)); + dw2w = fz_to_int(fz_array_get(obj, 1)); } - pdf_setdefaultvmtx(fontdesc, dw2y, dw2w); + pdf_set_default_vmtx(fontdesc, dw2y, dw2w); - widths = fz_dictgets(dict, "W2"); + widths = fz_dict_gets(dict, "W2"); if (widths) { int c0, c1, w, x, y; - for (i = 0; i < fz_arraylen(widths); ) + for (i = 0; i < fz_array_len(widths); ) { - c0 = fz_toint(fz_arrayget(widths, i)); - obj = fz_arrayget(widths, i + 1); - if (fz_isarray(obj)) + c0 = fz_to_int(fz_array_get(widths, i)); + obj = fz_array_get(widths, i + 1); + if (fz_is_array(obj)) { - for (k = 0; k * 3 < fz_arraylen(obj); k ++) + for (k = 0; k * 3 < fz_array_len(obj); k ++) { - w = fz_toint(fz_arrayget(obj, k * 3 + 0)); - x = fz_toint(fz_arrayget(obj, k * 3 + 1)); - y = fz_toint(fz_arrayget(obj, k * 3 + 2)); - pdf_addvmtx(fontdesc, c0 + k, c0 + k, x, y, w); + w = fz_to_int(fz_array_get(obj, k * 3 + 0)); + x = fz_to_int(fz_array_get(obj, k * 3 + 1)); + y = fz_to_int(fz_array_get(obj, k * 3 + 2)); + pdf_add_vmtx(fontdesc, c0 + k, c0 + k, x, y, w); } i += 2; } else { - c1 = fz_toint(obj); - w = fz_toint(fz_arrayget(widths, i + 2)); - x = fz_toint(fz_arrayget(widths, i + 3)); - y = fz_toint(fz_arrayget(widths, i + 4)); - pdf_addvmtx(fontdesc, c0, c1, x, y, w); + c1 = fz_to_int(obj); + w = fz_to_int(fz_array_get(widths, i + 2)); + x = fz_to_int(fz_array_get(widths, i + 3)); + y = fz_to_int(fz_array_get(widths, i + 4)); + pdf_add_vmtx(fontdesc, c0, c1, x, y, w); i += 5; } } } - pdf_endvmtx(fontdesc); + pdf_end_vmtx(fontdesc); } - pdf_logfont("}\n"); + pdf_log_font("}\n"); *fontdescp = fontdesc; return fz_okay; cleanup: - pdf_dropfont(fontdesc); - return fz_rethrow(error, "cannot load cid font (%d %d R)", fz_tonum(dict), fz_togen(dict)); + pdf_drop_font(fontdesc); + return fz_rethrow(error, "cannot load cid font (%d %d R)", fz_to_num(dict), fz_to_gen(dict)); } static fz_error -loadtype0(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict) +load_type0_font(pdf_font_desc **fontdescp, pdf_xref *xref, fz_obj *dict) { fz_error error; fz_obj *dfonts; fz_obj *dfont; fz_obj *subtype; fz_obj *encoding; - fz_obj *tounicode; + fz_obj *to_unicode; - dfonts = fz_dictgets(dict, "DescendantFonts"); + dfonts = fz_dict_gets(dict, "DescendantFonts"); if (!dfonts) return fz_throw("cid font is missing descendant fonts"); - dfont = fz_arrayget(dfonts, 0); + dfont = fz_array_get(dfonts, 0); - subtype = fz_dictgets(dfont, "Subtype"); - encoding = fz_dictgets(dict, "Encoding"); - tounicode = fz_dictgets(dict, "ToUnicode"); + subtype = fz_dict_gets(dfont, "Subtype"); + encoding = fz_dict_gets(dict, "Encoding"); + to_unicode = fz_dict_gets(dict, "ToUnicode"); - if (fz_isname(subtype) && !strcmp(fz_toname(subtype), "CIDFontType0")) - error = loadcidfont(fontdescp, xref, dfont, encoding, tounicode); - else if (fz_isname(subtype) && !strcmp(fz_toname(subtype), "CIDFontType2")) - error = loadcidfont(fontdescp, xref, dfont, encoding, tounicode); + if (fz_is_name(subtype) && !strcmp(fz_to_name(subtype), "CIDFontType0")) + error = load_cid_font(fontdescp, xref, dfont, encoding, to_unicode); + else if (fz_is_name(subtype) && !strcmp(fz_to_name(subtype), "CIDFontType2")) + error = load_cid_font(fontdescp, xref, dfont, encoding, to_unicode); else error = fz_throw("syntaxerror: unknown cid font type"); if (error) - return fz_rethrow(error, "cannot load descendant font (%d %d R)", fz_tonum(dfont), fz_togen(dfont)); + return fz_rethrow(error, "cannot load descendant font (%d %d R)", fz_to_num(dfont), fz_to_gen(dfont)); return fz_okay; } @@ -863,170 +863,170 @@ loadtype0(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *dict) */ fz_error -pdf_loadfontdescriptor(pdf_fontdesc *fontdesc, pdf_xref *xref, fz_obj *dict, char *collection, char *basefont) +pdf_load_font_descriptor(pdf_font_desc *fontdesc, pdf_xref *xref, fz_obj *dict, char *collection, char *basefont) { fz_error error; fz_obj *obj1, *obj2, *obj3, *obj; char *fontname; char *origname; - pdf_logfont("load fontdescriptor {\n"); + pdf_log_font("load fontdescriptor {\n"); if (!strchr(basefont, ',') || strchr(basefont, '+')) - origname = fz_toname(fz_dictgets(dict, "FontName")); + origname = fz_to_name(fz_dict_gets(dict, "FontName")); else origname = basefont; - fontname = cleanfontname(origname); + fontname = clean_font_name(origname); - pdf_logfont("fontname %s -> %s\n", origname, fontname); + pdf_log_font("fontname %s -> %s\n", origname, fontname); - fontdesc->flags = fz_toint(fz_dictgets(dict, "Flags")); - fontdesc->italicangle = fz_toreal(fz_dictgets(dict, "ItalicAngle")); - fontdesc->ascent = fz_toreal(fz_dictgets(dict, "Ascent")); - fontdesc->descent = fz_toreal(fz_dictgets(dict, "Descent")); - fontdesc->capheight = fz_toreal(fz_dictgets(dict, "CapHeight")); - fontdesc->xheight = fz_toreal(fz_dictgets(dict, "XHeight")); - fontdesc->missingwidth = fz_toreal(fz_dictgets(dict, "MissingWidth")); + fontdesc->flags = fz_to_int(fz_dict_gets(dict, "Flags")); + fontdesc->italic_angle = fz_to_real(fz_dict_gets(dict, "ItalicAngle")); + fontdesc->ascent = fz_to_real(fz_dict_gets(dict, "Ascent")); + fontdesc->descent = fz_to_real(fz_dict_gets(dict, "Descent")); + fontdesc->cap_height = fz_to_real(fz_dict_gets(dict, "CapHeight")); + fontdesc->x_height = fz_to_real(fz_dict_gets(dict, "XHeight")); + fontdesc->missing_width = fz_to_real(fz_dict_gets(dict, "MissingWidth")); - pdf_logfont("flags %d\n", fontdesc->flags); + pdf_log_font("flags %d\n", fontdesc->flags); - obj1 = fz_dictgets(dict, "FontFile"); - obj2 = fz_dictgets(dict, "FontFile2"); - obj3 = fz_dictgets(dict, "FontFile3"); + obj1 = fz_dict_gets(dict, "FontFile"); + obj2 = fz_dict_gets(dict, "FontFile2"); + obj3 = fz_dict_gets(dict, "FontFile3"); obj = obj1 ? obj1 : obj2 ? obj2 : obj3; if (getenv("NOFONT")) - obj = nil; + obj = NULL; - if (fz_isindirect(obj)) + if (fz_is_indirect(obj)) { - error = pdf_loadembeddedfont(fontdesc, xref, obj); + error = pdf_load_embedded_font(fontdesc, xref, obj); if (error) { fz_catch(error, "ignored error when loading embedded font, attempting to load system font"); if (origname != fontname) - error = pdf_loadbuiltinfont(fontdesc, fontname); + error = pdf_load_builtin_font(fontdesc, fontname); else - error = pdf_loadsystemfont(fontdesc, fontname, collection); + error = pdf_load_system_font(fontdesc, fontname, collection); if (error) - return fz_rethrow(error, "cannot load font descriptor (%d %d R)", fz_tonum(dict), fz_togen(dict)); + return fz_rethrow(error, "cannot load font descriptor (%d %d R)", fz_to_num(dict), fz_to_gen(dict)); } } else { if (origname != fontname) - error = pdf_loadbuiltinfont(fontdesc, fontname); + error = pdf_load_builtin_font(fontdesc, fontname); else - error = pdf_loadsystemfont(fontdesc, fontname, collection); + error = pdf_load_system_font(fontdesc, fontname, collection); if (error) - return fz_rethrow(error, "cannot load font descriptor (%d %d R)", fz_tonum(dict), fz_togen(dict)); + return fz_rethrow(error, "cannot load font descriptor (%d %d R)", fz_to_num(dict), fz_to_gen(dict)); } fz_strlcpy(fontdesc->font->name, fontname, sizeof fontdesc->font->name); - pdf_logfont("}\n"); + pdf_log_font("}\n"); return fz_okay; } static void -pdf_makewidthtable(pdf_fontdesc *fontdesc) +pdf_make_width_table(pdf_font_desc *fontdesc) { fz_font *font = fontdesc->font; int i, k, cid, gid; - font->widthcount = 0; - for (i = 0; i < fontdesc->nhmtx; i++) + font->width_count = 0; + for (i = 0; i < fontdesc->hmtx_len; i++) { for (k = fontdesc->hmtx[i].lo; k <= fontdesc->hmtx[i].hi; k++) { - cid = pdf_lookupcmap(fontdesc->encoding, k); - gid = pdf_fontcidtogid(fontdesc, cid); - if (gid > font->widthcount) - font->widthcount = gid; + cid = pdf_lookup_cmap(fontdesc->encoding, k); + gid = pdf_font_cid_to_gid(fontdesc, cid); + if (gid > font->width_count) + font->width_count = gid; } } - font->widthcount ++; + font->width_count ++; - font->widthtable = fz_calloc(font->widthcount, sizeof(int)); - memset(font->widthtable, 0, sizeof(int) * font->widthcount); + font->width_table = fz_calloc(font->width_count, sizeof(int)); + memset(font->width_table, 0, sizeof(int) * font->width_count); - for (i = 0; i < fontdesc->nhmtx; i++) + for (i = 0; i < fontdesc->hmtx_len; i++) { for (k = fontdesc->hmtx[i].lo; k <= fontdesc->hmtx[i].hi; k++) { - cid = pdf_lookupcmap(fontdesc->encoding, k); - gid = pdf_fontcidtogid(fontdesc, cid); - if (gid >= 0 && gid < font->widthcount) - font->widthtable[gid] = fontdesc->hmtx[i].w; + cid = pdf_lookup_cmap(fontdesc->encoding, k); + gid = pdf_font_cid_to_gid(fontdesc, cid); + if (gid >= 0 && gid < font->width_count) + font->width_table[gid] = fontdesc->hmtx[i].w; } } } fz_error -pdf_loadfont(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict) +pdf_load_font(pdf_font_desc **fontdescp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict) { fz_error error; char *subtype; fz_obj *dfonts; fz_obj *charprocs; - if ((*fontdescp = pdf_finditem(xref->store, pdf_dropfont, dict))) + if ((*fontdescp = pdf_find_item(xref->store, pdf_drop_font, dict))) { - pdf_keepfont(*fontdescp); + pdf_keep_font(*fontdescp); return fz_okay; } - subtype = fz_toname(fz_dictgets(dict, "Subtype")); - dfonts = fz_dictgets(dict, "DescendantFonts"); - charprocs = fz_dictgets(dict, "CharProcs"); + subtype = fz_to_name(fz_dict_gets(dict, "Subtype")); + dfonts = fz_dict_gets(dict, "DescendantFonts"); + charprocs = fz_dict_gets(dict, "CharProcs"); if (subtype && !strcmp(subtype, "Type0")) - error = loadtype0(fontdescp, xref, dict); + error = load_type0_font(fontdescp, xref, dict); else if (subtype && !strcmp(subtype, "Type1")) - error = loadsimplefont(fontdescp, xref, dict); + error = load_simple_font(fontdescp, xref, dict); else if (subtype && !strcmp(subtype, "MMType1")) - error = loadsimplefont(fontdescp, xref, dict); + error = load_simple_font(fontdescp, xref, dict); else if (subtype && !strcmp(subtype, "TrueType")) - error = loadsimplefont(fontdescp, xref, dict); + error = load_simple_font(fontdescp, xref, dict); else if (subtype && !strcmp(subtype, "Type3")) - error = pdf_loadtype3font(fontdescp, xref, rdb, dict); + error = pdf_load_type3_font(fontdescp, xref, rdb, dict); else if (charprocs) { fz_warn("unknown font format, guessing type3."); - error = pdf_loadtype3font(fontdescp, xref, rdb, dict); + error = pdf_load_type3_font(fontdescp, xref, rdb, dict); } else if (dfonts) { fz_warn("unknown font format, guessing type0."); - error = loadtype0(fontdescp, xref, dict); + error = load_type0_font(fontdescp, xref, dict); } else { fz_warn("unknown font format, guessing type1 or truetype."); - error = loadsimplefont(fontdescp, xref, dict); + error = load_simple_font(fontdescp, xref, dict); } if (error) - return fz_rethrow(error, "cannot load font (%d %d R)", fz_tonum(dict), fz_togen(dict)); + return fz_rethrow(error, "cannot load font (%d %d R)", fz_to_num(dict), fz_to_gen(dict)); /* Save the widths to stretch non-CJK substitute fonts */ - if ((*fontdescp)->font->ftsubstitute && !(*fontdescp)->tottfcmap) - pdf_makewidthtable(*fontdescp); + if ((*fontdescp)->font->ft_substitute && !(*fontdescp)->to_ttf_cmap) + pdf_make_width_table(*fontdescp); - pdf_storeitem(xref->store, pdf_keepfont, pdf_dropfont, dict, *fontdescp); + pdf_store_item(xref->store, pdf_keep_font, pdf_drop_font, dict, *fontdescp); return fz_okay; } void -pdf_debugfont(pdf_fontdesc *fontdesc) +pdf_debug_font(pdf_font_desc *fontdesc) { int i; printf("fontdesc {\n"); - if (fontdesc->font->ftface) + if (fontdesc->font->ft_face) printf("\tfreetype font\n"); if (fontdesc->font->t3procs) printf("\ttype3 font\n"); @@ -1035,7 +1035,7 @@ pdf_debugfont(pdf_fontdesc *fontdesc) printf("\tDW %d\n", fontdesc->dhmtx.w); printf("\tW {\n"); - for (i = 0; i < fontdesc->nhmtx; i++) + for (i = 0; i < fontdesc->hmtx_len; i++) printf("\t\t<%04x> <%04x> %d\n", fontdesc->hmtx[i].lo, fontdesc->hmtx[i].hi, fontdesc->hmtx[i].w); printf("\t}\n"); @@ -1044,7 +1044,7 @@ pdf_debugfont(pdf_fontdesc *fontdesc) { printf("\tDW2 [%d %d]\n", fontdesc->dvmtx.y, fontdesc->dvmtx.w); printf("\tW2 {\n"); - for (i = 0; i < fontdesc->nvmtx; i++) + for (i = 0; i < fontdesc->vmtx_len; i++) printf("\t\t<%04x> <%04x> %d %d %d\n", fontdesc->vmtx[i].lo, fontdesc->vmtx[i].hi, fontdesc->vmtx[i].x, fontdesc->vmtx[i].y, fontdesc->vmtx[i].w); printf("\t}\n"); diff --git a/pdf/pdf_fontagl.c b/pdf/pdf_fontagl.c index e310848b..e9a7af95 100644 --- a/pdf/pdf_fontagl.c +++ b/pdf/pdf_fontagl.c @@ -12,7 +12,7 @@ */ static const struct { char *name; int ucs; } -aglcodes[] = { +agl_codes[] = { {"A", 0x0041}, {"AE", 0x00C6}, {"AEacute", 0x01FC}, @@ -4297,7 +4297,7 @@ aglcodes[] = { }; static const struct { int ucs; int ofs; } -agldupcodes[] = { +agl_dup_codes[] = { {0x0020, 0}, {0x007C, 3}, {0x00A0, 6}, @@ -4678,7 +4678,7 @@ agldupcodes[] = { {0xFEF4, 1354}, }; -static char *agldupnames[] = { +static char *agl_dup_names[] = { "space", "spacehackarabic", 0, "bar", "verticalbar", 0, "nbspace", "nonbreakingspace", 0, @@ -5062,12 +5062,12 @@ static char *agldupnames[] = { #include "fitz.h" #include "mupdf.h" -int pdf_lookupagl(char *name) +int pdf_lookup_agl(char *name) { char buf[64]; char *p; int l = 0; - int r = nelem(aglcodes) - 1; + int r = nelem(agl_codes) - 1; fz_strlcpy(buf, name, sizeof buf); @@ -5080,40 +5080,40 @@ int pdf_lookupagl(char *name) while (l <= r) { int m = (l + r) >> 1; - int c = strcmp(buf, aglcodes[m].name); + int c = strcmp(buf, agl_codes[m].name); if (c < 0) r = m - 1; else if (c > 0) l = m + 1; else - return aglcodes[m].ucs; + return agl_codes[m].ucs; } if (strstr(buf, "uni") == buf) - return strtol(buf + 3, nil, 16); + return strtol(buf + 3, NULL, 16); else if (strstr(buf, "u") == buf) - return strtol(buf + 1, nil, 16); + return strtol(buf + 1, NULL, 16); else if (strstr(buf, "a") == buf && strlen(buf) >= 3) - return strtol(buf + 1, nil, 10); + return strtol(buf + 1, NULL, 10); return 0; } -static char *aglnoname[1] = { 0 }; +static char *agl_no_name[1] = { 0 }; -char **pdf_lookupaglnames(int ucs) +char **pdf_lookup_agl_names(int ucs) { int l = 0; - int r = nelem(agldupcodes) - 1; + int r = nelem(agl_dup_codes) - 1; while (l <= r) { int m = (l + r) >> 1; - if (ucs < agldupcodes[m].ucs) + if (ucs < agl_dup_codes[m].ucs) r = m - 1; - else if (ucs > agldupcodes[m].ucs) + else if (ucs > agl_dup_codes[m].ucs) l = m + 1; else - return agldupnames + agldupcodes[m].ofs; + return agl_dup_names + agl_dup_codes[m].ofs; } - return aglnoname; + return agl_no_name; } diff --git a/pdf/pdf_fontenc.c b/pdf/pdf_fontenc.c index 0f72cb6a..daa1aa27 100644 --- a/pdf/pdf_fontenc.c +++ b/pdf/pdf_fontenc.c @@ -1,19 +1,19 @@ #include "fitz.h" #include "mupdf.h" -#define _notdef nil +#define _notdef NULL -void pdf_loadencoding(char **estrings, char *encoding) +void pdf_load_encoding(char **estrings, char *encoding) { - char **bstrings = nil; + char **bstrings = NULL; int i; if (!strcmp(encoding, "MacRomanEncoding")) - bstrings = (char**) pdf_macroman; + bstrings = (char**) pdf_mac_roman; if (!strcmp(encoding, "MacExpertEncoding")) - bstrings = (char**) pdf_macexpert; + bstrings = (char**) pdf_mac_expert; if (!strcmp(encoding, "WinAnsiEncoding")) - bstrings = (char**) pdf_winansi; + bstrings = (char**) pdf_win_ansi; if (!strcmp(encoding, "StandardEncoding")) bstrings = (char**) pdf_standard; @@ -22,7 +22,7 @@ void pdf_loadencoding(char **estrings, char *encoding) estrings[i] = bstrings[i]; } -const unsigned short pdf_docencoding[256] = +const unsigned short pdf_doc_encoding[256] = { 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0000, 0x0009, 0x000A, 0x0000, 0x0000, 0x000D, 0x0000, 0x0000, @@ -58,7 +58,7 @@ const unsigned short pdf_docencoding[256] = 0x00f8, 0x00f9, 0x00fa, 0x00fb, 0x00fc, 0x00fd, 0x00fe, 0x00ff }; -const char * const pdf_macroman[256] = { _notdef, _notdef, +const char * const pdf_mac_roman[256] = { _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, @@ -98,7 +98,7 @@ const char * const pdf_macroman[256] = { _notdef, _notdef, "Ugrave", "dotlessi", "circumflex", "tilde", "macron", "breve", "dotaccent", "ring", "cedilla", "hungarumlaut", "ogonek", "caron" }; -const char * const pdf_macexpert[256] = { _notdef, _notdef, +const char * const pdf_mac_expert[256] = { _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, @@ -151,7 +151,7 @@ const char * const pdf_macexpert[256] = { _notdef, _notdef, "msuperior", "commasuperior", "periodsuperior", "Dotaccentsmall", "Ringsmall", _notdef, _notdef, _notdef, _notdef }; -const char * const pdf_winansi[256] = { _notdef, _notdef, _notdef, +const char * const pdf_win_ansi[256] = { _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, _notdef, diff --git a/pdf/pdf_fontfile.c b/pdf/pdf_fontfile.c index 1fedae44..79eee737 100644 --- a/pdf/pdf_fontfile.c +++ b/pdf/pdf_fontfile.c @@ -37,15 +37,15 @@ extern const unsigned int pdf_font_DroidSansFallback_ttf_len; enum { - FD_FIXED = 1 << 0, + FD_FIXED_PITCH = 1 << 0, FD_SERIF = 1 << 1, FD_SYMBOLIC = 1 << 2, FD_SCRIPT = 1 << 3, FD_NONSYMBOLIC = 1 << 5, FD_ITALIC = 1 << 6, - FD_ALLCAP = 1 << 16, - FD_SMALLCAP = 1 << 17, - FD_FORCEBOLD = 1 << 18 + FD_ALL_CAP = 1 << 16, + FD_SMALL_CAP = 1 << 17, + FD_FORCE_BOLD = 1 << 18 }; enum { CNS, GB, Japan, Korea }; @@ -55,7 +55,7 @@ static const struct { const char *name; const unsigned char *cff; const unsigned int *len; -} basefonts[] = { +} base_fonts[] = { { "Courier", pdf_font_NimbusMonL_Regu_cff_buf, &pdf_font_NimbusMonL_Regu_cff_len }, @@ -98,30 +98,30 @@ static const struct { { "ZapfDingbats", pdf_font_Dingbats_cff_buf, &pdf_font_Dingbats_cff_len }, - { nil, nil, nil } + { NULL, NULL, NULL } }; fz_error -pdf_loadbuiltinfont(pdf_fontdesc *fontdesc, char *fontname) +pdf_load_builtin_font(pdf_font_desc *fontdesc, char *fontname) { fz_error error; unsigned char *data; unsigned int len; int i; - for (i = 0; basefonts[i].name; i++) - if (!strcmp(fontname, basefonts[i].name)) + for (i = 0; base_fonts[i].name; i++) + if (!strcmp(fontname, base_fonts[i].name)) goto found; return fz_throw("cannot find font: '%s'", fontname); found: - pdf_logfont("load builtin font %s\n", fontname); + pdf_log_font("load builtin font %s\n", fontname); - data = (unsigned char *) basefonts[i].cff; - len = *basefonts[i].len; + data = (unsigned char *) base_fonts[i].cff; + len = *base_fonts[i].len; - error = fz_newfontfrombuffer(&fontdesc->font, data, len, 0); + error = fz_new_font_from_memory(&fontdesc->font, data, len, 0); if (error) return fz_rethrow(error, "cannot load freetype font from buffer"); @@ -134,7 +134,7 @@ found: } static fz_error -loadsystemcidfont(pdf_fontdesc *fontdesc, int ros, int kind) +load_system_cid_font(pdf_font_desc *fontdesc, int ros, int kind) { #ifndef NOCJK fz_error error; @@ -142,13 +142,13 @@ loadsystemcidfont(pdf_fontdesc *fontdesc, int ros, int kind) We only have one builtin fallback font. We'd really like to have one for each combination of ROS and Kind. */ - pdf_logfont("loading builtin CJK font\n"); - error = fz_newfontfrombuffer(&fontdesc->font, + pdf_log_font("loading builtin CJK font\n"); + error = fz_new_font_from_memory(&fontdesc->font, (unsigned char *)pdf_font_DroidSansFallback_ttf_buf, pdf_font_DroidSansFallback_ttf_len, 0); if (error) return fz_rethrow(error, "cannot load builtin CJK font"); - fontdesc->font->ftsubstitute = 1; /* substitute font */ + fontdesc->font->ft_substitute = 1; /* substitute font */ return fz_okay; #else return fz_throw("no builtin CJK font file"); @@ -156,7 +156,7 @@ loadsystemcidfont(pdf_fontdesc *fontdesc, int ros, int kind) } fz_error -pdf_loadsystemfont(pdf_fontdesc *fontdesc, char *fontname, char *collection) +pdf_load_system_font(pdf_font_desc *fontdesc, char *fontname, char *collection) { fz_error error; char *name; @@ -174,7 +174,7 @@ pdf_loadsystemfont(pdf_fontdesc *fontdesc, char *fontname, char *collection) if (strstr(fontname, "Oblique")) isitalic = 1; - if (fontdesc->flags & FD_FIXED) + if (fontdesc->flags & FD_FIXED_PITCH) isfixed = 1; if (fontdesc->flags & FD_SERIF) isserif = 1; @@ -182,10 +182,10 @@ pdf_loadsystemfont(pdf_fontdesc *fontdesc, char *fontname, char *collection) isitalic = 1; if (fontdesc->flags & FD_SCRIPT) isscript = 1; - if (fontdesc->flags & FD_FORCEBOLD) + if (fontdesc->flags & FD_FORCE_BOLD) isbold = 1; - pdf_logfont("fixed-%d serif-%d italic-%d script-%d bold-%d\n", + pdf_log_font("fixed-%d serif-%d italic-%d script-%d bold-%d\n", isfixed, isserif, isitalic, isscript, isbold); if (collection) @@ -198,15 +198,15 @@ pdf_loadsystemfont(pdf_fontdesc *fontdesc, char *fontname, char *collection) kind = GOTHIC; if (!strcmp(collection, "Adobe-CNS1")) - return loadsystemcidfont(fontdesc, CNS, kind); + return load_system_cid_font(fontdesc, CNS, kind); else if (!strcmp(collection, "Adobe-GB1")) - return loadsystemcidfont(fontdesc, GB, kind); + return load_system_cid_font(fontdesc, GB, kind); else if (!strcmp(collection, "Adobe-Japan1")) - return loadsystemcidfont(fontdesc, Japan, kind); + return load_system_cid_font(fontdesc, Japan, kind); else if (!strcmp(collection, "Adobe-Japan2")) - return loadsystemcidfont(fontdesc, Japan, kind); + return load_system_cid_font(fontdesc, Japan, kind); else if (!strcmp(collection, "Adobe-Korea1")) - return loadsystemcidfont(fontdesc, Korea, kind); + return load_system_cid_font(fontdesc, Korea, kind); fz_warn("unknown cid collection: %s", collection); } @@ -247,38 +247,38 @@ pdf_loadsystemfont(pdf_fontdesc *fontdesc, char *fontname, char *collection) } } - error = pdf_loadbuiltinfont(fontdesc, name); + error = pdf_load_builtin_font(fontdesc, name); if (error) return fz_throw("cannot load builtin substitute font: %s", name); /* it's a substitute font: override the metrics */ - fontdesc->font->ftsubstitute = 1; + fontdesc->font->ft_substitute = 1; return fz_okay; } fz_error -pdf_loadembeddedfont(pdf_fontdesc *fontdesc, pdf_xref *xref, fz_obj *stmref) +pdf_load_embedded_font(pdf_font_desc *fontdesc, pdf_xref *xref, fz_obj *stmref) { fz_error error; fz_buffer *buf; - pdf_logfont("load embedded font\n"); + pdf_log_font("load embedded font\n"); - error = pdf_loadstream(&buf, xref, fz_tonum(stmref), fz_togen(stmref)); + error = pdf_load_stream(&buf, xref, fz_to_num(stmref), fz_to_gen(stmref)); if (error) - return fz_rethrow(error, "cannot load font stream (%d %d R)", fz_tonum(stmref), fz_togen(stmref)); + return fz_rethrow(error, "cannot load font stream (%d %d R)", fz_to_num(stmref), fz_to_gen(stmref)); - error = fz_newfontfrombuffer(&fontdesc->font, buf->data, buf->len, 0); + error = fz_new_font_from_memory(&fontdesc->font, buf->data, buf->len, 0); if (error) { - fz_dropbuffer(buf); - return fz_rethrow(error, "cannot load embedded font (%d %d R)", fz_tonum(stmref), fz_togen(stmref)); + fz_drop_buffer(buf); + return fz_rethrow(error, "cannot load embedded font (%d %d R)", fz_to_num(stmref), fz_to_gen(stmref)); } /* save the buffer so we can free it later */ - fontdesc->font->ftdata = buf->data; - fontdesc->font->ftsize = buf->len; + fontdesc->font->ft_data = buf->data; + fontdesc->font->ft_size = buf->len; fz_free(buf); /* only free the fz_buffer struct, not the contained data */ fontdesc->isembedded = 1; diff --git a/pdf/pdf_fontmtx.c b/pdf/pdf_fontmtx.c index e957125a..2fc085de 100644 --- a/pdf/pdf_fontmtx.c +++ b/pdf/pdf_fontmtx.c @@ -2,54 +2,54 @@ #include "mupdf.h" void -pdf_setfontwmode(pdf_fontdesc *font, int wmode) +pdf_set_font_wmode(pdf_font_desc *font, int wmode) { font->wmode = wmode; } void -pdf_setdefaulthmtx(pdf_fontdesc *font, int w) +pdf_set_default_hmtx(pdf_font_desc *font, int w) { font->dhmtx.w = w; } void -pdf_setdefaultvmtx(pdf_fontdesc *font, int y, int w) +pdf_set_default_vmtx(pdf_font_desc *font, int y, int w) { font->dvmtx.y = y; font->dvmtx.w = w; } void -pdf_addhmtx(pdf_fontdesc *font, int lo, int hi, int w) +pdf_add_hmtx(pdf_font_desc *font, int lo, int hi, int w) { - if (font->nhmtx + 1 >= font->hmtxcap) + if (font->hmtx_len + 1 >= font->hmtx_cap) { - font->hmtxcap = font->hmtxcap + 16; - font->hmtx = fz_realloc(font->hmtx, font->hmtxcap, sizeof(pdf_hmtx)); + font->hmtx_cap = font->hmtx_cap + 16; + font->hmtx = fz_realloc(font->hmtx, font->hmtx_cap, sizeof(pdf_hmtx)); } - font->hmtx[font->nhmtx].lo = lo; - font->hmtx[font->nhmtx].hi = hi; - font->hmtx[font->nhmtx].w = w; - font->nhmtx++; + font->hmtx[font->hmtx_len].lo = lo; + font->hmtx[font->hmtx_len].hi = hi; + font->hmtx[font->hmtx_len].w = w; + font->hmtx_len++; } void -pdf_addvmtx(pdf_fontdesc *font, int lo, int hi, int x, int y, int w) +pdf_add_vmtx(pdf_font_desc *font, int lo, int hi, int x, int y, int w) { - if (font->nvmtx + 1 >= font->vmtxcap) + if (font->vmtx_len + 1 >= font->vmtx_cap) { - font->vmtxcap = font->vmtxcap + 16; - font->vmtx = fz_realloc(font->vmtx, font->vmtxcap, sizeof(pdf_vmtx)); + font->vmtx_cap = font->vmtx_cap + 16; + font->vmtx = fz_realloc(font->vmtx, font->vmtx_cap, sizeof(pdf_vmtx)); } - font->vmtx[font->nvmtx].lo = lo; - font->vmtx[font->nvmtx].hi = hi; - font->vmtx[font->nvmtx].x = x; - font->vmtx[font->nvmtx].y = y; - font->vmtx[font->nvmtx].w = w; - font->nvmtx++; + font->vmtx[font->vmtx_len].lo = lo; + font->vmtx[font->vmtx_len].hi = hi; + font->vmtx[font->vmtx_len].x = x; + font->vmtx[font->vmtx_len].y = y; + font->vmtx[font->vmtx_len].w = w; + font->vmtx_len++; } static int cmph(const void *a0, const void *b0) @@ -67,26 +67,26 @@ static int cmpv(const void *a0, const void *b0) } void -pdf_endhmtx(pdf_fontdesc *font) +pdf_end_hmtx(pdf_font_desc *font) { if (!font->hmtx) return; - qsort(font->hmtx, font->nhmtx, sizeof(pdf_hmtx), cmph); + qsort(font->hmtx, font->hmtx_len, sizeof(pdf_hmtx), cmph); } void -pdf_endvmtx(pdf_fontdesc *font) +pdf_end_vmtx(pdf_font_desc *font) { if (!font->vmtx) return; - qsort(font->vmtx, font->nvmtx, sizeof(pdf_vmtx), cmpv); + qsort(font->vmtx, font->vmtx_len, sizeof(pdf_vmtx), cmpv); } pdf_hmtx -pdf_gethmtx(pdf_fontdesc *font, int cid) +pdf_get_hmtx(pdf_font_desc *font, int cid) { int l = 0; - int r = font->nhmtx - 1; + int r = font->hmtx_len - 1; int m; if (!font->hmtx) @@ -108,12 +108,12 @@ notfound: } pdf_vmtx -pdf_getvmtx(pdf_fontdesc *font, int cid) +pdf_get_vmtx(pdf_font_desc *font, int cid) { pdf_hmtx h; pdf_vmtx v; int l = 0; - int r = font->nvmtx - 1; + int r = font->vmtx_len - 1; int m; if (!font->vmtx) @@ -131,7 +131,7 @@ pdf_getvmtx(pdf_fontdesc *font, int cid) } notfound: - h = pdf_gethmtx(font, cid); + h = pdf_get_hmtx(font, cid); v = font->dvmtx; v.x = h.w / 2; return v; diff --git a/pdf/pdf_function.c b/pdf/pdf_function.c index 3fdd6ac7..392b5c19 100644 --- a/pdf/pdf_function.c +++ b/pdf/pdf_function.c @@ -3,8 +3,8 @@ enum { - MAXN = FZ_MAXCOLORS, - MAXM = FZ_MAXCOLORS, + MAXN = FZ_MAX_COLORS, + MAXM = FZ_MAX_COLORS, }; typedef struct psobj_s psobj; @@ -25,7 +25,7 @@ struct pdf_function_s int n; /* number of output values */ float domain[MAXM][2]; /* even index : min value, odd index : max value */ float range[MAXN][2]; /* even index : min value, odd index : max value */ - int hasrange; + int has_range; union { @@ -72,20 +72,20 @@ static inline float LERP(float x, float xmin, float xmax, float ymin, float ymax * PostScript calculator */ -enum { PSBOOL, PSINT, PSREAL, PSOPERATOR, PSBLOCK }; +enum { PS_BOOL, PS_INT, PS_REAL, PS_OPERATOR, PS_BLOCK }; enum { - PSOABS, PSOADD, PSOAND, PSOATAN, PSOBITSHIFT, PSOCEILING, - PSOCOPY, PSOCOS, PSOCVI, PSOCVR, PSODIV, PSODUP, PSOEQ, - PSOEXCH, PSOEXP, PSOFALSE, PSOFLOOR, PSOGE, PSOGT, PSOIDIV, - PSOINDEX, PSOLE, PSOLN, PSOLOG, PSOLT, PSOMOD, PSOMUL, - PSONE, PSONEG, PSONOT, PSOOR, PSOPOP, PSOROLL, PSOROUND, - PSOSIN, PSOSQRT, PSOSUB, PSOTRUE, PSOTRUNCATE, PSOXOR, - PSOIF, PSOIFELSE, PSORETURN + PS_OP_ABS, PS_OP_ADD, PS_OP_AND, PS_OP_ATAN, PS_OP_BITSHIFT, PS_OP_CEILING, + PS_OP_COPY, PS_OP_COS, PS_OP_CVI, PS_OP_CVR, PS_OP_DIV, PS_OP_DUP, PS_OP_EQ, + PS_OP_EXCH, PS_OP_EXP, PS_OP_FALSE, PS_OP_FLOOR, PS_OP_GE, PS_OP_GT, PS_OP_IDIV, + PS_OP_INDEX, PS_OP_LE, PS_OP_LN, PS_OP_LOG, PS_OP_LT, PS_OP_MOD, PS_OP_MUL, + PS_OP_NE, PS_OP_NEG, PS_OP_NOT, PS_OP_OR, PS_OP_POP, PS_OP_ROLL, PS_OP_ROUND, + PS_OP_SIN, PS_OP_SQRT, PS_OP_SUB, PS_OP_TRUE, PS_OP_TRUNCATE, PS_OP_XOR, + PS_OP_IF, PS_OP_IFELSE, PS_OP_RETURN }; -static char *psopnames[] = +static char *ps_op_names[] = { "abs", "add", "and", "atan", "bitshift", "ceiling", "copy", "cos", "cvi", "cvr", "div", "dup", "eq", "exch", "exp", @@ -108,16 +108,16 @@ struct psobj_s } u; }; -typedef struct psstack_s psstack; +typedef struct ps_stack_s ps_stack; -struct psstack_s +struct ps_stack_s { psobj stack[100]; int sp; }; void -pdf_debugpsstack(psstack *st) +pdf_debug_ps_stack(ps_stack *st) { int i; @@ -127,18 +127,18 @@ pdf_debugpsstack(psstack *st) { switch (st->stack[i].type) { - case PSBOOL: + case PS_BOOL: if (st->stack[i].u.b) printf("true "); else printf("false "); break; - case PSINT: + case PS_INT: printf("%d ", st->stack[i].u.i); break; - case PSREAL: + case PS_REAL: printf("%g ", st->stack[i].u.f); break; } @@ -148,110 +148,110 @@ pdf_debugpsstack(psstack *st) } static void -psinitstack(psstack *st) +ps_init_stack(ps_stack *st) { memset(st->stack, 0, sizeof(st->stack)); st->sp = 0; } static inline int -psoverflow(psstack *st, int n) +ps_overflow(ps_stack *st, int n) { return n < 0 || st->sp + n >= nelem(st->stack); } static inline int -psunderflow(psstack *st, int n) +ps_underflow(ps_stack *st, int n) { return n < 0 || st->sp - n < 0; } static inline int -psistype(psstack *st, int t) +ps_is_type(ps_stack *st, int t) { - return !psunderflow(st, 1) && st->stack[st->sp - 1].type == t; + return !ps_underflow(st, 1) && st->stack[st->sp - 1].type == t; } static inline int -psistype2(psstack *st, int t) +ps_is_type2(ps_stack *st, int t) { - return !psunderflow(st, 2) && st->stack[st->sp - 1].type == t && st->stack[st->sp - 2].type == t; + return !ps_underflow(st, 2) && st->stack[st->sp - 1].type == t && st->stack[st->sp - 2].type == t; } static void -pspushbool(psstack *st, int b) +ps_push_bool(ps_stack *st, int b) { - if (!psoverflow(st, 1)) + if (!ps_overflow(st, 1)) { - st->stack[st->sp].type = PSBOOL; + st->stack[st->sp].type = PS_BOOL; st->stack[st->sp].u.b = b; st->sp++; } } static void -pspushint(psstack *st, int n) +ps_push_int(ps_stack *st, int n) { - if (!psoverflow(st, 1)) + if (!ps_overflow(st, 1)) { - st->stack[st->sp].type = PSINT; + st->stack[st->sp].type = PS_INT; st->stack[st->sp].u.i = n; st->sp++; } } static void -pspushreal(psstack *st, float n) +ps_push_real(ps_stack *st, float n) { - if (!psoverflow(st, 1)) + if (!ps_overflow(st, 1)) { - st->stack[st->sp].type = PSREAL; + st->stack[st->sp].type = PS_REAL; st->stack[st->sp].u.f = n; st->sp++; } } static int -pspopbool(psstack *st) +ps_pop_bool(ps_stack *st) { - if (!psunderflow(st, 1)) + if (!ps_underflow(st, 1)) { - if (psistype(st, PSBOOL)) + if (ps_is_type(st, PS_BOOL)) return st->stack[--st->sp].u.b; } return 0; } static int -pspopint(psstack *st) +ps_pop_int(ps_stack *st) { - if (!psunderflow(st, 1)) + if (!ps_underflow(st, 1)) { - if (psistype(st, PSINT)) + if (ps_is_type(st, PS_INT)) return st->stack[--st->sp].u.i; - if (psistype(st, PSREAL)) + if (ps_is_type(st, PS_REAL)) return st->stack[--st->sp].u.f; } return 0; } static float -pspopreal(psstack *st) +ps_pop_real(ps_stack *st) { - if (!psunderflow(st, 1)) + if (!ps_underflow(st, 1)) { - if (psistype(st, PSINT)) + if (ps_is_type(st, PS_INT)) return st->stack[--st->sp].u.i; - if (psistype(st, PSREAL)) + if (ps_is_type(st, PS_REAL)) return st->stack[--st->sp].u.f; } return 0; } static void -pscopy(psstack *st, int n) +ps_copy(ps_stack *st, int n) { - if (!psunderflow(st, n) && !psoverflow(st, n)) + if (!ps_underflow(st, n) && !ps_overflow(st, n)) { memcpy(st->stack + st->sp, st->stack + st->sp - n, n * sizeof(psobj)); st->sp += n; @@ -259,12 +259,12 @@ pscopy(psstack *st, int n) } static void -psroll(psstack *st, int n, int j) +ps_roll(ps_stack *st, int n, int j) { psobj tmp; int i; - if (psunderflow(st, n) || j == 0 || n == 0) + if (ps_underflow(st, n) || j == 0 || n == 0) return; if (j >= 0) @@ -287,9 +287,9 @@ psroll(psstack *st, int n, int j) } static void -psindex(psstack *st, int n) +ps_index(ps_stack *st, int n) { - if (!psoverflow(st, 1) && !psunderflow(st, n)) + if (!ps_overflow(st, 1) && !ps_underflow(st, n)) { st->stack[st->sp] = st->stack[st->sp - n - 1]; st->sp++; @@ -297,7 +297,7 @@ psindex(psstack *st, int n) } static void -psrun(psobj *code, psstack *st, int pc) +ps_run(psobj *code, ps_stack *st, int pc) { int i1, i2; float r1, r2; @@ -307,357 +307,357 @@ psrun(psobj *code, psstack *st, int pc) { switch (code[pc].type) { - case PSINT: - pspushint(st, code[pc++].u.i); + case PS_INT: + ps_push_int(st, code[pc++].u.i); break; - case PSREAL: - pspushreal(st, code[pc++].u.f); + case PS_REAL: + ps_push_real(st, code[pc++].u.f); break; - case PSOPERATOR: + case PS_OPERATOR: switch (code[pc++].u.op) { - case PSOABS: - if (psistype(st, PSINT)) - pspushint(st, abs(pspopint(st))); + case PS_OP_ABS: + if (ps_is_type(st, PS_INT)) + ps_push_int(st, abs(ps_pop_int(st))); else - pspushreal(st, fabsf(pspopreal(st))); + ps_push_real(st, fabsf(ps_pop_real(st))); break; - case PSOADD: - if (psistype2(st, PSINT)) { - i2 = pspopint(st); - i1 = pspopint(st); - pspushint(st, i1 + i2); + case PS_OP_ADD: + if (ps_is_type2(st, PS_INT)) { + i2 = ps_pop_int(st); + i1 = ps_pop_int(st); + ps_push_int(st, i1 + i2); } else { - r2 = pspopreal(st); - r1 = pspopreal(st); - pspushreal(st, r1 + r2); + r2 = ps_pop_real(st); + r1 = ps_pop_real(st); + ps_push_real(st, r1 + r2); } break; - case PSOAND: - if (psistype2(st, PSINT)) { - i2 = pspopint(st); - i1 = pspopint(st); - pspushint(st, i1 & i2); + case PS_OP_AND: + if (ps_is_type2(st, PS_INT)) { + i2 = ps_pop_int(st); + i1 = ps_pop_int(st); + ps_push_int(st, i1 & i2); } else { - b2 = pspopbool(st); - b1 = pspopbool(st); - pspushbool(st, b1 && b2); + b2 = ps_pop_bool(st); + b1 = ps_pop_bool(st); + ps_push_bool(st, b1 && b2); } break; - case PSOATAN: - r2 = pspopreal(st); - r1 = pspopreal(st); + case PS_OP_ATAN: + r2 = ps_pop_real(st); + r1 = ps_pop_real(st); r1 = atan2f(r1, r2) * RADIAN; if (r1 < 0) r1 += 360; - pspushreal(st, r1); + ps_push_real(st, r1); break; - case PSOBITSHIFT: - i2 = pspopint(st); - i1 = pspopint(st); + case PS_OP_BITSHIFT: + i2 = ps_pop_int(st); + i1 = ps_pop_int(st); if (i2 > 0) - pspushint(st, i1 << i2); + ps_push_int(st, i1 << i2); else if (i2 < 0) - pspushint(st, (int)((unsigned int)i1 >> i2)); + ps_push_int(st, (int)((unsigned int)i1 >> i2)); else - pspushint(st, i1); + ps_push_int(st, i1); break; - case PSOCEILING: - r1 = pspopreal(st); - pspushreal(st, ceilf(r1)); + case PS_OP_CEILING: + r1 = ps_pop_real(st); + ps_push_real(st, ceilf(r1)); break; - case PSOCOPY: - pscopy(st, pspopint(st)); + case PS_OP_COPY: + ps_copy(st, ps_pop_int(st)); break; - case PSOCOS: - r1 = pspopreal(st); - pspushreal(st, cosf(r1/RADIAN)); + case PS_OP_COS: + r1 = ps_pop_real(st); + ps_push_real(st, cosf(r1/RADIAN)); break; - case PSOCVI: - pspushint(st, pspopint(st)); + case PS_OP_CVI: + ps_push_int(st, ps_pop_int(st)); break; - case PSOCVR: - pspushreal(st, pspopreal(st)); + case PS_OP_CVR: + ps_push_real(st, ps_pop_real(st)); break; - case PSODIV: - r2 = pspopreal(st); - r1 = pspopreal(st); - pspushreal(st, r1 / r2); + case PS_OP_DIV: + r2 = ps_pop_real(st); + r1 = ps_pop_real(st); + ps_push_real(st, r1 / r2); break; - case PSODUP: - pscopy(st, 1); + case PS_OP_DUP: + ps_copy(st, 1); break; - case PSOEQ: - if (psistype2(st, PSBOOL)) { - b2 = pspopbool(st); - b1 = pspopbool(st); - pspushbool(st, b1 == b2); + case PS_OP_EQ: + if (ps_is_type2(st, PS_BOOL)) { + b2 = ps_pop_bool(st); + b1 = ps_pop_bool(st); + ps_push_bool(st, b1 == b2); } - else if (psistype2(st, PSINT)) { - i2 = pspopint(st); - i1 = pspopint(st); - pspushbool(st, i1 == i2); + else if (ps_is_type2(st, PS_INT)) { + i2 = ps_pop_int(st); + i1 = ps_pop_int(st); + ps_push_bool(st, i1 == i2); } else { - r2 = pspopreal(st); - r1 = pspopreal(st); - pspushbool(st, r1 == r2); + r2 = ps_pop_real(st); + r1 = ps_pop_real(st); + ps_push_bool(st, r1 == r2); } break; - case PSOEXCH: - psroll(st, 2, 1); + case PS_OP_EXCH: + ps_roll(st, 2, 1); break; - case PSOEXP: - r2 = pspopreal(st); - r1 = pspopreal(st); - pspushreal(st, powf(r1, r2)); + case PS_OP_EXP: + r2 = ps_pop_real(st); + r1 = ps_pop_real(st); + ps_push_real(st, powf(r1, r2)); break; - case PSOFALSE: - pspushbool(st, 0); + case PS_OP_FALSE: + ps_push_bool(st, 0); break; - case PSOFLOOR: - r1 = pspopreal(st); - pspushreal(st, floorf(r1)); + case PS_OP_FLOOR: + r1 = ps_pop_real(st); + ps_push_real(st, floorf(r1)); break; - case PSOGE: - if (psistype2(st, PSINT)) { - i2 = pspopint(st); - i1 = pspopint(st); - pspushbool(st, i1 >= i2); + case PS_OP_GE: + if (ps_is_type2(st, PS_INT)) { + i2 = ps_pop_int(st); + i1 = ps_pop_int(st); + ps_push_bool(st, i1 >= i2); } else { - r2 = pspopreal(st); - r1 = pspopreal(st); - pspushbool(st, r1 >= r2); + r2 = ps_pop_real(st); + r1 = ps_pop_real(st); + ps_push_bool(st, r1 >= r2); } break; - case PSOGT: - if (psistype2(st, PSINT)) { - i2 = pspopint(st); - i1 = pspopint(st); - pspushbool(st, i1 > i2); + case PS_OP_GT: + if (ps_is_type2(st, PS_INT)) { + i2 = ps_pop_int(st); + i1 = ps_pop_int(st); + ps_push_bool(st, i1 > i2); } else { - r2 = pspopreal(st); - r1 = pspopreal(st); - pspushbool(st, r1 > r2); + r2 = ps_pop_real(st); + r1 = ps_pop_real(st); + ps_push_bool(st, r1 > r2); } break; - case PSOIDIV: - i2 = pspopint(st); - i1 = pspopint(st); - pspushint(st, i1 / i2); + case PS_OP_IDIV: + i2 = ps_pop_int(st); + i1 = ps_pop_int(st); + ps_push_int(st, i1 / i2); break; - case PSOINDEX: - psindex(st, pspopint(st)); + case PS_OP_INDEX: + ps_index(st, ps_pop_int(st)); break; - case PSOLE: - if (psistype2(st, PSINT)) { - i2 = pspopint(st); - i1 = pspopint(st); - pspushbool(st, i1 <= i2); + case PS_OP_LE: + if (ps_is_type2(st, PS_INT)) { + i2 = ps_pop_int(st); + i1 = ps_pop_int(st); + ps_push_bool(st, i1 <= i2); } else { - r2 = pspopreal(st); - r1 = pspopreal(st); - pspushbool(st, r1 <= r2); + r2 = ps_pop_real(st); + r1 = ps_pop_real(st); + ps_push_bool(st, r1 <= r2); } break; - case PSOLN: - r1 = pspopreal(st); - pspushreal(st, logf(r1)); + case PS_OP_LN: + r1 = ps_pop_real(st); + ps_push_real(st, logf(r1)); break; - case PSOLOG: - r1 = pspopreal(st); - pspushreal(st, log10f(r1)); + case PS_OP_LOG: + r1 = ps_pop_real(st); + ps_push_real(st, log10f(r1)); break; - case PSOLT: - if (psistype2(st, PSINT)) { - i2 = pspopint(st); - i1 = pspopint(st); - pspushbool(st, i1 < i2); + case PS_OP_LT: + if (ps_is_type2(st, PS_INT)) { + i2 = ps_pop_int(st); + i1 = ps_pop_int(st); + ps_push_bool(st, i1 < i2); } else { - r2 = pspopreal(st); - r1 = pspopreal(st); - pspushbool(st, r1 < r2); + r2 = ps_pop_real(st); + r1 = ps_pop_real(st); + ps_push_bool(st, r1 < r2); } break; - case PSOMOD: - i2 = pspopint(st); - i1 = pspopint(st); - pspushint(st, i1 % i2); + case PS_OP_MOD: + i2 = ps_pop_int(st); + i1 = ps_pop_int(st); + ps_push_int(st, i1 % i2); break; - case PSOMUL: - if (psistype2(st, PSINT)) { - i2 = pspopint(st); - i1 = pspopint(st); - pspushint(st, i1 * i2); + case PS_OP_MUL: + if (ps_is_type2(st, PS_INT)) { + i2 = ps_pop_int(st); + i1 = ps_pop_int(st); + ps_push_int(st, i1 * i2); } else { - r2 = pspopreal(st); - r1 = pspopreal(st); - pspushreal(st, r1 * r2); + r2 = ps_pop_real(st); + r1 = ps_pop_real(st); + ps_push_real(st, r1 * r2); } break; - case PSONE: - if (psistype2(st, PSBOOL)) { - b2 = pspopbool(st); - b1 = pspopbool(st); - pspushbool(st, b1 != b2); + case PS_OP_NE: + if (ps_is_type2(st, PS_BOOL)) { + b2 = ps_pop_bool(st); + b1 = ps_pop_bool(st); + ps_push_bool(st, b1 != b2); } - else if (psistype2(st, PSINT)) { - i2 = pspopint(st); - i1 = pspopint(st); - pspushbool(st, i1 != i2); + else if (ps_is_type2(st, PS_INT)) { + i2 = ps_pop_int(st); + i1 = ps_pop_int(st); + ps_push_bool(st, i1 != i2); } else { - r2 = pspopreal(st); - r1 = pspopreal(st); - pspushbool(st, r1 != r2); + r2 = ps_pop_real(st); + r1 = ps_pop_real(st); + ps_push_bool(st, r1 != r2); } break; - case PSONEG: - if (psistype(st, PSINT)) - pspushint(st, -pspopint(st)); + case PS_OP_NEG: + if (ps_is_type(st, PS_INT)) + ps_push_int(st, -ps_pop_int(st)); else - pspushreal(st, -pspopreal(st)); + ps_push_real(st, -ps_pop_real(st)); break; - case PSONOT: - if (psistype(st, PSBOOL)) - pspushbool(st, !pspopbool(st)); + case PS_OP_NOT: + if (ps_is_type(st, PS_BOOL)) + ps_push_bool(st, !ps_pop_bool(st)); else - pspushint(st, ~pspopint(st)); + ps_push_int(st, ~ps_pop_int(st)); break; - case PSOOR: - if (psistype2(st, PSBOOL)) { - b2 = pspopbool(st); - b1 = pspopbool(st); - pspushbool(st, b1 || b2); + case PS_OP_OR: + if (ps_is_type2(st, PS_BOOL)) { + b2 = ps_pop_bool(st); + b1 = ps_pop_bool(st); + ps_push_bool(st, b1 || b2); } else { - i2 = pspopint(st); - i1 = pspopint(st); - pspushint(st, i1 | i2); + i2 = ps_pop_int(st); + i1 = ps_pop_int(st); + ps_push_int(st, i1 | i2); } break; - case PSOPOP: - if (!psunderflow(st, 1)) + case PS_OP_POP: + if (!ps_underflow(st, 1)) st->sp--; break; - case PSOROLL: - i2 = pspopint(st); - i1 = pspopint(st); - psroll(st, i1, i2); + case PS_OP_ROLL: + i2 = ps_pop_int(st); + i1 = ps_pop_int(st); + ps_roll(st, i1, i2); break; - case PSOROUND: - if (!psistype(st, PSINT)) { - r1 = pspopreal(st); - pspushreal(st, (r1 >= 0) ? floorf(r1 + 0.5f) : ceilf(r1 - 0.5f)); + case PS_OP_ROUND: + if (!ps_is_type(st, PS_INT)) { + r1 = ps_pop_real(st); + ps_push_real(st, (r1 >= 0) ? floorf(r1 + 0.5f) : ceilf(r1 - 0.5f)); } break; - case PSOSIN: - r1 = pspopreal(st); - pspushreal(st, sinf(r1/RADIAN)); + case PS_OP_SIN: + r1 = ps_pop_real(st); + ps_push_real(st, sinf(r1/RADIAN)); break; - case PSOSQRT: - r1 = pspopreal(st); - pspushreal(st, sqrtf(r1)); + case PS_OP_SQRT: + r1 = ps_pop_real(st); + ps_push_real(st, sqrtf(r1)); break; - case PSOSUB: - if (psistype2(st, PSINT)) { - i2 = pspopint(st); - i1 = pspopint(st); - pspushint(st, i1 - i2); + case PS_OP_SUB: + if (ps_is_type2(st, PS_INT)) { + i2 = ps_pop_int(st); + i1 = ps_pop_int(st); + ps_push_int(st, i1 - i2); } else { - r2 = pspopreal(st); - r1 = pspopreal(st); - pspushreal(st, r1 - r2); + r2 = ps_pop_real(st); + r1 = ps_pop_real(st); + ps_push_real(st, r1 - r2); } break; - case PSOTRUE: - pspushbool(st, 1); + case PS_OP_TRUE: + ps_push_bool(st, 1); break; - case PSOTRUNCATE: - if (!psistype(st, PSINT)) { - r1 = pspopreal(st); - pspushreal(st, (r1 >= 0) ? floorf(r1) : ceilf(r1)); + case PS_OP_TRUNCATE: + if (!ps_is_type(st, PS_INT)) { + r1 = ps_pop_real(st); + ps_push_real(st, (r1 >= 0) ? floorf(r1) : ceilf(r1)); } break; - case PSOXOR: - if (psistype2(st, PSBOOL)) { - b2 = pspopbool(st); - b1 = pspopbool(st); - pspushbool(st, b1 ^ b2); + case PS_OP_XOR: + if (ps_is_type2(st, PS_BOOL)) { + b2 = ps_pop_bool(st); + b1 = ps_pop_bool(st); + ps_push_bool(st, b1 ^ b2); } else { - i2 = pspopint(st); - i1 = pspopint(st); - pspushint(st, i1 ^ i2); + i2 = ps_pop_int(st); + i1 = ps_pop_int(st); + ps_push_int(st, i1 ^ i2); } break; - case PSOIF: - b1 = pspopbool(st); + case PS_OP_IF: + b1 = ps_pop_bool(st); if (b1) - psrun(code, st, code[pc + 1].u.block); + ps_run(code, st, code[pc + 1].u.block); pc = code[pc + 2].u.block; break; - case PSOIFELSE: - b1 = pspopbool(st); + case PS_OP_IFELSE: + b1 = ps_pop_bool(st); if (b1) - psrun(code, st, code[pc + 1].u.block); + ps_run(code, st, code[pc + 1].u.block); else - psrun(code, st, code[pc + 0].u.block); + ps_run(code, st, code[pc + 0].u.block); pc = code[pc + 2].u.block; break; - case PSORETURN: + case PS_OP_RETURN: return; default: @@ -674,7 +674,7 @@ psrun(psobj *code, psstack *st, int pc) } static void -resizecode(pdf_function *func, int newsize) +resize_code(pdf_function *func, int newsize) { if (newsize >= func->u.p.cap) { @@ -684,7 +684,7 @@ resizecode(pdf_function *func, int newsize) } static fz_error -parsecode(pdf_function *func, fz_stream *stream, int *codeptr) +parse_code(pdf_function *func, fz_stream *stream, int *codeptr) { fz_error error; char buf[64]; @@ -703,31 +703,31 @@ parsecode(pdf_function *func, fz_stream *stream, int *codeptr) switch(tok) { - case PDF_TEOF: + case PDF_TOK_EOF: return fz_throw("truncated calculator function"); - case PDF_TINT: - resizecode(func, *codeptr); - func->u.p.code[*codeptr].type = PSINT; + case PDF_TOK_INT: + resize_code(func, *codeptr); + func->u.p.code[*codeptr].type = PS_INT; func->u.p.code[*codeptr].u.i = atoi(buf); ++*codeptr; break; - case PDF_TREAL: - resizecode(func, *codeptr); - func->u.p.code[*codeptr].type = PSREAL; + case PDF_TOK_REAL: + resize_code(func, *codeptr); + func->u.p.code[*codeptr].type = PS_REAL; func->u.p.code[*codeptr].u.f = atof(buf); ++*codeptr; break; - case PDF_TOBRACE: + case PDF_TOK_OPEN_BRACE: opptr = *codeptr; *codeptr += 4; - resizecode(func, *codeptr); + resize_code(func, *codeptr); ifptr = *codeptr; - error = parsecode(func, stream, codeptr); + error = parse_code(func, stream, codeptr); if (error) return fz_rethrow(error, "error in 'if' branch"); @@ -735,10 +735,10 @@ parsecode(pdf_function *func, fz_stream *stream, int *codeptr) if (error) return fz_rethrow(error, "calculator function syntax error"); - if (tok == PDF_TOBRACE) + if (tok == PDF_TOK_OPEN_BRACE) { elseptr = *codeptr; - error = parsecode(func, stream, codeptr); + error = parse_code(func, stream, codeptr); if (error) return fz_rethrow(error, "error in 'else' branch"); @@ -751,30 +751,30 @@ parsecode(pdf_function *func, fz_stream *stream, int *codeptr) elseptr = -1; } - if (tok == PDF_TKEYWORD) + if (tok == PDF_TOK_KEYWORD) { if (!strcmp(buf, "if")) { if (elseptr >= 0) return fz_throw("too many branches for 'if'"); - func->u.p.code[opptr].type = PSOPERATOR; - func->u.p.code[opptr].u.op = PSOIF; - func->u.p.code[opptr+2].type = PSBLOCK; + func->u.p.code[opptr].type = PS_OPERATOR; + func->u.p.code[opptr].u.op = PS_OP_IF; + func->u.p.code[opptr+2].type = PS_BLOCK; func->u.p.code[opptr+2].u.block = ifptr; - func->u.p.code[opptr+3].type = PSBLOCK; + func->u.p.code[opptr+3].type = PS_BLOCK; func->u.p.code[opptr+3].u.block = *codeptr; } else if (!strcmp(buf, "ifelse")) { if (elseptr < 0) return fz_throw("not enough branches for 'ifelse'"); - func->u.p.code[opptr].type = PSOPERATOR; - func->u.p.code[opptr].u.op = PSOIFELSE; - func->u.p.code[opptr+1].type = PSBLOCK; + func->u.p.code[opptr].type = PS_OPERATOR; + func->u.p.code[opptr].u.op = PS_OP_IFELSE; + func->u.p.code[opptr+1].type = PS_BLOCK; func->u.p.code[opptr+1].u.block = elseptr; - func->u.p.code[opptr+2].type = PSBLOCK; + func->u.p.code[opptr+2].type = PS_BLOCK; func->u.p.code[opptr+2].u.block = ifptr; - func->u.p.code[opptr+3].type = PSBLOCK; + func->u.p.code[opptr+3].type = PS_BLOCK; func->u.p.code[opptr+3].u.block = *codeptr; } else @@ -788,21 +788,21 @@ parsecode(pdf_function *func, fz_stream *stream, int *codeptr) } break; - case PDF_TCBRACE: - resizecode(func, *codeptr); - func->u.p.code[*codeptr].type = PSOPERATOR; - func->u.p.code[*codeptr].u.op = PSORETURN; + case PDF_TOK_CLOSE_BRACE: + resize_code(func, *codeptr); + func->u.p.code[*codeptr].type = PS_OPERATOR; + func->u.p.code[*codeptr].u.op = PS_OP_RETURN; ++*codeptr; return fz_okay; - case PDF_TKEYWORD: + case PDF_TOK_KEYWORD: cmp = -1; a = -1; - b = nelem(psopnames); + b = nelem(ps_op_names); while (b - a > 1) { mid = (a + b) / 2; - cmp = strcmp(buf, psopnames[mid]); + cmp = strcmp(buf, ps_op_names[mid]); if (cmp > 0) a = mid; else if (cmp < 0) @@ -813,8 +813,8 @@ parsecode(pdf_function *func, fz_stream *stream, int *codeptr) if (cmp != 0) return fz_throw("unknown operator: '%s'", buf); - resizecode(func, *codeptr); - func->u.p.code[*codeptr].type = PSOPERATOR; + resize_code(func, *codeptr); + func->u.p.code[*codeptr].type = PS_OPERATOR; func->u.p.code[*codeptr].u.op = a; ++*codeptr; break; @@ -826,7 +826,7 @@ parsecode(pdf_function *func, fz_stream *stream, int *codeptr) } static fz_error -loadpostscriptfunc(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, int gen) +load_postscript_func(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, int gen) { fz_error error; fz_stream *stream; @@ -835,9 +835,9 @@ loadpostscriptfunc(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, in int tok; int len; - pdf_logrsrc("load postscript function (%d %d R)\n", num, gen); + pdf_log_rsrc("load postscript function (%d %d R)\n", num, gen); - error = pdf_openstream(&stream, xref, num, gen); + error = pdf_open_stream(&stream, xref, num, gen); if (error) return fz_rethrow(error, "cannot open calculator function stream"); @@ -848,17 +848,17 @@ loadpostscriptfunc(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, in return fz_rethrow(error, "stream is not a calculator function"); } - if (tok != PDF_TOBRACE) + if (tok != PDF_TOK_OPEN_BRACE) { fz_close(stream); return fz_throw("stream is not a calculator function"); } - func->u.p.code = nil; + func->u.p.code = NULL; func->u.p.cap = 0; codeptr = 0; - error = parsecode(func, stream, &codeptr); + error = parse_code(func, stream, &codeptr); if (error) { fz_close(stream); @@ -870,25 +870,25 @@ loadpostscriptfunc(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, in } static void -evalpostscriptfunc(pdf_function *func, float *in, float *out) +eval_postscript_func(pdf_function *func, float *in, float *out) { - psstack st; + ps_stack st; float x; int i; - psinitstack(&st); + ps_init_stack(&st); for (i = 0; i < func->m; i++) { x = CLAMP(in[i], func->domain[i][0], func->domain[i][1]); - pspushreal(&st, x); + ps_push_real(&st, x); } - psrun(func->u.p.code, &st, 0); + ps_run(func->u.p.code, &st, 0); for (i = func->n - 1; i >= 0; i--) { - x = pspopreal(&st); + x = ps_pop_real(&st); out[i] = CLAMP(x, func->range[i][0], func->range[i][1]); } } @@ -898,7 +898,7 @@ evalpostscriptfunc(pdf_function *func, float *in, float *out) */ static fz_error -loadsamplefunc(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, int gen) +load_sample_func(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, int gen) { fz_error error; fz_stream *stream; @@ -907,32 +907,32 @@ loadsamplefunc(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, int ge int bps; int i; - pdf_logrsrc("sampled function {\n"); + pdf_log_rsrc("sampled function {\n"); - func->u.sa.samples = nil; + func->u.sa.samples = NULL; - obj = fz_dictgets(dict, "Size"); - if (!fz_isarray(obj) || fz_arraylen(obj) != func->m) + obj = fz_dict_gets(dict, "Size"); + if (!fz_is_array(obj) || fz_array_len(obj) != func->m) return fz_throw("malformed /Size"); for (i = 0; i < func->m; i++) - func->u.sa.size[i] = fz_toint(fz_arrayget(obj, i)); + func->u.sa.size[i] = fz_to_int(fz_array_get(obj, i)); - obj = fz_dictgets(dict, "BitsPerSample"); - if (!fz_isint(obj)) + obj = fz_dict_gets(dict, "BitsPerSample"); + if (!fz_is_int(obj)) return fz_throw("malformed /BitsPerSample"); - func->u.sa.bps = bps = fz_toint(obj); + func->u.sa.bps = bps = fz_to_int(obj); - pdf_logrsrc("bps %d\n", bps); + pdf_log_rsrc("bps %d\n", bps); - obj = fz_dictgets(dict, "Encode"); - if (fz_isarray(obj)) + obj = fz_dict_gets(dict, "Encode"); + if (fz_is_array(obj)) { - if (fz_arraylen(obj) != func->m * 2) + if (fz_array_len(obj) != func->m * 2) return fz_throw("malformed /Encode"); for (i = 0; i < func->m; i++) { - func->u.sa.encode[i][0] = fz_toreal(fz_arrayget(obj, i*2+0)); - func->u.sa.encode[i][1] = fz_toreal(fz_arrayget(obj, i*2+1)); + func->u.sa.encode[i][0] = fz_to_real(fz_array_get(obj, i*2+0)); + func->u.sa.encode[i][1] = fz_to_real(fz_array_get(obj, i*2+1)); } } else @@ -944,15 +944,15 @@ loadsamplefunc(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, int ge } } - obj = fz_dictgets(dict, "Decode"); - if (fz_isarray(obj)) + obj = fz_dict_gets(dict, "Decode"); + if (fz_is_array(obj)) { - if (fz_arraylen(obj) != func->n * 2) + if (fz_array_len(obj) != func->n * 2) return fz_throw("malformed /Decode"); for (i = 0; i < func->n; i++) { - func->u.sa.decode[i][0] = fz_toreal(fz_arrayget(obj, i*2+0)); - func->u.sa.decode[i][1] = fz_toreal(fz_arrayget(obj, i*2+1)); + func->u.sa.decode[i][0] = fz_to_real(fz_array_get(obj, i*2+0)); + func->u.sa.decode[i][1] = fz_to_real(fz_array_get(obj, i*2+1)); } } else @@ -967,11 +967,11 @@ loadsamplefunc(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, int ge for (i = 0, samplecount = func->n; i < func->m; i++) samplecount *= func->u.sa.size[i]; - pdf_logrsrc("samplecount %d\n", samplecount); + pdf_log_rsrc("samplecount %d\n", samplecount); func->u.sa.samples = fz_calloc(samplecount, sizeof(float)); - error = pdf_openstream(&stream, xref, num, gen); + error = pdf_open_stream(&stream, xref, num, gen); if (error) return fz_rethrow(error, "cannot open samples stream (%d %d R)", num, gen); @@ -981,7 +981,7 @@ loadsamplefunc(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, int ge unsigned int x; float s; - if (fz_iseofbits(stream)) + if (fz_is_eof_bits(stream)) { fz_close(stream); return fz_throw("truncated sample stream"); @@ -989,27 +989,27 @@ loadsamplefunc(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, int ge switch (bps) { - case 1: s = fz_readbits(stream, 1); break; - case 2: s = fz_readbits(stream, 2) / 3.0f; break; - case 4: s = fz_readbits(stream, 4) / 15.0f; break; - case 8: s = fz_readbyte(stream) / 255.0f; break; - case 12: s = fz_readbits(stream, 12) / 4095.0f; break; + case 1: s = fz_read_bits(stream, 1); break; + case 2: s = fz_read_bits(stream, 2) / 3.0f; break; + case 4: s = fz_read_bits(stream, 4) / 15.0f; break; + case 8: s = fz_read_byte(stream) / 255.0f; break; + case 12: s = fz_read_bits(stream, 12) / 4095.0f; break; case 16: - x = fz_readbyte(stream) << 8; - x |= fz_readbyte(stream); + x = fz_read_byte(stream) << 8; + x |= fz_read_byte(stream); s = x / 65535.0f; break; case 24: - x = fz_readbyte(stream) << 16; - x |= fz_readbyte(stream) << 8; - x |= fz_readbyte(stream); + x = fz_read_byte(stream) << 16; + x |= fz_read_byte(stream) << 8; + x |= fz_read_byte(stream); s = x / 16777215.0f; break; case 32: - x = fz_readbyte(stream) << 24; - x |= fz_readbyte(stream) << 16; - x |= fz_readbyte(stream) << 8; - x |= fz_readbyte(stream); + x = fz_read_byte(stream) << 24; + x |= fz_read_byte(stream) << 16; + x |= fz_read_byte(stream) << 8; + x |= fz_read_byte(stream); s = x / 4294967295.0f; break; default: @@ -1022,13 +1022,13 @@ loadsamplefunc(pdf_function *func, pdf_xref *xref, fz_obj *dict, int num, int ge fz_close(stream); - pdf_logrsrc("}\n"); + pdf_log_rsrc("}\n"); return fz_okay; } static float -interpolatesample(pdf_function *func, int *scale, int *e0, int *e1, float *efrac, int dim, int idx) +interpolate_sample(pdf_function *func, int *scale, int *e0, int *e1, float *efrac, int dim, int idx) { float a, b; int idx0, idx1; @@ -1043,15 +1043,15 @@ interpolatesample(pdf_function *func, int *scale, int *e0, int *e1, float *efrac } else { - a = interpolatesample(func, scale, e0, e1, efrac, dim - 1, idx0); - b = interpolatesample(func, scale, e0, e1, efrac, dim - 1, idx1); + a = interpolate_sample(func, scale, e0, e1, efrac, dim - 1, idx0); + b = interpolate_sample(func, scale, e0, e1, efrac, dim - 1, idx1); } return a + (b - a) * efrac[dim]; } static void -evalsamplefunc(pdf_function *func, float *in, float *out) +eval_sample_func(pdf_function *func, float *in, float *out) { int e0[MAXM], e1[MAXM], scale[MAXM]; float efrac[MAXM]; @@ -1107,7 +1107,7 @@ evalsamplefunc(pdf_function *func, float *in, float *out) else { - float x = interpolatesample(func, scale, e0, e1, efrac, func->m - 1, i); + float x = interpolate_sample(func, scale, e0, e1, efrac, func->m - 1, i); out[i] = LERP(x, 0, 1, func->u.sa.decode[i][0], func->u.sa.decode[i][1]); out[i] = CLAMP(out[i], func->range[i][0], func->range[i][1]); } @@ -1119,31 +1119,31 @@ evalsamplefunc(pdf_function *func, float *in, float *out) */ static fz_error -loadexponentialfunc(pdf_function *func, fz_obj *dict) +load_exponential_func(pdf_function *func, fz_obj *dict) { fz_obj *obj; int i; - pdf_logrsrc("exponential function {\n"); + pdf_log_rsrc("exponential function {\n"); if (func->m != 1) return fz_throw("/Domain must be one dimension (%d)", func->m); - obj = fz_dictgets(dict, "N"); - if (!fz_isint(obj) && !fz_isreal(obj)) + obj = fz_dict_gets(dict, "N"); + if (!fz_is_int(obj) && !fz_is_real(obj)) return fz_throw("malformed /N"); - func->u.e.n = fz_toreal(obj); - pdf_logrsrc("n %g\n", func->u.e.n); + func->u.e.n = fz_to_real(obj); + pdf_log_rsrc("n %g\n", func->u.e.n); - obj = fz_dictgets(dict, "C0"); - if (fz_isarray(obj)) + obj = fz_dict_gets(dict, "C0"); + if (fz_is_array(obj)) { - func->n = fz_arraylen(obj); + func->n = fz_array_len(obj); if (func->n >= MAXN) return fz_throw("exponential function result array out of range"); for (i = 0; i < func->n; i++) - func->u.e.c0[i] = fz_toreal(fz_arrayget(obj, i)); - pdf_logrsrc("c0 %d\n", func->n); + func->u.e.c0[i] = fz_to_real(fz_array_get(obj, i)); + pdf_log_rsrc("c0 %d\n", func->n); } else { @@ -1151,14 +1151,14 @@ loadexponentialfunc(pdf_function *func, fz_obj *dict) func->u.e.c0[0] = 0; } - obj = fz_dictgets(dict, "C1"); - if (fz_isarray(obj)) + obj = fz_dict_gets(dict, "C1"); + if (fz_is_array(obj)) { - if (fz_arraylen(obj) != func->n) + if (fz_array_len(obj) != func->n) return fz_throw("/C1 must match /C0 length"); for (i = 0; i < func->n; i++) - func->u.e.c1[i] = fz_toreal(fz_arrayget(obj, i)); - pdf_logrsrc("c1 %d\n", func->n); + func->u.e.c1[i] = fz_to_real(fz_array_get(obj, i)); + pdf_log_rsrc("c1 %d\n", func->n); } else { @@ -1167,13 +1167,13 @@ loadexponentialfunc(pdf_function *func, fz_obj *dict) func->u.e.c1[0] = 1; } - pdf_logrsrc("}\n"); + pdf_log_rsrc("}\n"); return fz_okay; } static void -evalexponentialfunc(pdf_function *func, float in, float *out) +eval_exponential_func(pdf_function *func, float in, float *out) { float x = in; float tmp; @@ -1192,7 +1192,7 @@ evalexponentialfunc(pdf_function *func, float in, float *out) for (i = 0; i < func->n; i++) { out[i] = func->u.e.c0[i] + tmp * (func->u.e.c1[i] - func->u.e.c0[i]); - if (func->hasrange) + if (func->has_range) out[i] = CLAMP(out[i], func->range[i][0], func->range[i][1]); } } @@ -1202,7 +1202,7 @@ evalexponentialfunc(pdf_function *func, float in, float *out) */ static fz_error -loadstitchingfunc(pdf_function *func, pdf_xref *xref, fz_obj *dict) +load_stitching_func(pdf_function *func, pdf_xref *xref, fz_obj *dict) { pdf_function **funcs; fz_error error; @@ -1212,20 +1212,20 @@ loadstitchingfunc(pdf_function *func, pdf_xref *xref, fz_obj *dict) int k; int i; - pdf_logrsrc("stitching {\n"); + pdf_log_rsrc("stitching {\n"); func->u.st.k = 0; if (func->m != 1) return fz_throw("/Domain must be one dimension (%d)", func->m); - obj = fz_dictgets(dict, "Functions"); - if (!fz_isarray(obj)) + obj = fz_dict_gets(dict, "Functions"); + if (!fz_is_array(obj)) return fz_throw("stitching function has no input functions"); { - k = fz_arraylen(obj); + k = fz_array_len(obj); - pdf_logrsrc("k %d\n", k); + pdf_log_rsrc("k %d\n", k); func->u.st.funcs = fz_calloc(k, sizeof(pdf_function*)); func->u.st.bounds = fz_calloc(k - 1, sizeof(float)); @@ -1234,10 +1234,10 @@ loadstitchingfunc(pdf_function *func, pdf_xref *xref, fz_obj *dict) for (i = 0; i < k; i++) { - sub = fz_arrayget(obj, i); - error = pdf_loadfunction(&funcs[i], xref, sub); + sub = fz_array_get(obj, i); + error = pdf_load_function(&funcs[i], xref, sub); if (error) - return fz_rethrow(error, "cannot load sub function %d (%d %d R)", i, fz_tonum(sub), fz_togen(sub)); + return fz_rethrow(error, "cannot load sub function %d (%d %d R)", i, fz_to_num(sub), fz_to_gen(sub)); if (funcs[i]->m != 1 || funcs[i]->n != funcs[0]->n) return fz_throw("sub function %d /Domain or /Range mismatch", i); func->u.st.k ++; @@ -1249,19 +1249,19 @@ loadstitchingfunc(pdf_function *func, pdf_xref *xref, fz_obj *dict) return fz_throw("sub function /Domain or /Range mismatch"); } - obj = fz_dictgets(dict, "Bounds"); - if (!fz_isarray(obj)) + obj = fz_dict_gets(dict, "Bounds"); + if (!fz_is_array(obj)) return fz_throw("stitching function has no bounds"); { - if (!fz_isarray(obj) || fz_arraylen(obj) != k - 1) + if (!fz_is_array(obj) || fz_array_len(obj) != k - 1) return fz_throw("malformed /Bounds (not array or wrong length)"); for (i = 0; i < k-1; i++) { - num = fz_arrayget(obj, i); - if (!fz_isint(num) && !fz_isreal(num)) + num = fz_array_get(obj, i); + if (!fz_is_int(num) && !fz_is_real(num)) return fz_throw("malformed /Bounds (item not real)"); - func->u.st.bounds[i] = fz_toreal(num); + func->u.st.bounds[i] = fz_to_real(num); if (i && func->u.st.bounds[i-1] > func->u.st.bounds[i]) return fz_throw("malformed /Bounds (item not monotonic)"); } @@ -1271,26 +1271,26 @@ loadstitchingfunc(pdf_function *func, pdf_xref *xref, fz_obj *dict) fz_warn("malformed shading function bounds (domain mismatch), proceeding anyway."); } - obj = fz_dictgets(dict, "Encode"); - if (!fz_isarray(obj)) + obj = fz_dict_gets(dict, "Encode"); + if (!fz_is_array(obj)) return fz_throw("stitching function is missing encoding"); { - if (!fz_isarray(obj) || fz_arraylen(obj) != k * 2) + if (!fz_is_array(obj) || fz_array_len(obj) != k * 2) return fz_throw("malformed /Encode"); for (i = 0; i < k; i++) { - func->u.st.encode[i*2+0] = fz_toreal(fz_arrayget(obj, i*2+0)); - func->u.st.encode[i*2+1] = fz_toreal(fz_arrayget(obj, i*2+1)); + func->u.st.encode[i*2+0] = fz_to_real(fz_array_get(obj, i*2+0)); + func->u.st.encode[i*2+1] = fz_to_real(fz_array_get(obj, i*2+1)); } } - pdf_logrsrc("}\n"); + pdf_log_rsrc("}\n"); return fz_okay; } static void -evalstitchingfunc(pdf_function *func, float in, float *out) +eval_stitching_func(pdf_function *func, float in, float *out) { float low, high; int k = func->u.st.k; @@ -1328,7 +1328,7 @@ evalstitchingfunc(pdf_function *func, float in, float *out) in = LERP(in, low, high, func->u.st.encode[i*2+0], func->u.st.encode[i*2+1]); - pdf_evalfunction(func->u.st.funcs[i], &in, 1, out, func->n); + pdf_eval_function(func->u.st.funcs[i], &in, 1, out, func->n); } /* @@ -1336,14 +1336,14 @@ evalstitchingfunc(pdf_function *func, float in, float *out) */ pdf_function * -pdf_keepfunction(pdf_function *func) +pdf_keep_function(pdf_function *func) { func->refs ++; return func; } void -pdf_dropfunction(pdf_function *func) +pdf_drop_function(pdf_function *func) { int i; if (--func->refs == 0) @@ -1357,7 +1357,7 @@ pdf_dropfunction(pdf_function *func) break; case STITCHING: for (i = 0; i < func->u.st.k; i++) - pdf_dropfunction(func->u.st.funcs[i]); + pdf_drop_function(func->u.st.funcs[i]); fz_free(func->u.st.funcs); fz_free(func->u.st.bounds); fz_free(func->u.st.encode); @@ -1371,56 +1371,56 @@ pdf_dropfunction(pdf_function *func) } fz_error -pdf_loadfunction(pdf_function **funcp, pdf_xref *xref, fz_obj *dict) +pdf_load_function(pdf_function **funcp, pdf_xref *xref, fz_obj *dict) { fz_error error; pdf_function *func; fz_obj *obj; int i; - if ((*funcp = pdf_finditem(xref->store, pdf_dropfunction, dict))) + if ((*funcp = pdf_find_item(xref->store, pdf_drop_function, dict))) { - pdf_keepfunction(*funcp); + pdf_keep_function(*funcp); return fz_okay; } - pdf_logrsrc("load function (%d %d R) {\n", fz_tonum(dict), fz_togen(dict)); + pdf_log_rsrc("load function (%d %d R) {\n", fz_to_num(dict), fz_to_gen(dict)); func = fz_malloc(sizeof(pdf_function)); memset(func, 0, sizeof(pdf_function)); func->refs = 1; - obj = fz_dictgets(dict, "FunctionType"); - func->type = fz_toint(obj); + obj = fz_dict_gets(dict, "FunctionType"); + func->type = fz_to_int(obj); - pdf_logrsrc("type %d\n", func->type); + pdf_log_rsrc("type %d\n", func->type); /* required for all */ - obj = fz_dictgets(dict, "Domain"); - func->m = fz_arraylen(obj) / 2; + obj = fz_dict_gets(dict, "Domain"); + func->m = fz_array_len(obj) / 2; for (i = 0; i < func->m; i++) { - func->domain[i][0] = fz_toreal(fz_arrayget(obj, i * 2 + 0)); - func->domain[i][1] = fz_toreal(fz_arrayget(obj, i * 2 + 1)); + func->domain[i][0] = fz_to_real(fz_array_get(obj, i * 2 + 0)); + func->domain[i][1] = fz_to_real(fz_array_get(obj, i * 2 + 1)); } - pdf_logrsrc("domain %d\n", func->m); + pdf_log_rsrc("domain %d\n", func->m); /* required for type0 and type4, optional otherwise */ - obj = fz_dictgets(dict, "Range"); - if (fz_isarray(obj)) + obj = fz_dict_gets(dict, "Range"); + if (fz_is_array(obj)) { - func->hasrange = 1; - func->n = fz_arraylen(obj) / 2; + func->has_range = 1; + func->n = fz_array_len(obj) / 2; for (i = 0; i < func->n; i++) { - func->range[i][0] = fz_toreal(fz_arrayget(obj, i * 2 + 0)); - func->range[i][1] = fz_toreal(fz_arrayget(obj, i * 2 + 1)); + func->range[i][0] = fz_to_real(fz_array_get(obj, i * 2 + 0)); + func->range[i][1] = fz_to_real(fz_array_get(obj, i * 2 + 1)); } - pdf_logrsrc("range %d\n", func->n); + pdf_log_rsrc("range %d\n", func->n); } else { - func->hasrange = 0; + func->has_range = 0; func->n = 0; } @@ -1433,56 +1433,56 @@ pdf_loadfunction(pdf_function **funcp, pdf_xref *xref, fz_obj *dict) switch(func->type) { case SAMPLE: - error = loadsamplefunc(func, xref, dict, fz_tonum(dict), fz_togen(dict)); + error = load_sample_func(func, xref, dict, fz_to_num(dict), fz_to_gen(dict)); if (error) { - pdf_dropfunction(func); - return fz_rethrow(error, "cannot load sampled function (%d %d R)", fz_tonum(dict), fz_togen(dict)); + pdf_drop_function(func); + return fz_rethrow(error, "cannot load sampled function (%d %d R)", fz_to_num(dict), fz_to_gen(dict)); } break; case EXPONENTIAL: - error = loadexponentialfunc(func, dict); + error = load_exponential_func(func, dict); if (error) { - pdf_dropfunction(func); - return fz_rethrow(error, "cannot load exponential function (%d %d R)", fz_tonum(dict), fz_togen(dict)); + pdf_drop_function(func); + return fz_rethrow(error, "cannot load exponential function (%d %d R)", fz_to_num(dict), fz_to_gen(dict)); } break; case STITCHING: - error = loadstitchingfunc(func, xref, dict); + error = load_stitching_func(func, xref, dict); if (error) { - pdf_dropfunction(func); - return fz_rethrow(error, "cannot load stitching function (%d %d R)", fz_tonum(dict), fz_togen(dict)); + pdf_drop_function(func); + return fz_rethrow(error, "cannot load stitching function (%d %d R)", fz_to_num(dict), fz_to_gen(dict)); } break; case POSTSCRIPT: - error = loadpostscriptfunc(func, xref, dict, fz_tonum(dict), fz_togen(dict)); + error = load_postscript_func(func, xref, dict, fz_to_num(dict), fz_to_gen(dict)); if (error) { - pdf_dropfunction(func); - return fz_rethrow(error, "cannot load calculator function (%d %d R)", fz_tonum(dict), fz_togen(dict)); + pdf_drop_function(func); + return fz_rethrow(error, "cannot load calculator function (%d %d R)", fz_to_num(dict), fz_to_gen(dict)); } break; default: fz_free(func); - return fz_throw("unknown function type (%d %d R)", fz_tonum(dict), fz_togen(dict)); + return fz_throw("unknown function type (%d %d R)", fz_to_num(dict), fz_to_gen(dict)); } - pdf_logrsrc("}\n"); + pdf_log_rsrc("}\n"); - pdf_storeitem(xref->store, pdf_keepfunction, pdf_dropfunction, dict, func); + pdf_store_item(xref->store, pdf_keep_function, pdf_drop_function, dict, func); *funcp = func; return fz_okay; } void -pdf_evalfunction(pdf_function *func, float *in, int inlen, float *out, int outlen) +pdf_eval_function(pdf_function *func, float *in, int inlen, float *out, int outlen) { memset(out, 0, sizeof(float) * outlen); @@ -1499,10 +1499,10 @@ pdf_evalfunction(pdf_function *func, float *in, int inlen, float *out, int outle switch(func->type) { - case SAMPLE: evalsamplefunc(func, in, out); break; - case EXPONENTIAL: evalexponentialfunc(func, *in, out); break; - case STITCHING: evalstitchingfunc(func, *in, out); break; - case POSTSCRIPT: evalpostscriptfunc(func, in, out); break; + case SAMPLE: eval_sample_func(func, in, out); break; + case EXPONENTIAL: eval_exponential_func(func, *in, out); break; + case STITCHING: eval_stitching_func(func, *in, out); break; + case POSTSCRIPT: eval_postscript_func(func, in, out); break; } } @@ -1511,7 +1511,7 @@ pdf_evalfunction(pdf_function *func, float *in, int inlen, float *out, int outle */ static void -pdf_debugindent(char *prefix, int level, char *suffix) +pdf_debug_indent(char *prefix, int level, char *suffix) { int i; @@ -1524,20 +1524,20 @@ pdf_debugindent(char *prefix, int level, char *suffix) } static void -pdf_debugpsfunccode(psobj *funccode, psobj *code, int level) +pdf_debug_ps_func_code(psobj *funccode, psobj *code, int level) { int eof, wasop; - pdf_debugindent("", level, "{"); + pdf_debug_indent("", level, "{"); /* Print empty blocks as { }, instead of separating braces on different lines. */ - if (code->type == PSOPERATOR && code->u.op == PSORETURN) + if (code->type == PS_OPERATOR && code->u.op == PS_OP_RETURN) { printf(" } "); return; } - pdf_debugindent("\n", ++level, ""); + pdf_debug_indent("\n", ++level, ""); eof = 0; wasop = 0; @@ -1545,60 +1545,60 @@ pdf_debugpsfunccode(psobj *funccode, psobj *code, int level) { switch (code->type) { - case PSINT: + case PS_INT: if (wasop) - pdf_debugindent("\n", level, ""); + pdf_debug_indent("\n", level, ""); printf("%d ", code->u.i); wasop = 0; code++; break; - case PSREAL: + case PS_REAL: if (wasop) - pdf_debugindent("\n", level, ""); + pdf_debug_indent("\n", level, ""); printf("%g ", code->u.f); wasop = 0; code++; break; - case PSOPERATOR: - if (code->u.op == PSORETURN) + case PS_OPERATOR: + if (code->u.op == PS_OP_RETURN) { printf("\n"); eof = 1; } - else if (code->u.op == PSOIF) + else if (code->u.op == PS_OP_IF) { printf("\n"); - pdf_debugpsfunccode(funccode, &funccode[(code + 2)->u.block], level); + pdf_debug_ps_func_code(funccode, &funccode[(code + 2)->u.block], level); - printf("%s", psopnames[code->u.op]); + printf("%s", ps_op_names[code->u.op]); code = &funccode[(code + 3)->u.block]; - if (code->type != PSOPERATOR || code->u.op != PSORETURN) - pdf_debugindent("\n", level, ""); + if (code->type != PS_OPERATOR || code->u.op != PS_OP_RETURN) + pdf_debug_indent("\n", level, ""); wasop = 0; } - else if (code->u.op == PSOIFELSE) + else if (code->u.op == PS_OP_IFELSE) { printf("\n"); - pdf_debugpsfunccode(funccode, &funccode[(code + 2)->u.block], level); + pdf_debug_ps_func_code(funccode, &funccode[(code + 2)->u.block], level); printf("\n"); - pdf_debugpsfunccode(funccode, &funccode[(code + 1)->u.block], level); + pdf_debug_ps_func_code(funccode, &funccode[(code + 1)->u.block], level); - printf("%s", psopnames[code->u.op]); + printf("%s", ps_op_names[code->u.op]); code = &funccode[(code + 3)->u.block]; - if (code->type != PSOPERATOR || code->u.op != PSORETURN) - pdf_debugindent("\n", level, ""); + if (code->type != PS_OPERATOR || code->u.op != PS_OP_RETURN) + pdf_debug_indent("\n", level, ""); wasop = 0; } else { - printf("%s ", psopnames[code->u.op]); + printf("%s ", ps_op_names[code->u.op]); code++; wasop = 1; } @@ -1606,17 +1606,17 @@ pdf_debugpsfunccode(psobj *funccode, psobj *code, int level) } } - pdf_debugindent("", --level, "} "); + pdf_debug_indent("", --level, "} "); } static void -pdf_debugfunctionimp(pdf_function *func, int level) +pdf_debug_function_imp(pdf_function *func, int level) { int i; - pdf_debugindent("", level, "function {\n"); + pdf_debug_indent("", level, "function {\n"); - pdf_debugindent("", ++level, ""); + pdf_debug_indent("", ++level, ""); switch (func->type) { case SAMPLE: @@ -1633,17 +1633,17 @@ pdf_debugfunctionimp(pdf_function *func, int level) break; } - pdf_debugindent("\n", level, ""); + pdf_debug_indent("\n", level, ""); printf("%d input -> %d output\n", func->m, func->n); - pdf_debugindent("", level, "domain "); + pdf_debug_indent("", level, "domain "); for (i = 0; i < func->m; i++) printf("%g %g ", func->domain[i][0], func->domain[i][1]); printf("\n"); - if (func->hasrange) + if (func->has_range) { - pdf_debugindent("", level, "range "); + pdf_debug_indent("", level, "range "); for (i = 0; i < func->n; i++) printf("%g %g ", func->range[i][0], func->range[i][1]); printf("\n"); @@ -1652,22 +1652,22 @@ pdf_debugfunctionimp(pdf_function *func, int level) switch (func->type) { case SAMPLE: - pdf_debugindent("", level, ""); + pdf_debug_indent("", level, ""); printf("bps: %d\n", func->u.sa.bps); - pdf_debugindent("", level, ""); + pdf_debug_indent("", level, ""); printf("size: [ "); for (i = 0; i < func->m; i++) printf("%d ", func->u.sa.size[i]); printf("]\n"); - pdf_debugindent("", level, ""); + pdf_debug_indent("", level, ""); printf("encode: [ "); for (i = 0; i < func->m; i++) printf("%g %g ", func->u.sa.encode[i][0], func->u.sa.encode[i][1]); printf("]\n"); - pdf_debugindent("", level, ""); + pdf_debug_indent("", level, ""); printf("decode: [ "); for (i = 0; i < func->m; i++) printf("%g %g ", func->u.sa.decode[i][0], func->u.sa.decode[i][1]); @@ -1675,16 +1675,16 @@ pdf_debugfunctionimp(pdf_function *func, int level) break; case EXPONENTIAL: - pdf_debugindent("", level, ""); + pdf_debug_indent("", level, ""); printf("n: %g\n", func->u.e.n); - pdf_debugindent("", level, ""); + pdf_debug_indent("", level, ""); printf("c0: [ "); for (i = 0; i < func->n; i++) printf("%g ", func->u.e.c0[i]); printf("]\n"); - pdf_debugindent("", level, ""); + pdf_debug_indent("", level, ""); printf("c1: [ "); for (i = 0; i < func->n; i++) printf("%g ", func->u.e.c1[i]); @@ -1692,36 +1692,36 @@ pdf_debugfunctionimp(pdf_function *func, int level) break; case STITCHING: - pdf_debugindent("", level, ""); + pdf_debug_indent("", level, ""); printf("%d functions\n", func->u.st.k); - pdf_debugindent("", level, ""); + pdf_debug_indent("", level, ""); printf("bounds: [ "); for (i = 0; i < func->u.st.k - 1; i++) printf("%g ", func->u.st.bounds[i]); printf("]\n"); - pdf_debugindent("", level, ""); + pdf_debug_indent("", level, ""); printf("encode: [ "); for (i = 0; i < func->u.st.k * 2; i++) printf("%g ", func->u.st.encode[i]); printf("]\n"); for (i = 0; i < func->u.st.k; i++) - pdf_debugfunctionimp(func->u.st.funcs[i], level); + pdf_debug_function_imp(func->u.st.funcs[i], level); break; case POSTSCRIPT: - pdf_debugpsfunccode(func->u.p.code, func->u.p.code, level); + pdf_debug_ps_func_code(func->u.p.code, func->u.p.code, level); printf("\n"); break; } - pdf_debugindent("", --level, "}\n"); + pdf_debug_indent("", --level, "}\n"); } void -pdf_debugfunction(pdf_function *func) +pdf_debug_function(pdf_function *func) { - pdf_debugfunctionimp(func, 0); + pdf_debug_function_imp(func, 0); } diff --git a/pdf/pdf_image.c b/pdf/pdf_image.c index b37c7257..dc12c232 100644 --- a/pdf/pdf_image.c +++ b/pdf/pdf_image.c @@ -4,10 +4,10 @@ /* TODO: store JPEG compressed samples */ /* TODO: store flate compressed samples */ -static fz_error pdf_loadjpximage(fz_pixmap **imgp, pdf_xref *xref, fz_obj *dict); +static fz_error pdf_load_jpx_image(fz_pixmap **imgp, pdf_xref *xref, fz_obj *dict); static void -pdf_maskcolorkey(fz_pixmap *pix, int n, int *colorkey) +pdf_mask_color_key(fz_pixmap *pix, int n, int *colorkey) { unsigned char *p = pix->samples; int len = pix->w * pix->h; @@ -26,7 +26,7 @@ pdf_maskcolorkey(fz_pixmap *pix, int n, int *colorkey) } static fz_error -pdf_loadimageimp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz_stream *cstm, int forcemask) +pdf_load_image_imp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz_stream *cstm, int forcemask) { fz_stream *stm; fz_pixmap *tile; @@ -40,8 +40,8 @@ pdf_loadimageimp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz fz_colorspace *colorspace; fz_pixmap *mask; /* explicit mask/softmask image */ int usecolorkey; - int colorkey[FZ_MAXCOLORS * 2]; - float decode[FZ_MAXCOLORS * 2]; + int colorkey[FZ_MAX_COLORS * 2]; + float decode[FZ_MAX_COLORS * 2]; int scale; int stride; @@ -49,21 +49,21 @@ pdf_loadimageimp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz int i, len; /* special case for JPEG2000 images */ - if (pdf_isjpximage(dict)) + if (pdf_is_jpx_image(dict)) { - tile = nil; - error = pdf_loadjpximage(&tile, xref, dict); + tile = NULL; + error = pdf_load_jpx_image(&tile, xref, dict); if (error) return fz_rethrow(error, "cannot load jpx image"); if (forcemask) { if (tile->n != 2) { - fz_droppixmap(tile); + fz_drop_pixmap(tile); return fz_throw("softmask must be grayscale"); } - mask = fz_alphafromgray(tile, 1); - fz_droppixmap(tile); + mask = fz_alpha_from_gray(tile, 1); + fz_drop_pixmap(tile); *imgp = mask; return fz_okay; } @@ -71,16 +71,16 @@ pdf_loadimageimp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz return fz_okay; } - w = fz_toint(fz_dictgetsa(dict, "Width", "W")); - h = fz_toint(fz_dictgetsa(dict, "Height", "H")); - bpc = fz_toint(fz_dictgetsa(dict, "BitsPerComponent", "BPC")); - imagemask = fz_tobool(fz_dictgetsa(dict, "ImageMask", "IM")); - interpolate = fz_tobool(fz_dictgetsa(dict, "Interpolate", "I")); + w = fz_to_int(fz_dict_getsa(dict, "Width", "W")); + h = fz_to_int(fz_dict_getsa(dict, "Height", "H")); + bpc = fz_to_int(fz_dict_getsa(dict, "BitsPerComponent", "BPC")); + imagemask = fz_to_bool(fz_dict_getsa(dict, "ImageMask", "IM")); + interpolate = fz_to_bool(fz_dict_getsa(dict, "Interpolate", "I")); indexed = 0; usecolorkey = 0; - colorspace = nil; - mask = nil; + colorspace = NULL; + mask = NULL; if (imagemask) bpc = 1; @@ -96,18 +96,18 @@ pdf_loadimageimp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz if (h > (1 << 16)) return fz_throw("image is too high"); - obj = fz_dictgetsa(dict, "ColorSpace", "CS"); + obj = fz_dict_getsa(dict, "ColorSpace", "CS"); if (obj && !imagemask && !forcemask) { /* colorspace resource lookup is only done for inline images */ - if (fz_isname(obj)) + if (fz_is_name(obj)) { - res = fz_dictget(fz_dictgets(rdb, "ColorSpace"), obj); + res = fz_dict_get(fz_dict_gets(rdb, "ColorSpace"), obj); if (res) obj = res; } - error = pdf_loadcolorspace(&colorspace, xref, obj); + error = pdf_load_colorspace(&colorspace, xref, obj); if (error) return fz_rethrow(error, "cannot load image colorspace"); @@ -121,11 +121,11 @@ pdf_loadimageimp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz n = 1; } - obj = fz_dictgetsa(dict, "Decode", "D"); + obj = fz_dict_getsa(dict, "Decode", "D"); if (obj) { for (i = 0; i < n * 2; i++) - decode[i] = fz_toreal(fz_arrayget(obj, i)); + decode[i] = fz_to_real(fz_array_get(obj, i)); } else { @@ -134,44 +134,44 @@ pdf_loadimageimp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz decode[i] = i & 1 ? maxval : 0; } - obj = fz_dictgetsa(dict, "SMask", "Mask"); - if (fz_isdict(obj)) + obj = fz_dict_getsa(dict, "SMask", "Mask"); + if (fz_is_dict(obj)) { /* Not allowed for inline images */ if (!cstm) { - error = pdf_loadimageimp(&mask, xref, rdb, obj, nil, 1); + error = pdf_load_image_imp(&mask, xref, rdb, obj, NULL, 1); if (error) { if (colorspace) - fz_dropcolorspace(colorspace); + fz_drop_colorspace(colorspace); return fz_rethrow(error, "cannot load image mask/softmask"); } } } - else if (fz_isarray(obj)) + else if (fz_is_array(obj)) { usecolorkey = 1; for (i = 0; i < n * 2; i++) - colorkey[i] = fz_toint(fz_arrayget(obj, i)); + colorkey[i] = fz_to_int(fz_array_get(obj, i)); } stride = (w * n * bpc + 7) / 8; if (cstm) { - stm = pdf_openinlinestream(cstm, xref, dict, stride * h); + stm = pdf_open_inline_stream(cstm, xref, dict, stride * h); } else { - error = pdf_openstream(&stm, xref, fz_tonum(dict), fz_togen(dict)); + error = pdf_open_stream(&stm, xref, fz_to_num(dict), fz_to_gen(dict)); if (error) { if (colorspace) - fz_dropcolorspace(colorspace); + fz_drop_colorspace(colorspace); if (mask) - fz_droppixmap(mask); - return fz_rethrow(error, "cannot open image data stream (%d 0 R)", fz_tonum(dict)); + fz_drop_pixmap(mask); + return fz_rethrow(error, "cannot open image data stream (%d 0 R)", fz_to_num(dict)); } } @@ -182,9 +182,9 @@ pdf_loadimageimp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz { fz_close(stm); if (colorspace) - fz_dropcolorspace(colorspace); + fz_drop_colorspace(colorspace); if (mask) - fz_droppixmap(mask); + fz_drop_pixmap(mask); fz_free(samples); return fz_rethrow(len, "cannot read image data"); } @@ -205,7 +205,7 @@ pdf_loadimageimp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz /* Pad truncated images */ if (len < stride * h) { - fz_warn("padding truncated image (%d 0 R)", fz_tonum(dict)); + fz_warn("padding truncated image (%d 0 R)", fz_to_num(dict)); memset(samples + len, 0, stride * h - len); } @@ -219,11 +219,11 @@ pdf_loadimageimp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz p[i] = ~p[i]; } - pdf_logimage("size %dx%d n=%d bpc=%d imagemask=%d indexed=%d\n", w, h, n, bpc, imagemask, indexed); + pdf_log_image("size %dx%d n=%d bpc=%d imagemask=%d indexed=%d\n", w, h, n, bpc, imagemask, indexed); /* Unpack samples into pixmap */ - tile = fz_newpixmap(colorspace, 0, 0, w, h); + tile = fz_new_pixmap(colorspace, 0, 0, w, h); scale = 1; if (!indexed) @@ -236,28 +236,28 @@ pdf_loadimageimp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz } } - fz_unpacktile(tile, samples, n, bpc, stride, scale); + fz_unpack_tile(tile, samples, n, bpc, stride, scale); if (usecolorkey) - pdf_maskcolorkey(tile, n, colorkey); + pdf_mask_color_key(tile, n, colorkey); if (indexed) { fz_pixmap *conv; - fz_decodeindexedtile(tile, decode, (1 << bpc) - 1); + fz_decode_indexed_tile(tile, decode, (1 << bpc) - 1); - conv = pdf_expandindexedpixmap(tile); - fz_droppixmap(tile); + conv = pdf_expand_indexed_pixmap(tile); + fz_drop_pixmap(tile); tile = conv; } else { - fz_decodetile(tile, decode); + fz_decode_tile(tile, decode); } if (colorspace) - fz_dropcolorspace(colorspace); + fz_drop_colorspace(colorspace); tile->mask = mask; tile->interpolate = interpolate; @@ -269,97 +269,97 @@ pdf_loadimageimp(fz_pixmap **imgp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz } fz_error -pdf_loadinlineimage(fz_pixmap **pixp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz_stream *file) +pdf_load_inline_image(fz_pixmap **pixp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict, fz_stream *file) { fz_error error; - pdf_logimage("load inline image {\n"); + pdf_log_image("load inline image {\n"); - error = pdf_loadimageimp(pixp, xref, rdb, dict, file, 0); + error = pdf_load_image_imp(pixp, xref, rdb, dict, file, 0); if (error) return fz_rethrow(error, "cannot load inline image"); - pdf_logimage("}\n"); + pdf_log_image("}\n"); return fz_okay; } int -pdf_isjpximage(fz_obj *dict) +pdf_is_jpx_image(fz_obj *dict) { fz_obj *filter; int i; - filter = fz_dictgets(dict, "Filter"); - if (!strcmp(fz_toname(filter), "JPXDecode")) + filter = fz_dict_gets(dict, "Filter"); + if (!strcmp(fz_to_name(filter), "JPXDecode")) return 1; - for (i = 0; i < fz_arraylen(filter); i++) - if (!strcmp(fz_toname(fz_arrayget(filter, i)), "JPXDecode")) + for (i = 0; i < fz_array_len(filter); i++) + if (!strcmp(fz_to_name(fz_array_get(filter, i)), "JPXDecode")) return 1; return 0; } static fz_error -pdf_loadjpximage(fz_pixmap **imgp, pdf_xref *xref, fz_obj *dict) +pdf_load_jpx_image(fz_pixmap **imgp, pdf_xref *xref, fz_obj *dict) { fz_error error; fz_buffer *buf; fz_pixmap *img; fz_obj *obj; - pdf_logimage("jpeg2000\n"); + pdf_log_image("jpeg2000\n"); - error = pdf_loadstream(&buf, xref, fz_tonum(dict), fz_togen(dict)); + error = pdf_load_stream(&buf, xref, fz_to_num(dict), fz_to_gen(dict)); if (error) return fz_rethrow(error, "cannot load jpx image data"); - error = fz_loadjpximage(&img, buf->data, buf->len); + error = fz_load_jpx_image(&img, buf->data, buf->len); if (error) { - fz_dropbuffer(buf); + fz_drop_buffer(buf); return fz_rethrow(error, "cannot load jpx image"); } - fz_dropbuffer(buf); + fz_drop_buffer(buf); - obj = fz_dictgetsa(dict, "SMask", "Mask"); - if (fz_isdict(obj)) + obj = fz_dict_getsa(dict, "SMask", "Mask"); + if (fz_is_dict(obj)) { - error = pdf_loadimageimp(&img->mask, xref, nil, obj, nil, 1); + error = pdf_load_image_imp(&img->mask, xref, NULL, obj, NULL, 1); if (error) { - fz_droppixmap(img); + fz_drop_pixmap(img); return fz_rethrow(error, "cannot load image mask/softmask"); } } - obj = fz_dictgets(dict, "ColorSpace"); + obj = fz_dict_gets(dict, "ColorSpace"); if (obj) { fz_colorspace *original = img->colorspace; - img->colorspace = nil; + img->colorspace = NULL; - error = pdf_loadcolorspace(&img->colorspace, xref, obj); + error = pdf_load_colorspace(&img->colorspace, xref, obj); if (error) { - fz_dropcolorspace(original); + fz_drop_colorspace(original); return fz_rethrow(error, "cannot load image colorspace"); } if (original->n != img->colorspace->n) { fz_warn("jpeg-2000 colorspace (%s) does not match promised colorspace (%s)", original->name, img->colorspace->name); - fz_dropcolorspace(img->colorspace); + fz_drop_colorspace(img->colorspace); img->colorspace = original; } else - fz_dropcolorspace(original); + fz_drop_colorspace(original); if (!strcmp(img->colorspace->name, "Indexed")) { fz_pixmap *conv; - conv = pdf_expandindexedpixmap(img); - fz_droppixmap(img); + conv = pdf_expand_indexed_pixmap(img); + fz_drop_pixmap(img); img = conv; } } @@ -369,25 +369,25 @@ pdf_loadjpximage(fz_pixmap **imgp, pdf_xref *xref, fz_obj *dict) } fz_error -pdf_loadimage(fz_pixmap **pixp, pdf_xref *xref, fz_obj *dict) +pdf_load_image(fz_pixmap **pixp, pdf_xref *xref, fz_obj *dict) { fz_error error; - if ((*pixp = pdf_finditem(xref->store, fz_droppixmap, dict))) + if ((*pixp = pdf_find_item(xref->store, fz_drop_pixmap, dict))) { - fz_keeppixmap(*pixp); + fz_keep_pixmap(*pixp); return fz_okay; } - pdf_logimage("load image (%d 0 R) {\n", fz_tonum(dict)); + pdf_log_image("load image (%d 0 R) {\n", fz_to_num(dict)); - error = pdf_loadimageimp(pixp, xref, nil, dict, nil, 0); + error = pdf_load_image_imp(pixp, xref, NULL, dict, NULL, 0); if (error) - return fz_rethrow(error, "cannot load image (%d 0 R)", fz_tonum(dict)); + return fz_rethrow(error, "cannot load image (%d 0 R)", fz_to_num(dict)); - pdf_storeitem(xref->store, fz_keeppixmap, fz_droppixmap, dict, *pixp); + pdf_store_item(xref->store, fz_keep_pixmap, fz_drop_pixmap, dict, *pixp); - pdf_logimage("}\n"); + pdf_log_image("}\n"); return fz_okay; } diff --git a/pdf/pdf_interpret.c b/pdf/pdf_interpret.c index dbeeb997..81848709 100644 --- a/pdf/pdf_interpret.c +++ b/pdf/pdf_interpret.c @@ -2,7 +2,7 @@ #include "mupdf.h" static pdf_csi * -pdf_newcsi(pdf_xref *xref, fz_device *dev, fz_matrix ctm, char *target) +pdf_new_csi(pdf_xref *xref, fz_device *dev, fz_matrix ctm, char *target) { pdf_csi *csi; @@ -12,43 +12,43 @@ pdf_newcsi(pdf_xref *xref, fz_device *dev, fz_matrix ctm, char *target) csi->target = target; csi->top = 0; - csi->obj = nil; + csi->obj = NULL; csi->name[0] = 0; - csi->stringlen = 0; + csi->string_len = 0; memset(csi->stack, 0, sizeof csi->stack); csi->xbalance = 0; - csi->intext = 0; - csi->inarray = 0; + csi->in_text = 0; + csi->in_array = 0; - csi->path = fz_newpath(); + csi->path = fz_new_path(); csi->clip = 0; - csi->clipevenodd = 0; + csi->clip_even_odd = 0; - csi->text = nil; + csi->text = NULL; csi->tlm = fz_identity; csi->tm = fz_identity; - csi->textmode = 0; + csi->text_mode = 0; csi->accumulate = 1; - csi->topctm = ctm; - pdf_initgstate(&csi->gstate[0], ctm); + csi->top_ctm = ctm; + pdf_init_gstate(&csi->gstate[0], ctm); csi->gtop = 0; return csi; } static void -pdf_clearstack(pdf_csi *csi) +pdf_clear_stack(pdf_csi *csi) { int i; if (csi->obj) - fz_dropobj(csi->obj); - csi->obj = nil; + fz_drop_obj(csi->obj); + csi->obj = NULL; csi->name[0] = 0; - csi->stringlen = 0; + csi->string_len = 0; for (i = 0; i < csi->top; i++) csi->stack[i] = 0; @@ -56,26 +56,26 @@ pdf_clearstack(pdf_csi *csi) } pdf_material * -pdf_keepmaterial(pdf_material *mat) +pdf_keep_material(pdf_material *mat) { if (mat->colorspace) - fz_keepcolorspace(mat->colorspace); + fz_keep_colorspace(mat->colorspace); if (mat->pattern) - pdf_keeppattern(mat->pattern); + pdf_keep_pattern(mat->pattern); if (mat->shade) - fz_keepshade(mat->shade); + fz_keep_shade(mat->shade); return mat; } pdf_material * -pdf_dropmaterial(pdf_material *mat) +pdf_drop_material(pdf_material *mat) { if (mat->colorspace) - fz_dropcolorspace(mat->colorspace); + fz_drop_colorspace(mat->colorspace); if (mat->pattern) - pdf_droppattern(mat->pattern); + pdf_drop_pattern(mat->pattern); if (mat->shade) - fz_dropshade(mat->shade); + fz_drop_shade(mat->shade); return mat; } @@ -94,19 +94,19 @@ pdf_gsave(pdf_csi *csi) csi->gtop ++; - pdf_keepmaterial(&gs->stroke); - pdf_keepmaterial(&gs->fill); + pdf_keep_material(&gs->stroke); + pdf_keep_material(&gs->fill); if (gs->font) - pdf_keepfont(gs->font); + pdf_keep_font(gs->font); if (gs->softmask) - pdf_keepxobject(gs->softmask); + pdf_keep_xobject(gs->softmask); } void pdf_grestore(pdf_csi *csi) { pdf_gstate *gs = csi->gstate + csi->gtop; - int clipdepth = gs->clipdepth; + int clip_depth = gs->clip_depth; if (csi->gtop == 0) { @@ -114,49 +114,49 @@ pdf_grestore(pdf_csi *csi) return; } - pdf_dropmaterial(&gs->stroke); - pdf_dropmaterial(&gs->fill); + pdf_drop_material(&gs->stroke); + pdf_drop_material(&gs->fill); if (gs->font) - pdf_dropfont(gs->font); + pdf_drop_font(gs->font); if (gs->softmask) - pdf_dropxobject(gs->softmask); + pdf_drop_xobject(gs->softmask); csi->gtop --; gs = csi->gstate + csi->gtop; - while (clipdepth > gs->clipdepth) + while (clip_depth > gs->clip_depth) { - csi->dev->popclip(csi->dev->user); - clipdepth--; + csi->dev->pop_clip(csi->dev->user); + clip_depth--; } } static void -pdf_freecsi(pdf_csi *csi) +pdf_free_csi(pdf_csi *csi) { while (csi->gtop) pdf_grestore(csi); - pdf_dropmaterial(&csi->gstate[0].fill); - pdf_dropmaterial(&csi->gstate[0].stroke); + pdf_drop_material(&csi->gstate[0].fill); + pdf_drop_material(&csi->gstate[0].stroke); if (csi->gstate[0].font) - pdf_dropfont(csi->gstate[0].font); + pdf_drop_font(csi->gstate[0].font); if (csi->gstate[0].softmask) - pdf_dropxobject(csi->gstate[0].softmask); + pdf_drop_xobject(csi->gstate[0].softmask); - while (csi->gstate[0].clipdepth--) - csi->dev->popclip(csi->dev->user); + while (csi->gstate[0].clip_depth--) + csi->dev->pop_clip(csi->dev->user); - if (csi->path) fz_freepath(csi->path); - if (csi->text) fz_freetext(csi->text); + if (csi->path) fz_free_path(csi->path); + if (csi->text) fz_free_text(csi->text); - pdf_clearstack(csi); + pdf_clear_stack(csi); fz_free(csi); } static int -pdf_ishiddenocg(pdf_csi *csi, fz_obj *xobj) +pdf_is_hidden_ocg(pdf_csi *csi, fz_obj *xobj) { char target_state[16]; fz_obj *obj; @@ -164,18 +164,18 @@ pdf_ishiddenocg(pdf_csi *csi, fz_obj *xobj) fz_strlcpy(target_state, csi->target, sizeof target_state); fz_strlcat(target_state, "State", sizeof target_state); - obj = fz_dictgets(xobj, "OC"); - obj = fz_dictgets(obj, "OCGs"); - if (fz_isarray(obj)) - obj = fz_arrayget(obj, 0); - obj = fz_dictgets(obj, "Usage"); - obj = fz_dictgets(obj, csi->target); - obj = fz_dictgets(obj, target_state); - return !strcmp(fz_toname(obj), "OFF"); + obj = fz_dict_gets(xobj, "OC"); + obj = fz_dict_gets(obj, "OCGs"); + if (fz_is_array(obj)) + obj = fz_array_get(obj, 0); + obj = fz_dict_gets(obj, "Usage"); + obj = fz_dict_gets(obj, csi->target); + obj = fz_dict_gets(obj, target_state); + return !strcmp(fz_to_name(obj), "OFF"); } fz_error -pdf_runxobject(pdf_csi *csi, fz_obj *resources, pdf_xobject *xobj, fz_matrix transform) +pdf_run_xobject(pdf_csi *csi, fz_obj *resources, pdf_xobject *xobj, fz_matrix transform) { fz_error error; pdf_gstate *gstate; @@ -199,26 +199,26 @@ pdf_runxobject(pdf_csi *csi, fz_obj *resources, pdf_xobject *xobj, fz_matrix tra if (gstate->softmask) { pdf_xobject *softmask = gstate->softmask; - fz_rect bbox = fz_transformrect(gstate->ctm, xobj->bbox); + fz_rect bbox = fz_transform_rect(gstate->ctm, xobj->bbox); - gstate->softmask = nil; + gstate->softmask = NULL; popmask = 1; - csi->dev->beginmask(csi->dev->user, bbox, gstate->luminosity, - softmask->colorspace, gstate->softmaskbc); - error = pdf_runxobject(csi, resources, softmask, fz_identity); + csi->dev->begin_mask(csi->dev->user, bbox, gstate->luminosity, + softmask->colorspace, gstate->softmask_bc); + error = pdf_run_xobject(csi, resources, softmask, fz_identity); if (error) return fz_rethrow(error, "cannot run softmask"); - csi->dev->endmask(csi->dev->user); + csi->dev->end_mask(csi->dev->user); - pdf_dropxobject(softmask); + pdf_drop_xobject(softmask); } - csi->dev->begingroup(csi->dev->user, - fz_transformrect(gstate->ctm, xobj->bbox), + csi->dev->begin_group(csi->dev->user, + fz_transform_rect(gstate->ctm, xobj->bbox), xobj->isolated, xobj->knockout, gstate->blendmode, gstate->fill.alpha); - gstate->blendmode = FZ_BNORMAL; + gstate->blendmode = FZ_BLEND_NORMAL; gstate->stroke.alpha = 1; gstate->fill.alpha = 1; } @@ -231,21 +231,21 @@ pdf_runxobject(pdf_csi *csi, fz_obj *resources, pdf_xobject *xobj, fz_matrix tra fz_lineto(csi->path, xobj->bbox.x0, xobj->bbox.y1); fz_closepath(csi->path); csi->clip = 1; - pdf_showpath(csi, 0, 0, 0, 0); + pdf_show_path(csi, 0, 0, 0, 0); /* run contents */ - oldtopctm = csi->topctm; - csi->topctm = gstate->ctm; + oldtopctm = csi->top_ctm; + csi->top_ctm = gstate->ctm; if (xobj->resources) resources = xobj->resources; - error = pdf_runcsibuffer(csi, resources, xobj->contents); + error = pdf_run_csi_buffer(csi, resources, xobj->contents); if (error) return fz_rethrow(error, "cannot interpret XObject stream"); - csi->topctm = oldtopctm; + csi->top_ctm = oldtopctm; while (oldtop < csi->gtop) pdf_grestore(csi); @@ -256,124 +256,124 @@ pdf_runxobject(pdf_csi *csi, fz_obj *resources, pdf_xobject *xobj, fz_matrix tra if (xobj->transparency) { - csi->dev->endgroup(csi->dev->user); + csi->dev->end_group(csi->dev->user); if (popmask) - csi->dev->popclip(csi->dev->user); + csi->dev->pop_clip(csi->dev->user); } return fz_okay; } static fz_error -pdf_runinlineimage(pdf_csi *csi, fz_obj *rdb, fz_stream *file, fz_obj *dict) +pdf_run_inline_image(pdf_csi *csi, fz_obj *rdb, fz_stream *file, fz_obj *dict) { fz_error error; fz_pixmap *img; int ch; - error = pdf_loadinlineimage(&img, csi->xref, rdb, dict, file); + error = pdf_load_inline_image(&img, csi->xref, rdb, dict, file); if (error) return fz_rethrow(error, "cannot load inline image"); /* find EI */ - ch = fz_readbyte(file); + ch = fz_read_byte(file); while (ch != 'E' && ch != EOF) - ch = fz_readbyte(file); - ch = fz_readbyte(file); + ch = fz_read_byte(file); + ch = fz_read_byte(file); if (ch != 'I') { - fz_droppixmap(img); + fz_drop_pixmap(img); return fz_rethrow(error, "syntax error after inline image"); } - pdf_showimage(csi, img); + pdf_show_image(csi, img); - fz_droppixmap(img); + fz_drop_pixmap(img); return fz_okay; } static fz_error -pdf_runextgstate(pdf_csi *csi, fz_obj *rdb, fz_obj *extgstate) +pdf_run_extgstate(pdf_csi *csi, fz_obj *rdb, fz_obj *extgstate) { pdf_gstate *gstate = csi->gstate + csi->gtop; fz_colorspace *colorspace; int i, k; - pdf_flushtext(csi); + pdf_flush_text(csi); - for (i = 0; i < fz_dictlen(extgstate); i++) + for (i = 0; i < fz_dict_len(extgstate); i++) { - fz_obj *key = fz_dictgetkey(extgstate, i); - fz_obj *val = fz_dictgetval(extgstate, i); - char *s = fz_toname(key); + fz_obj *key = fz_dict_get_key(extgstate, i); + fz_obj *val = fz_dict_get_val(extgstate, i); + char *s = fz_to_name(key); if (!strcmp(s, "Font")) { - if (fz_isarray(val) && fz_arraylen(val) == 2) + if (fz_is_array(val) && fz_array_len(val) == 2) { fz_error error; - fz_obj *font = fz_arrayget(val, 0); + fz_obj *font = fz_array_get(val, 0); if (gstate->font) { - pdf_dropfont(gstate->font); - gstate->font = nil; + pdf_drop_font(gstate->font); + gstate->font = NULL; } - error = pdf_loadfont(&gstate->font, csi->xref, rdb, font); + error = pdf_load_font(&gstate->font, csi->xref, rdb, font); if (error) - return fz_rethrow(error, "cannot load font (%d %d R)", fz_tonum(font), fz_togen(font)); + return fz_rethrow(error, "cannot load font (%d %d R)", fz_to_num(font), fz_to_gen(font)); if (!gstate->font) return fz_throw("cannot find font in store"); - gstate->size = fz_toreal(fz_arrayget(val, 1)); + gstate->size = fz_to_real(fz_array_get(val, 1)); } else return fz_throw("malformed /Font dictionary"); } else if (!strcmp(s, "LW")) - gstate->strokestate.linewidth = fz_toreal(val); + gstate->stroke_state.linewidth = fz_to_real(val); else if (!strcmp(s, "LC")) - gstate->strokestate.linecap = fz_toint(val); + gstate->stroke_state.linecap = fz_to_int(val); else if (!strcmp(s, "LJ")) - gstate->strokestate.linejoin = fz_toint(val); + gstate->stroke_state.linejoin = fz_to_int(val); else if (!strcmp(s, "ML")) - gstate->strokestate.miterlimit = fz_toreal(val); + gstate->stroke_state.miterlimit = fz_to_real(val); else if (!strcmp(s, "D")) { - if (fz_isarray(val) && fz_arraylen(val) == 2) + if (fz_is_array(val) && fz_array_len(val) == 2) { - fz_obj *dashes = fz_arrayget(val, 0); - gstate->strokestate.dashlen = MAX(fz_arraylen(dashes), 32); - for (k = 0; k < gstate->strokestate.dashlen; k++) - gstate->strokestate.dashlist[k] = fz_toreal(fz_arrayget(dashes, k)); - gstate->strokestate.dashphase = fz_toreal(fz_arrayget(val, 1)); + fz_obj *dashes = fz_array_get(val, 0); + gstate->stroke_state.dash_len = MAX(fz_array_len(dashes), 32); + for (k = 0; k < gstate->stroke_state.dash_len; k++) + gstate->stroke_state.dash_list[k] = fz_to_real(fz_array_get(dashes, k)); + gstate->stroke_state.dash_phase = fz_to_real(fz_array_get(val, 1)); } else return fz_throw("malformed /D"); } else if (!strcmp(s, "CA")) - gstate->stroke.alpha = fz_toreal(val); + gstate->stroke.alpha = fz_to_real(val); else if (!strcmp(s, "ca")) - gstate->fill.alpha = fz_toreal(val); + gstate->fill.alpha = fz_to_real(val); else if (!strcmp(s, "BM")) { - if (fz_isarray(val)) - val = fz_arrayget(val, 0); + if (fz_is_array(val)) + val = fz_array_get(val, 0); - gstate->blendmode = FZ_BNORMAL; - for (k = 0; fz_blendnames[k]; k++) - if (!strcmp(fz_blendnames[k], fz_toname(val))) + gstate->blendmode = FZ_BLEND_NORMAL; + for (k = 0; fz_blendmode_names[k]; k++) + if (!strcmp(fz_blendmode_names[k], fz_to_name(val))) gstate->blendmode = k; } else if (!strcmp(s, "SMask")) { - if (fz_isdict(val)) + if (fz_is_dict(val)) { fz_error error; pdf_xobject *xobj; @@ -381,52 +381,52 @@ pdf_runextgstate(pdf_csi *csi, fz_obj *rdb, fz_obj *extgstate) if (gstate->softmask) { - pdf_dropxobject(gstate->softmask); - gstate->softmask = nil; + pdf_drop_xobject(gstate->softmask); + gstate->softmask = NULL; } - group = fz_dictgets(val, "G"); + group = fz_dict_gets(val, "G"); if (!group) - return fz_throw("cannot load softmask xobject (%d %d R)", fz_tonum(val), fz_togen(val)); - error = pdf_loadxobject(&xobj, csi->xref, group); + return fz_throw("cannot load softmask xobject (%d %d R)", fz_to_num(val), fz_to_gen(val)); + error = pdf_load_xobject(&xobj, csi->xref, group); if (error) - return fz_rethrow(error, "cannot load xobject (%d %d R)", fz_tonum(val), fz_togen(val)); + return fz_rethrow(error, "cannot load xobject (%d %d R)", fz_to_num(val), fz_to_gen(val)); colorspace = xobj->colorspace; if (!colorspace) - colorspace = fz_devicegray; + colorspace = fz_device_gray; - gstate->softmaskctm = fz_concat(xobj->matrix, gstate->ctm); + gstate->softmask_ctm = fz_concat(xobj->matrix, gstate->ctm); gstate->softmask = xobj; for (k = 0; k < colorspace->n; k++) - gstate->softmaskbc[k] = 0; + gstate->softmask_bc[k] = 0; - bc = fz_dictgets(val, "BC"); - if (fz_isarray(bc)) + bc = fz_dict_gets(val, "BC"); + if (fz_is_array(bc)) { for (k = 0; k < colorspace->n; k++) - gstate->softmaskbc[k] = fz_toreal(fz_arrayget(bc, k)); + gstate->softmask_bc[k] = fz_to_real(fz_array_get(bc, k)); } - luminosity = fz_dictgets(val, "S"); - if (fz_isname(luminosity) && !strcmp(fz_toname(luminosity), "Luminosity")) + luminosity = fz_dict_gets(val, "S"); + if (fz_is_name(luminosity) && !strcmp(fz_to_name(luminosity), "Luminosity")) gstate->luminosity = 1; else gstate->luminosity = 0; } - else if (fz_isname(val) && !strcmp(fz_toname(val), "None")) + else if (fz_is_name(val) && !strcmp(fz_to_name(val), "None")) { if (gstate->softmask) { - pdf_dropxobject(gstate->softmask); - gstate->softmask = nil; + pdf_drop_xobject(gstate->softmask); + gstate->softmask = NULL; } } } else if (!strcmp(s, "TR")) { - if (fz_isname(val) && strcmp(fz_toname(val), "Identity")) + if (fz_is_name(val) && strcmp(fz_to_name(val), "Identity")) fz_warn("ignoring transfer function"); } } @@ -446,18 +446,18 @@ static fz_error pdf_run_BI(pdf_csi *csi, fz_obj *rdb, fz_stream *file) int buflen = sizeof(csi->xref->scratch); fz_obj *obj; - error = pdf_parsedict(&obj, csi->xref, file, buf, buflen); + error = pdf_parse_dict(&obj, csi->xref, file, buf, buflen); if (error) return fz_rethrow(error, "cannot parse inline image dictionary"); /* read whitespace after ID keyword */ - ch = fz_readbyte(file); + ch = fz_read_byte(file); if (ch == '\r') - if (fz_peekbyte(file) == '\n') - fz_readbyte(file); + if (fz_peek_byte(file) == '\n') + fz_read_byte(file); - error = pdf_runinlineimage(csi, rdb, file, obj); - fz_dropobj(obj); + error = pdf_run_inline_image(csi, rdb, file, obj); + fz_drop_obj(obj); if (error) return fz_rethrow(error, "cannot parse inline image"); @@ -466,7 +466,7 @@ static fz_error pdf_run_BI(pdf_csi *csi, fz_obj *rdb, fz_stream *file) static void pdf_run_B(pdf_csi *csi) { - pdf_showpath(csi, 0, 1, 1, 0); + pdf_show_path(csi, 0, 1, 1, 0); } static void pdf_run_BMC(pdf_csi *csi) @@ -475,7 +475,7 @@ static void pdf_run_BMC(pdf_csi *csi) static void pdf_run_BT(pdf_csi *csi) { - csi->intext = 1; + csi->in_text = 1; csi->tm = fz_identity; csi->tlm = fz_identity; } @@ -487,7 +487,7 @@ static void pdf_run_BX(pdf_csi *csi) static void pdf_run_Bstar(pdf_csi *csi) { - pdf_showpath(csi, 0, 1, 1, 1); + pdf_show_path(csi, 0, 1, 1, 1); } static fz_error pdf_run_cs_imp(pdf_csi *csi, fz_obj *rdb, int what) @@ -498,32 +498,32 @@ static fz_error pdf_run_cs_imp(pdf_csi *csi, fz_obj *rdb, int what) if (!strcmp(csi->name, "Pattern")) { - pdf_setpattern(csi, what, nil, nil); + pdf_set_pattern(csi, what, NULL, NULL); } else { if (!strcmp(csi->name, "DeviceGray")) - colorspace = fz_keepcolorspace(fz_devicegray); + colorspace = fz_keep_colorspace(fz_device_gray); else if (!strcmp(csi->name, "DeviceRGB")) - colorspace = fz_keepcolorspace(fz_devicergb); + colorspace = fz_keep_colorspace(fz_device_rgb); else if (!strcmp(csi->name, "DeviceCMYK")) - colorspace = fz_keepcolorspace(fz_devicecmyk); + colorspace = fz_keep_colorspace(fz_device_cmyk); else { - dict = fz_dictgets(rdb, "ColorSpace"); + dict = fz_dict_gets(rdb, "ColorSpace"); if (!dict) return fz_throw("cannot find ColorSpace dictionary"); - obj = fz_dictgets(dict, csi->name); + obj = fz_dict_gets(dict, csi->name); if (!obj) return fz_throw("cannot find colorspace resource '%s'", csi->name); - error = pdf_loadcolorspace(&colorspace, csi->xref, obj); + error = pdf_load_colorspace(&colorspace, csi->xref, obj); if (error) - return fz_rethrow(error, "cannot load colorspace (%d 0 R)", fz_tonum(obj)); + return fz_rethrow(error, "cannot load colorspace (%d 0 R)", fz_to_num(obj)); } - pdf_setcolorspace(csi, what, colorspace); + pdf_set_colorspace(csi, what, colorspace); - fz_dropcolorspace(colorspace); + fz_drop_colorspace(colorspace); } return fz_okay; } @@ -531,7 +531,7 @@ static fz_error pdf_run_cs_imp(pdf_csi *csi, fz_obj *rdb, int what) static void pdf_run_CS(pdf_csi *csi, fz_obj *rdb) { fz_error error; - error = pdf_run_cs_imp(csi, rdb, PDF_MSTROKE); + error = pdf_run_cs_imp(csi, rdb, PDF_STROKE); if (error) fz_catch(error, "cannot set colorspace"); } @@ -539,7 +539,7 @@ static void pdf_run_CS(pdf_csi *csi, fz_obj *rdb) static void pdf_run_cs(pdf_csi *csi, fz_obj *rdb) { fz_error error; - error = pdf_run_cs_imp(csi, rdb, PDF_MFILL); + error = pdf_run_cs_imp(csi, rdb, PDF_FILL); if (error) fz_catch(error, "cannot set colorspace"); } @@ -555,64 +555,64 @@ static fz_error pdf_run_Do(pdf_csi *csi, fz_obj *rdb) fz_obj *subtype; fz_error error; - dict = fz_dictgets(rdb, "XObject"); + dict = fz_dict_gets(rdb, "XObject"); if (!dict) return fz_throw("cannot find XObject dictionary when looking for: '%s'", csi->name); - obj = fz_dictgets(dict, csi->name); + obj = fz_dict_gets(dict, csi->name); if (!obj) return fz_throw("cannot find xobject resource: '%s'", csi->name); - subtype = fz_dictgets(obj, "Subtype"); - if (!fz_isname(subtype)) + subtype = fz_dict_gets(obj, "Subtype"); + if (!fz_is_name(subtype)) return fz_throw("no XObject subtype specified"); - if (pdf_ishiddenocg(csi, obj)) + if (pdf_is_hidden_ocg(csi, obj)) return fz_okay; - if (!strcmp(fz_toname(subtype), "Form") && fz_dictgets(obj, "Subtype2")) - subtype = fz_dictgets(obj, "Subtype2"); + if (!strcmp(fz_to_name(subtype), "Form") && fz_dict_gets(obj, "Subtype2")) + subtype = fz_dict_gets(obj, "Subtype2"); - if (!strcmp(fz_toname(subtype), "Form")) + if (!strcmp(fz_to_name(subtype), "Form")) { pdf_xobject *xobj; - error = pdf_loadxobject(&xobj, csi->xref, obj); + error = pdf_load_xobject(&xobj, csi->xref, obj); if (error) - return fz_rethrow(error, "cannot load xobject (%d %d R)", fz_tonum(obj), fz_togen(obj)); + return fz_rethrow(error, "cannot load xobject (%d %d R)", fz_to_num(obj), fz_to_gen(obj)); /* Inherit parent resources, in case this one was empty XXX check where it's loaded */ if (!xobj->resources) - xobj->resources = fz_keepobj(rdb); + xobj->resources = fz_keep_obj(rdb); - error = pdf_runxobject(csi, xobj->resources, xobj, fz_identity); + error = pdf_run_xobject(csi, xobj->resources, xobj, fz_identity); if (error) - return fz_rethrow(error, "cannot draw xobject (%d %d R)", fz_tonum(obj), fz_togen(obj)); + return fz_rethrow(error, "cannot draw xobject (%d %d R)", fz_to_num(obj), fz_to_gen(obj)); - pdf_dropxobject(xobj); + pdf_drop_xobject(xobj); } - else if (!strcmp(fz_toname(subtype), "Image")) + else if (!strcmp(fz_to_name(subtype), "Image")) { - if ((csi->dev->hints & FZ_IGNOREIMAGE) == 0) + if ((csi->dev->hints & FZ_IGNORE_IMAGE) == 0) { fz_pixmap *img; - error = pdf_loadimage(&img, csi->xref, obj); + error = pdf_load_image(&img, csi->xref, obj); if (error) - return fz_rethrow(error, "cannot load image (%d %d R)", fz_tonum(obj), fz_togen(obj)); - pdf_showimage(csi, img); - fz_droppixmap(img); + return fz_rethrow(error, "cannot load image (%d %d R)", fz_to_num(obj), fz_to_gen(obj)); + pdf_show_image(csi, img); + fz_drop_pixmap(img); } } - else if (!strcmp(fz_toname(subtype), "PS")) + else if (!strcmp(fz_to_name(subtype), "PS")) { fz_warn("ignoring XObject with subtype PS"); } else { - return fz_throw("unknown XObject subtype: '%s'", fz_toname(subtype)); + return fz_throw("unknown XObject subtype: '%s'", fz_to_name(subtype)); } return fz_okay; @@ -624,9 +624,9 @@ static void pdf_run_EMC(pdf_csi *csi) static void pdf_run_ET(pdf_csi *csi) { - pdf_flushtext(csi); + pdf_flush_text(csi); csi->accumulate = 1; - csi->intext = 0; + csi->in_text = 0; } static void pdf_run_EX(pdf_csi *csi) @@ -636,31 +636,31 @@ static void pdf_run_EX(pdf_csi *csi) static void pdf_run_F(pdf_csi *csi) { - pdf_showpath(csi, 0, 1, 0, 0); + pdf_show_path(csi, 0, 1, 0, 0); } static void pdf_run_G(pdf_csi *csi) { - pdf_setcolorspace(csi, PDF_MSTROKE, fz_devicegray); - pdf_setcolor(csi, PDF_MSTROKE, csi->stack); + pdf_set_colorspace(csi, PDF_STROKE, fz_device_gray); + pdf_set_color(csi, PDF_STROKE, csi->stack); } static void pdf_run_J(pdf_csi *csi) { pdf_gstate *gstate = csi->gstate + csi->gtop; - gstate->strokestate.linecap = csi->stack[0]; + gstate->stroke_state.linecap = csi->stack[0]; } static void pdf_run_K(pdf_csi *csi) { - pdf_setcolorspace(csi, PDF_MSTROKE, fz_devicecmyk); - pdf_setcolor(csi, PDF_MSTROKE, csi->stack); + pdf_set_colorspace(csi, PDF_STROKE, fz_device_cmyk); + pdf_set_color(csi, PDF_STROKE, csi->stack); } static void pdf_run_M(pdf_csi *csi) { pdf_gstate *gstate = csi->gstate + csi->gtop; - gstate->strokestate.miterlimit = csi->stack[0]; + gstate->stroke_state.miterlimit = csi->stack[0]; } static void pdf_run_MP(pdf_csi *csi) @@ -674,13 +674,13 @@ static void pdf_run_Q(pdf_csi *csi) static void pdf_run_RG(pdf_csi *csi) { - pdf_setcolorspace(csi, PDF_MSTROKE, fz_devicergb); - pdf_setcolor(csi, PDF_MSTROKE, csi->stack); + pdf_set_colorspace(csi, PDF_STROKE, fz_device_rgb); + pdf_set_color(csi, PDF_STROKE, csi->stack); } static void pdf_run_S(pdf_csi *csi) { - pdf_showpath(csi, 0, 0, 1, 0); + pdf_show_path(csi, 0, 0, 1, 0); } static fz_error pdf_run_SC_imp(pdf_csi *csi, fz_obj *rdb, int what, pdf_material *mat) @@ -693,53 +693,53 @@ static fz_error pdf_run_SC_imp(pdf_csi *csi, fz_obj *rdb, int what, pdf_material kind = mat->kind; if (csi->name[0]) - kind = PDF_MPATTERN; + kind = PDF_MAT_PATTERN; switch (kind) { - case PDF_MNONE: + case PDF_MAT_NONE: return fz_throw("cannot set color in mask objects"); - case PDF_MCOLOR: - pdf_setcolor(csi, what, csi->stack); + case PDF_MAT_COLOR: + pdf_set_color(csi, what, csi->stack); break; - case PDF_MPATTERN: - dict = fz_dictgets(rdb, "Pattern"); + case PDF_MAT_PATTERN: + dict = fz_dict_gets(rdb, "Pattern"); if (!dict) return fz_throw("cannot find Pattern dictionary"); - obj = fz_dictgets(dict, csi->name); + obj = fz_dict_gets(dict, csi->name); if (!obj) return fz_throw("cannot find pattern resource '%s'", csi->name); - patterntype = fz_dictgets(obj, "PatternType"); + patterntype = fz_dict_gets(obj, "PatternType"); - if (fz_toint(patterntype) == 1) + if (fz_to_int(patterntype) == 1) { pdf_pattern *pat; - error = pdf_loadpattern(&pat, csi->xref, obj); + error = pdf_load_pattern(&pat, csi->xref, obj); if (error) - return fz_rethrow(error, "cannot load pattern (%d 0 R)", fz_tonum(obj)); - pdf_setpattern(csi, what, pat, csi->top > 0 ? csi->stack : nil); - pdf_droppattern(pat); + return fz_rethrow(error, "cannot load pattern (%d 0 R)", fz_to_num(obj)); + pdf_set_pattern(csi, what, pat, csi->top > 0 ? csi->stack : NULL); + pdf_drop_pattern(pat); } - else if (fz_toint(patterntype) == 2) + else if (fz_to_int(patterntype) == 2) { fz_shade *shd; - error = pdf_loadshading(&shd, csi->xref, obj); + error = pdf_load_shading(&shd, csi->xref, obj); if (error) - return fz_rethrow(error, "cannot load shading (%d 0 R)", fz_tonum(obj)); - pdf_setshade(csi, what, shd); - fz_dropshade(shd); + return fz_rethrow(error, "cannot load shading (%d 0 R)", fz_to_num(obj)); + pdf_set_shade(csi, what, shd); + fz_drop_shade(shd); } else { - return fz_throw("unknown pattern type: %d", fz_toint(patterntype)); + return fz_throw("unknown pattern type: %d", fz_to_int(patterntype)); } break; - case PDF_MSHADE: + case PDF_MAT_SHADE: return fz_throw("cannot set color in shade objects"); } @@ -750,7 +750,7 @@ static void pdf_run_SC(pdf_csi *csi, fz_obj *rdb) { fz_error error; pdf_gstate *gstate = csi->gstate + csi->gtop; - error = pdf_run_SC_imp(csi, rdb, PDF_MSTROKE, &gstate->stroke); + error = pdf_run_SC_imp(csi, rdb, PDF_STROKE, &gstate->stroke); if (error) fz_catch(error, "cannot set color and colorspace"); } @@ -759,7 +759,7 @@ static void pdf_run_sc(pdf_csi *csi, fz_obj *rdb) { fz_error error; pdf_gstate *gstate = csi->gstate + csi->gtop; - error = pdf_run_SC_imp(csi, rdb, PDF_MFILL, &gstate->fill); + error = pdf_run_SC_imp(csi, rdb, PDF_FILL, &gstate->fill); if (error) fz_catch(error, "cannot set color and colorspace"); } @@ -767,20 +767,20 @@ static void pdf_run_sc(pdf_csi *csi, fz_obj *rdb) static void pdf_run_Tc(pdf_csi *csi) { pdf_gstate *gstate = csi->gstate + csi->gtop; - gstate->charspace = csi->stack[0]; + gstate->char_space = csi->stack[0]; } static void pdf_run_Tw(pdf_csi *csi) { pdf_gstate *gstate = csi->gstate + csi->gtop; - gstate->wordspace = csi->stack[0]; + gstate->word_space = csi->stack[0]; } static void pdf_run_Tz(pdf_csi *csi) { pdf_gstate *gstate = csi->gstate + csi->gtop; float a = csi->stack[0] / 100; - pdf_flushtext(csi); + pdf_flush_text(csi); gstate->scale = a; } @@ -799,20 +799,20 @@ static fz_error pdf_run_Tf(pdf_csi *csi, fz_obj *rdb) gstate->size = csi->stack[0]; if (gstate->font) - pdf_dropfont(gstate->font); - gstate->font = nil; + pdf_drop_font(gstate->font); + gstate->font = NULL; - dict = fz_dictgets(rdb, "Font"); + dict = fz_dict_gets(rdb, "Font"); if (!dict) return fz_throw("cannot find Font dictionary"); - obj = fz_dictgets(dict, csi->name); + obj = fz_dict_gets(dict, csi->name); if (!obj) return fz_throw("cannot find font resource: '%s'", csi->name); - error = pdf_loadfont(&gstate->font, csi->xref, rdb, obj); + error = pdf_load_font(&gstate->font, csi->xref, rdb, obj); if (error) - return fz_rethrow(error, "cannot load font (%d 0 R)", fz_tonum(obj)); + return fz_rethrow(error, "cannot load font (%d 0 R)", fz_to_num(obj)); return fz_okay; } @@ -849,7 +849,7 @@ static void pdf_run_TD(pdf_csi *csi) static void pdf_run_Tm(pdf_csi *csi) { - pdf_flushtext(csi); + pdf_flush_text(csi); csi->tm.a = csi->stack[0]; csi->tm.b = csi->stack[1]; csi->tm.c = csi->stack[2]; @@ -869,40 +869,40 @@ static void pdf_run_Tstar(pdf_csi *csi) static void pdf_run_Tj(pdf_csi *csi) { - if (csi->stringlen) - pdf_showstring(csi, csi->string, csi->stringlen); + if (csi->string_len) + pdf_show_string(csi, csi->string, csi->string_len); else - pdf_showtext(csi, csi->obj); + pdf_show_text(csi, csi->obj); } static void pdf_run_TJ(pdf_csi *csi) { - if (csi->stringlen) - pdf_showstring(csi, csi->string, csi->stringlen); + if (csi->string_len) + pdf_show_string(csi, csi->string, csi->string_len); else - pdf_showtext(csi, csi->obj); + pdf_show_text(csi, csi->obj); } static void pdf_run_W(pdf_csi *csi) { csi->clip = 1; - csi->clipevenodd = 0; + csi->clip_even_odd = 0; } static void pdf_run_Wstar(pdf_csi *csi) { csi->clip = 1; - csi->clipevenodd = 1; + csi->clip_even_odd = 1; } static void pdf_run_b(pdf_csi *csi) { - pdf_showpath(csi, 1, 1, 1, 0); + pdf_show_path(csi, 1, 1, 1, 0); } static void pdf_run_bstar(pdf_csi *csi) { - pdf_showpath(csi, 1, 1, 1, 1); + pdf_show_path(csi, 1, 1, 1, 1); } static void pdf_run_c(pdf_csi *csi) @@ -939,10 +939,10 @@ static void pdf_run_d(pdf_csi *csi) int i; array = csi->obj; - gstate->strokestate.dashlen = MIN(fz_arraylen(array), nelem(gstate->strokestate.dashlist)); - for (i = 0; i < gstate->strokestate.dashlen; i++) - gstate->strokestate.dashlist[i] = fz_toreal(fz_arrayget(array, i)); - gstate->strokestate.dashphase = csi->stack[0]; + gstate->stroke_state.dash_len = MIN(fz_array_len(array), nelem(gstate->stroke_state.dash_list)); + for (i = 0; i < gstate->stroke_state.dash_len; i++) + gstate->stroke_state.dash_list[i] = fz_to_real(fz_array_get(array, i)); + gstate->stroke_state.dash_phase = csi->stack[0]; } static void pdf_run_d0(pdf_csi *csi) @@ -955,18 +955,18 @@ static void pdf_run_d1(pdf_csi *csi) static void pdf_run_f(pdf_csi *csi) { - pdf_showpath(csi, 0, 1, 0, 0); + pdf_show_path(csi, 0, 1, 0, 0); } static void pdf_run_fstar(pdf_csi *csi) { - pdf_showpath(csi, 0, 1, 0, 1); + pdf_show_path(csi, 0, 1, 0, 1); } static void pdf_run_g(pdf_csi *csi) { - pdf_setcolorspace(csi, PDF_MFILL, fz_devicegray); - pdf_setcolor(csi, PDF_MFILL, csi->stack); + pdf_set_colorspace(csi, PDF_FILL, fz_device_gray); + pdf_set_color(csi, PDF_FILL, csi->stack); } static fz_error pdf_run_gs(pdf_csi *csi, fz_obj *rdb) @@ -975,17 +975,17 @@ static fz_error pdf_run_gs(pdf_csi *csi, fz_obj *rdb) fz_obj *dict; fz_obj *obj; - dict = fz_dictgets(rdb, "ExtGState"); + dict = fz_dict_gets(rdb, "ExtGState"); if (!dict) return fz_throw("cannot find ExtGState dictionary"); - obj = fz_dictgets(dict, csi->name); + obj = fz_dict_gets(dict, csi->name); if (!obj) return fz_throw("cannot find extgstate resource '%s'", csi->name); - error = pdf_runextgstate(csi, rdb, obj); + error = pdf_run_extgstate(csi, rdb, obj); if (error) - return fz_rethrow(error, "cannot set ExtGState (%d 0 R)", fz_tonum(obj)); + return fz_rethrow(error, "cannot set ExtGState (%d 0 R)", fz_to_num(obj)); return fz_okay; } @@ -1001,13 +1001,13 @@ static void pdf_run_i(pdf_csi *csi) static void pdf_run_j(pdf_csi *csi) { pdf_gstate *gstate = csi->gstate + csi->gtop; - gstate->strokestate.linejoin = csi->stack[0]; + gstate->stroke_state.linejoin = csi->stack[0]; } static void pdf_run_k(pdf_csi *csi) { - pdf_setcolorspace(csi, PDF_MFILL, fz_devicecmyk); - pdf_setcolor(csi, PDF_MFILL, csi->stack); + pdf_set_colorspace(csi, PDF_FILL, fz_device_cmyk); + pdf_set_color(csi, PDF_FILL, csi->stack); } static void pdf_run_l(pdf_csi *csi) @@ -1028,7 +1028,7 @@ static void pdf_run_m(pdf_csi *csi) static void pdf_run_n(pdf_csi *csi) { - pdf_showpath(csi, 0, 0, 0, csi->clipevenodd); + pdf_show_path(csi, 0, 0, 0, csi->clip_even_odd); } static void pdf_run_q(pdf_csi *csi) @@ -1054,17 +1054,17 @@ static void pdf_run_re(pdf_csi *csi) static void pdf_run_rg(pdf_csi *csi) { - pdf_setcolorspace(csi, PDF_MFILL, fz_devicergb); - pdf_setcolor(csi, PDF_MFILL, csi->stack); + pdf_set_colorspace(csi, PDF_FILL, fz_device_rgb); + pdf_set_color(csi, PDF_FILL, csi->stack); } static void pdf_run_ri(pdf_csi *csi) { } -static void pdf_run_s(pdf_csi *csi) +static void pdf_run(pdf_csi *csi) { - pdf_showpath(csi, 1, 0, 1, 0); + pdf_show_path(csi, 1, 0, 1, 0); } static fz_error pdf_run_sh(pdf_csi *csi, fz_obj *rdb) @@ -1074,21 +1074,21 @@ static fz_error pdf_run_sh(pdf_csi *csi, fz_obj *rdb) fz_shade *shd; fz_error error; - dict = fz_dictgets(rdb, "Shading"); + dict = fz_dict_gets(rdb, "Shading"); if (!dict) return fz_throw("cannot find shading dictionary"); - obj = fz_dictgets(dict, csi->name); + obj = fz_dict_gets(dict, csi->name); if (!obj) return fz_throw("cannot find shading resource: '%s'", csi->name); - if ((csi->dev->hints & FZ_IGNORESHADE) == 0) + if ((csi->dev->hints & FZ_IGNORE_SHADE) == 0) { - error = pdf_loadshading(&shd, csi->xref, obj); + error = pdf_load_shading(&shd, csi->xref, obj); if (error) - return fz_rethrow(error, "cannot load shading (%d %d R)", fz_tonum(obj), fz_togen(obj)); - pdf_showshade(csi, shd); - fz_dropshade(shd); + return fz_rethrow(error, "cannot load shading (%d %d R)", fz_to_num(obj), fz_to_gen(obj)); + pdf_show_shade(csi, shd); + fz_drop_shade(shd); } return fz_okay; } @@ -1106,7 +1106,7 @@ static void pdf_run_v(pdf_csi *csi) static void pdf_run_w(pdf_csi *csi) { pdf_gstate *gstate = csi->gstate + csi->gtop; - gstate->strokestate.linewidth = csi->stack[0]; + gstate->stroke_state.linewidth = csi->stack[0]; } static void pdf_run_y(pdf_csi *csi) @@ -1128,10 +1128,10 @@ static void pdf_run_squote(pdf_csi *csi) csi->tlm = fz_concat(m, csi->tlm); csi->tm = csi->tlm; - if (csi->stringlen) - pdf_showstring(csi, csi->string, csi->stringlen); + if (csi->string_len) + pdf_show_string(csi, csi->string, csi->string_len); else - pdf_showtext(csi, csi->obj); + pdf_show_text(csi, csi->obj); } static void pdf_run_dquote(pdf_csi *csi) @@ -1139,17 +1139,17 @@ static void pdf_run_dquote(pdf_csi *csi) fz_matrix m; pdf_gstate *gstate = csi->gstate + csi->gtop; - gstate->wordspace = csi->stack[0]; - gstate->charspace = csi->stack[1]; + gstate->word_space = csi->stack[0]; + gstate->char_space = csi->stack[1]; m = fz_translate(0, -gstate->leading); csi->tlm = fz_concat(m, csi->tlm); csi->tm = csi->tlm; - if (csi->stringlen) - pdf_showstring(csi, csi->string, csi->stringlen); + if (csi->string_len) + pdf_show_string(csi, csi->string, csi->string_len); else - pdf_showtext(csi, csi->obj); + pdf_show_text(csi, csi->obj); } #define A(a) (a) @@ -1157,7 +1157,7 @@ static void pdf_run_dquote(pdf_csi *csi) #define C(a,b,c) (a | b << 8 | c << 16) static fz_error -pdf_runkeyword(pdf_csi *csi, fz_obj *rdb, fz_stream *file, char *buf) +pdf_run_keyword(pdf_csi *csi, fz_obj *rdb, fz_stream *file, char *buf) { fz_error error; int key; @@ -1256,7 +1256,7 @@ pdf_runkeyword(pdf_csi *csi, fz_obj *rdb, fz_stream *file, char *buf) case B('r','e'): pdf_run_re(csi); break; case B('r','g'): pdf_run_rg(csi); break; case B('r','i'): pdf_run_ri(csi); break; - case A('s'): pdf_run_s(csi); break; + case A('s'): pdf_run(csi); break; case B('s','c'): pdf_run_sc(csi, rdb); break; case C('s','c','n'): pdf_run_sc(csi, rdb); break; case B('s','h'): @@ -1277,13 +1277,13 @@ pdf_runkeyword(pdf_csi *csi, fz_obj *rdb, fz_stream *file, char *buf) } static fz_error -pdf_runcsifile(pdf_csi *csi, fz_obj *rdb, fz_stream *file, char *buf, int buflen) +pdf_run_csi_file(pdf_csi *csi, fz_obj *rdb, fz_stream *file, char *buf, int buflen) { fz_error error; int tok; int len; - pdf_clearstack(csi); + pdf_clear_stack(csi); while (1) { @@ -1294,29 +1294,29 @@ pdf_runcsifile(pdf_csi *csi, fz_obj *rdb, fz_stream *file, char *buf, int buflen if (error) return fz_rethrow(error, "lexical error in content stream"); - if (csi->inarray) + if (csi->in_array) { - if (tok == PDF_TCARRAY) + if (tok == PDF_TOK_CLOSE_ARRAY) { - csi->inarray = 0; + csi->in_array = 0; } - else if (tok == PDF_TINT || tok == PDF_TREAL) + else if (tok == PDF_TOK_INT || tok == PDF_TOK_REAL) { pdf_gstate *gstate = csi->gstate + csi->gtop; - pdf_showspace(csi, -atof(buf) * gstate->size * 0.001f); + pdf_show_space(csi, -atof(buf) * gstate->size * 0.001f); } - else if (tok == PDF_TSTRING) + else if (tok == PDF_TOK_STRING) { - pdf_showstring(csi, (unsigned char *)buf, len); + pdf_show_string(csi, (unsigned char *)buf, len); } - else if (tok == PDF_TKEYWORD) + else if (tok == PDF_TOK_KEYWORD) { if (!strcmp(buf, "Tw") || !strcmp(buf, "Tc")) fz_warn("ignoring keyword '%s' inside array", buf); else return fz_throw("syntax error in array"); } - else if (tok == PDF_TEOF) + else if (tok == PDF_TOK_EOF) return fz_okay; else return fz_throw("syntax error in array"); @@ -1324,60 +1324,60 @@ pdf_runcsifile(pdf_csi *csi, fz_obj *rdb, fz_stream *file, char *buf, int buflen else switch (tok) { - case PDF_TENDSTREAM: - case PDF_TEOF: + case PDF_TOK_ENDSTREAM: + case PDF_TOK_EOF: return fz_okay; - case PDF_TOARRAY: - if (!csi->intext) + case PDF_TOK_OPEN_ARRAY: + if (!csi->in_text) { - error = pdf_parsearray(&csi->obj, csi->xref, file, buf, buflen); + error = pdf_parse_array(&csi->obj, csi->xref, file, buf, buflen); if (error) return fz_rethrow(error, "cannot parse array"); } else { - csi->inarray = 1; + csi->in_array = 1; } break; - case PDF_TODICT: - error = pdf_parsedict(&csi->obj, csi->xref, file, buf, buflen); + case PDF_TOK_OPEN_DICT: + error = pdf_parse_dict(&csi->obj, csi->xref, file, buf, buflen); if (error) return fz_rethrow(error, "cannot parse dictionary"); break; - case PDF_TNAME: + case PDF_TOK_NAME: fz_strlcpy(csi->name, buf, sizeof(csi->name)); break; - case PDF_TINT: + case PDF_TOK_INT: csi->stack[csi->top] = atoi(buf); csi->top ++; break; - case PDF_TREAL: + case PDF_TOK_REAL: csi->stack[csi->top] = atof(buf); csi->top ++; break; - case PDF_TSTRING: + case PDF_TOK_STRING: if (len <= sizeof(csi->string)) { memcpy(csi->string, buf, len); - csi->stringlen = len; + csi->string_len = len; } else { - csi->obj = fz_newstring(buf, len); + csi->obj = fz_new_string(buf, len); } break; - case PDF_TKEYWORD: - error = pdf_runkeyword(csi, rdb, file, buf); + case PDF_TOK_KEYWORD: + error = pdf_run_keyword(csi, rdb, file, buf); if (error) return fz_rethrow(error, "cannot run keyword"); - pdf_clearstack(csi); + pdf_clear_stack(csi); break; default: @@ -1387,12 +1387,12 @@ pdf_runcsifile(pdf_csi *csi, fz_obj *rdb, fz_stream *file, char *buf, int buflen } fz_error -pdf_runcsibuffer(pdf_csi *csi, fz_obj *rdb, fz_buffer *contents) +pdf_run_csi_buffer(pdf_csi *csi, fz_obj *rdb, fz_buffer *contents) { fz_stream *file; fz_error error; - file = fz_openbuffer(contents); - error = pdf_runcsifile(csi, rdb, file, csi->xref->scratch, sizeof csi->xref->scratch); + file = fz_open_buffer(contents); + error = pdf_run_csi_file(csi, rdb, file, csi->xref->scratch, sizeof csi->xref->scratch); fz_close(file); if (error) return fz_rethrow(error, "cannot parse content stream"); @@ -1400,7 +1400,7 @@ pdf_runcsibuffer(pdf_csi *csi, fz_obj *rdb, fz_buffer *contents) } fz_error -pdf_runpagewithtarget(pdf_xref *xref, pdf_page *page, fz_device *dev, fz_matrix ctm, char *target) +pdf_run_page_with_usage(pdf_xref *xref, pdf_page *page, fz_device *dev, fz_matrix ctm, char *target) { pdf_csi *csi; fz_error error; @@ -1408,19 +1408,19 @@ pdf_runpagewithtarget(pdf_xref *xref, pdf_page *page, fz_device *dev, fz_matrix int flags; if (page->transparency) - dev->begingroup(dev->user, - fz_transformrect(ctm, page->mediabox), - 0, 0, FZ_BNORMAL, 1); + dev->begin_group(dev->user, + fz_transform_rect(ctm, page->mediabox), + 0, 0, FZ_BLEND_NORMAL, 1); - csi = pdf_newcsi(xref, dev, ctm, target); - error = pdf_runcsibuffer(csi, page->resources, page->contents); - pdf_freecsi(csi); + csi = pdf_new_csi(xref, dev, ctm, target); + error = pdf_run_csi_buffer(csi, page->resources, page->contents); + pdf_free_csi(csi); if (error) return fz_rethrow(error, "cannot parse page content stream"); for (annot = page->annots; annot; annot = annot->next) { - flags = fz_toint(fz_dictgets(annot->obj, "F")); + flags = fz_to_int(fz_dict_gets(annot->obj, "F")); /* TODO: NoZoom and NoRotate */ if (flags & (1 << 0)) /* Invisible */ @@ -1430,34 +1430,34 @@ pdf_runpagewithtarget(pdf_xref *xref, pdf_page *page, fz_device *dev, fz_matrix if (flags & (1 << 5)) /* NoView */ continue; - if (pdf_ishiddenocg(csi, annot->obj)) + if (pdf_is_hidden_ocg(csi, annot->obj)) continue; - csi = pdf_newcsi(xref, dev, ctm, target); - error = pdf_runxobject(csi, page->resources, annot->ap, annot->matrix); - pdf_freecsi(csi); + csi = pdf_new_csi(xref, dev, ctm, target); + error = pdf_run_xobject(csi, page->resources, annot->ap, annot->matrix); + pdf_free_csi(csi); if (error) return fz_rethrow(error, "cannot parse annotation appearance stream"); } if (page->transparency) - dev->endgroup(dev->user); + dev->end_group(dev->user); return fz_okay; } fz_error -pdf_runpage(pdf_xref *xref, pdf_page *page, fz_device *dev, fz_matrix ctm) +pdf_run_page(pdf_xref *xref, pdf_page *page, fz_device *dev, fz_matrix ctm) { - return pdf_runpagewithtarget(xref, page, dev, ctm, "View"); + return pdf_run_page_with_usage(xref, page, dev, ctm, "View"); } fz_error -pdf_runglyph(pdf_xref *xref, fz_obj *resources, fz_buffer *contents, fz_device *dev, fz_matrix ctm) +pdf_run_glyph(pdf_xref *xref, fz_obj *resources, fz_buffer *contents, fz_device *dev, fz_matrix ctm) { - pdf_csi *csi = pdf_newcsi(xref, dev, ctm, "View"); - fz_error error = pdf_runcsibuffer(csi, resources, contents); - pdf_freecsi(csi); + pdf_csi *csi = pdf_new_csi(xref, dev, ctm, "View"); + fz_error error = pdf_run_csi_buffer(csi, resources, contents); + pdf_free_csi(csi); if (error) return fz_rethrow(error, "cannot parse glyph content stream"); return fz_okay; diff --git a/pdf/pdf_lex.c b/pdf/pdf_lex.c index 6b2f26e4..bb0e6e32 100644 --- a/pdf/pdf_lex.c +++ b/pdf/pdf_lex.c @@ -1,17 +1,17 @@ #include "fitz.h" #include "mupdf.h" -#define ISNUMBER \ +#define IS_NUMBER \ '+':case'-':case'.':case'0':case'1':case'2':case'3':\ case'4':case'5':case'6':case'7':case'8':case'9' -#define ISWHITE \ +#define IS_WHITE \ '\000':case'\011':case'\012':case'\014':case'\015':case'\040' -#define ISHEX \ +#define IS_HEX \ '0':case'1':case'2':case'3':case'4':case'5':case'6':\ case'7':case'8':case'9':case'A':case'B':case'C':\ case'D':case'E':case'F':case'a':case'b':case'c':\ case'd':case'e':case'f' -#define ISDELIM \ +#define IS_DELIM \ '(':case')':case'<':case'>':case'[':case']':case'{':\ case'}':case'/':case'%' @@ -36,7 +36,7 @@ iswhite(int ch) } static inline int -fromhex(int ch) +from_hex(int ch) { if (ch >= '0' && ch <= '9') return ch - '0'; @@ -48,43 +48,43 @@ fromhex(int ch) } static inline void -lexwhite(fz_stream *f) +lex_white(fz_stream *f) { int c; do { - c = fz_readbyte(f); + c = fz_read_byte(f); } while ((c <= 32) && (iswhite(c))); if (c != EOF) - fz_unreadbyte(f); + fz_unread_byte(f); } static inline void -lexcomment(fz_stream *f) +lex_comment(fz_stream *f) { int c; do { - c = fz_readbyte(f); + c = fz_read_byte(f); } while ((c != '\012') && (c != '\015') && (c != EOF)); } static int -lexnumber(fz_stream *f, char *s, int n, int *tok) +lex_number(fz_stream *f, char *s, int n, int *tok) { char *buf = s; - *tok = PDF_TINT; + *tok = PDF_TOK_INT; /* Initially we might have +, -, . or a digit */ if (n > 1) { - int c = fz_readbyte(f); + int c = fz_read_byte(f); switch (c) { case '.': - *tok = PDF_TREAL; + *tok = PDF_TOK_REAL; *s++ = c; n--; goto loop_after_dot; @@ -95,7 +95,7 @@ lexnumber(fz_stream *f, char *s, int n, int *tok) n--; goto loop_after_sign; default: - fz_unreadbyte(f); + fz_unread_byte(f); goto end; case EOF: goto end; @@ -106,11 +106,11 @@ lexnumber(fz_stream *f, char *s, int n, int *tok) loop_after_sign: while (n > 1) { - int c = fz_readbyte(f); + int c = fz_read_byte(f); switch (c) { case '.': - *tok = PDF_TREAL; + *tok = PDF_TOK_REAL; *s++ = c; n--; goto loop_after_dot; @@ -118,7 +118,7 @@ loop_after_sign: *s++ = c; break; default: - fz_unreadbyte(f); + fz_unread_byte(f); goto end; case EOF: goto end; @@ -130,14 +130,14 @@ loop_after_sign: loop_after_dot: while (n > 1) { - int c = fz_readbyte(f); + int c = fz_read_byte(f); switch (c) { case RANGE_0_9: *s++ = c; break; default: - fz_unreadbyte(f); + fz_unread_byte(f); goto end; case EOF: goto end; @@ -151,23 +151,23 @@ end: } static void -lexname(fz_stream *f, char *s, int n) +lex_name(fz_stream *f, char *s, int n) { while (n > 1) { - int c = fz_readbyte(f); + int c = fz_read_byte(f); switch (c) { - case ISWHITE: - case ISDELIM: - fz_unreadbyte(f); + case IS_WHITE: + case IS_DELIM: + fz_unread_byte(f); goto end; case EOF: goto end; case '#': { int d; - c = fz_readbyte(f); + c = fz_read_byte(f); switch (c) { case RANGE_0_9: @@ -180,12 +180,12 @@ lexname(fz_stream *f, char *s, int n) d = (c - 'A' + 10) << 4; break; default: - fz_unreadbyte(f); + fz_unread_byte(f); /* fallthrough */ case EOF: goto end; } - c = fz_readbyte(f); + c = fz_read_byte(f); switch (c) { case RANGE_0_9: @@ -198,7 +198,7 @@ lexname(fz_stream *f, char *s, int n) c -= 'A' - 10; break; default: - fz_unreadbyte(f); + fz_unread_byte(f); /* fallthrough */ case EOF: *s++ = d; @@ -220,7 +220,7 @@ end: } static int -lexstring(fz_stream *f, char *buf, int n) +lex_string(fz_stream *f, char *buf, int n) { char *s = buf; char *e = buf + n; @@ -230,7 +230,7 @@ lexstring(fz_stream *f, char *buf, int n) while (s < e) { - c = fz_readbyte(f); + c = fz_read_byte(f); switch (c) { case EOF: @@ -246,7 +246,7 @@ lexstring(fz_stream *f, char *buf, int n) *s++ = c; break; case '\\': - c = fz_readbyte(f); + c = fz_read_byte(f); switch (c) { case EOF: @@ -277,26 +277,26 @@ lexstring(fz_stream *f, char *buf, int n) break; case RANGE_0_9: oct = c - '0'; - c = fz_readbyte(f); + c = fz_read_byte(f); if (c >= '0' && c <= '9') { oct = oct * 8 + (c - '0'); - c = fz_readbyte(f); + c = fz_read_byte(f); if (c >= '0' && c <= '9') oct = oct * 8 + (c - '0'); else if (c != EOF) - fz_unreadbyte(f); + fz_unread_byte(f); } else if (c != EOF) - fz_unreadbyte(f); + fz_unread_byte(f); *s++ = oct; break; case '\n': break; case '\r': - c = fz_readbyte(f); + c = fz_read_byte(f); if ((c != '\n') && (c != EOF)) - fz_unreadbyte(f); + fz_unread_byte(f); break; default: *s++ = c; @@ -312,7 +312,7 @@ end: } static int -lexhexstring(fz_stream *f, char *buf, int n) +lex_hex_string(fz_stream *f, char *buf, int n) { char *s = buf; char *e = buf + n; @@ -321,20 +321,20 @@ lexhexstring(fz_stream *f, char *buf, int n) while (s < e) { - c = fz_readbyte(f); + c = fz_read_byte(f); switch (c) { - case ISWHITE: + case IS_WHITE: break; - case ISHEX: + case IS_HEX: if (x) { - *s++ = a * 16 + fromhex(c); + *s++ = a * 16 + from_hex(c); x = !x; } else { - a = fromhex(c); + a = from_hex(c); x = !x; } break; @@ -348,42 +348,42 @@ end: } static int -pdf_tokenfromkeyword(char *key) +pdf_token_from_keyword(char *key) { switch (*key) { case 'R': - if (!strcmp(key, "R")) return PDF_TR; + if (!strcmp(key, "R")) return PDF_TOK_R; break; case 't': - if (!strcmp(key, "true")) return PDF_TTRUE; - if (!strcmp(key, "trailer")) return PDF_TTRAILER; + if (!strcmp(key, "true")) return PDF_TOK_TRUE; + if (!strcmp(key, "trailer")) return PDF_TOK_TRAILER; break; case 'f': - if (!strcmp(key, "false")) return PDF_TFALSE; + if (!strcmp(key, "false")) return PDF_TOK_FALSE; break; case 'n': - if (!strcmp(key, "null")) return PDF_TNULL; + if (!strcmp(key, "null")) return PDF_TOK_NULL; break; case 'o': - if (!strcmp(key, "obj")) return PDF_TOBJ; + if (!strcmp(key, "obj")) return PDF_TOK_OBJ; break; case 'e': - if (!strcmp(key, "endobj")) return PDF_TENDOBJ; - if (!strcmp(key, "endstream")) return PDF_TENDSTREAM; + if (!strcmp(key, "endobj")) return PDF_TOK_ENDOBJ; + if (!strcmp(key, "endstream")) return PDF_TOK_ENDSTREAM; break; case 's': - if (!strcmp(key, "stream")) return PDF_TSTREAM; - if (!strcmp(key, "startxref")) return PDF_TSTARTXREF; + if (!strcmp(key, "stream")) return PDF_TOK_STREAM; + if (!strcmp(key, "startxref")) return PDF_TOK_STARTXREF; break; case 'x': - if (!strcmp(key, "xref")) return PDF_TXREF; + if (!strcmp(key, "xref")) return PDF_TOK_XREF; break; default: break; } - return PDF_TKEYWORD; + return PDF_TOK_KEYWORD; } fz_error @@ -391,78 +391,78 @@ pdf_lex(int *tok, fz_stream *f, char *buf, int n, int *sl) { while (1) { - int c = fz_readbyte(f); + int c = fz_read_byte(f); switch (c) { case EOF: - *tok = PDF_TEOF; + *tok = PDF_TOK_EOF; return fz_okay; - case ISWHITE: - lexwhite(f); + case IS_WHITE: + lex_white(f); break; case '%': - lexcomment(f); + lex_comment(f); break; case '/': - lexname(f, buf, n); + lex_name(f, buf, n); *sl = strlen(buf); - *tok = PDF_TNAME; + *tok = PDF_TOK_NAME; return fz_okay; case '(': - *sl = lexstring(f, buf, n); - *tok = PDF_TSTRING; + *sl = lex_string(f, buf, n); + *tok = PDF_TOK_STRING; return fz_okay; case ')': - *tok = PDF_TERROR; + *tok = PDF_TOK_ERROR; goto cleanuperror; case '<': - c = fz_readbyte(f); + c = fz_read_byte(f); if (c == '<') { - *tok = PDF_TODICT; + *tok = PDF_TOK_OPEN_DICT; } else { - fz_unreadbyte(f); - *sl = lexhexstring(f, buf, n); - *tok = PDF_TSTRING; + fz_unread_byte(f); + *sl = lex_hex_string(f, buf, n); + *tok = PDF_TOK_STRING; } return fz_okay; case '>': - c = fz_readbyte(f); + c = fz_read_byte(f); if (c == '>') { - *tok = PDF_TCDICT; + *tok = PDF_TOK_CLOSE_DICT; return fz_okay; } - *tok = PDF_TERROR; + *tok = PDF_TOK_ERROR; goto cleanuperror; case '[': - *tok = PDF_TOARRAY; + *tok = PDF_TOK_OPEN_ARRAY; return fz_okay; case ']': - *tok = PDF_TCARRAY; + *tok = PDF_TOK_CLOSE_ARRAY; return fz_okay; case '{': - *tok = PDF_TOBRACE; + *tok = PDF_TOK_OPEN_BRACE; return fz_okay; case '}': - *tok = PDF_TCBRACE; + *tok = PDF_TOK_CLOSE_BRACE; return fz_okay; - case ISNUMBER: - fz_unreadbyte(f); - *sl = lexnumber(f, buf, n, tok); + case IS_NUMBER: + fz_unread_byte(f); + *sl = lex_number(f, buf, n, tok); return fz_okay; default: /* isregular: !isdelim && !iswhite && c != EOF */ - fz_unreadbyte(f); - lexname(f, buf, n); + fz_unread_byte(f); + lex_name(f, buf, n); *sl = strlen(buf); - *tok = pdf_tokenfromkeyword(buf); + *tok = pdf_token_from_keyword(buf); return fz_okay; } } cleanuperror: - *tok = PDF_TERROR; + *tok = PDF_TOK_ERROR; return fz_throw("lexical error"); } diff --git a/pdf/pdf_nametree.c b/pdf/pdf_nametree.c index 6b2314cd..e2b3e160 100644 --- a/pdf/pdf_nametree.c +++ b/pdf/pdf_nametree.c @@ -2,44 +2,44 @@ #include "mupdf.h" static fz_obj * -pdf_lookupnameimp(fz_obj *node, fz_obj *needle) +pdf_lookup_name_imp(fz_obj *node, fz_obj *needle) { - fz_obj *kids = fz_dictgets(node, "Kids"); - fz_obj *names = fz_dictgets(node, "Names"); + fz_obj *kids = fz_dict_gets(node, "Kids"); + fz_obj *names = fz_dict_gets(node, "Names"); - if (fz_isarray(kids)) + if (fz_is_array(kids)) { int l = 0; - int r = fz_arraylen(kids) - 1; + int r = fz_array_len(kids) - 1; while (l <= r) { int m = (l + r) >> 1; - fz_obj *kid = fz_arrayget(kids, m); - fz_obj *limits = fz_dictgets(kid, "Limits"); - fz_obj *first = fz_arrayget(limits, 0); - fz_obj *last = fz_arrayget(limits, 1); + fz_obj *kid = fz_array_get(kids, m); + fz_obj *limits = fz_dict_gets(kid, "Limits"); + fz_obj *first = fz_array_get(limits, 0); + fz_obj *last = fz_array_get(limits, 1); if (fz_objcmp(needle, first) < 0) r = m - 1; else if (fz_objcmp(needle, last) > 0) l = m + 1; else - return pdf_lookupnameimp(kid, needle); + return pdf_lookup_name_imp(kid, needle); } } - if (fz_isarray(names)) + if (fz_is_array(names)) { int l = 0; - int r = (fz_arraylen(names) / 2) - 1; + int r = (fz_array_len(names) / 2) - 1; while (l <= r) { int m = (l + r) >> 1; int c; - fz_obj *key = fz_arrayget(names, m * 2); - fz_obj *val = fz_arrayget(names, m * 2 + 1); + fz_obj *key = fz_array_get(names, m * 2); + fz_obj *val = fz_array_get(names, m * 2 + 1); c = fz_objcmp(needle, key); if (c < 0) @@ -51,89 +51,89 @@ pdf_lookupnameimp(fz_obj *node, fz_obj *needle) } } - return nil; + return NULL; } fz_obj * -pdf_lookupname(pdf_xref *xref, char *which, fz_obj *needle) +pdf_lookup_name(pdf_xref *xref, char *which, fz_obj *needle) { - fz_obj *root = fz_dictgets(xref->trailer, "Root"); - fz_obj *names = fz_dictgets(root, "Names"); - fz_obj *tree = fz_dictgets(names, which); - return pdf_lookupnameimp(tree, needle); + fz_obj *root = fz_dict_gets(xref->trailer, "Root"); + fz_obj *names = fz_dict_gets(root, "Names"); + fz_obj *tree = fz_dict_gets(names, which); + return pdf_lookup_name_imp(tree, needle); } fz_obj * -pdf_lookupdest(pdf_xref *xref, fz_obj *needle) +pdf_lookup_dest(pdf_xref *xref, fz_obj *needle) { - fz_obj *root = fz_dictgets(xref->trailer, "Root"); - fz_obj *dests = fz_dictgets(root, "Dests"); - fz_obj *names = fz_dictgets(root, "Names"); - fz_obj *dest = nil; + fz_obj *root = fz_dict_gets(xref->trailer, "Root"); + fz_obj *dests = fz_dict_gets(root, "Dests"); + fz_obj *names = fz_dict_gets(root, "Names"); + fz_obj *dest = NULL; /* PDF 1.1 has destinations in a dictionary */ if (dests) { - if (fz_isname(needle)) - return fz_dictget(dests, needle); + if (fz_is_name(needle)) + return fz_dict_get(dests, needle); else - return fz_dictgets(dests, fz_tostrbuf(needle)); + return fz_dict_gets(dests, fz_to_str_buf(needle)); } /* PDF 1.2 has destinations in a name tree */ if (names && !dest) { - fz_obj *tree = fz_dictgets(names, "Dests"); - return pdf_lookupnameimp(tree, needle); + fz_obj *tree = fz_dict_gets(names, "Dests"); + return pdf_lookup_name_imp(tree, needle); } - return nil; + return NULL; } static void -pdf_loadnametreeimp(fz_obj *dict, pdf_xref *xref, fz_obj *node) +pdf_load_name_tree_imp(fz_obj *dict, pdf_xref *xref, fz_obj *node) { - fz_obj *kids = fz_dictgets(node, "Kids"); - fz_obj *names = fz_dictgets(node, "Names"); + fz_obj *kids = fz_dict_gets(node, "Kids"); + fz_obj *names = fz_dict_gets(node, "Names"); int i; if (kids) { - for (i = 0; i < fz_arraylen(kids); i++) - pdf_loadnametreeimp(dict, xref, fz_arrayget(kids, i)); + for (i = 0; i < fz_array_len(kids); i++) + pdf_load_name_tree_imp(dict, xref, fz_array_get(kids, i)); } if (names) { - for (i = 0; i + 1 < fz_arraylen(names); i += 2) + for (i = 0; i + 1 < fz_array_len(names); i += 2) { - fz_obj *key = fz_arrayget(names, i); - fz_obj *val = fz_arrayget(names, i + 1); - if (fz_isstring(key)) + fz_obj *key = fz_array_get(names, i); + fz_obj *val = fz_array_get(names, i + 1); + if (fz_is_string(key)) { - key = pdf_toutf8name(key); - fz_dictput(dict, key, val); - fz_dropobj(key); + key = pdf_to_utf8_name(key); + fz_dict_put(dict, key, val); + fz_drop_obj(key); } - else if (fz_isname(key)) + else if (fz_is_name(key)) { - fz_dictput(dict, key, val); + fz_dict_put(dict, key, val); } } } } fz_obj * -pdf_loadnametree(pdf_xref *xref, char *which) +pdf_load_name_tree(pdf_xref *xref, char *which) { - fz_obj *root = fz_dictgets(xref->trailer, "Root"); - fz_obj *names = fz_dictgets(root, "Names"); - fz_obj *tree = fz_dictgets(names, which); - if (fz_isdict(tree)) + fz_obj *root = fz_dict_gets(xref->trailer, "Root"); + fz_obj *names = fz_dict_gets(root, "Names"); + fz_obj *tree = fz_dict_gets(names, which); + if (fz_is_dict(tree)) { - fz_obj *dict = fz_newdict(100); - pdf_loadnametreeimp(dict, xref, tree); + fz_obj *dict = fz_new_dict(100); + pdf_load_name_tree_imp(dict, xref, tree); return dict; } - return nil; + return NULL; } diff --git a/pdf/pdf_outline.c b/pdf/pdf_outline.c index b211060f..829bfa8b 100644 --- a/pdf/pdf_outline.c +++ b/pdf/pdf_outline.c @@ -2,97 +2,97 @@ #include "mupdf.h" static pdf_outline * -pdf_loadoutlineimp(pdf_xref *xref, fz_obj *dict) +pdf_load_outline_imp(pdf_xref *xref, fz_obj *dict) { pdf_outline *node; fz_obj *obj; - if (fz_isnull(dict)) - return nil; + if (fz_is_null(dict)) + return NULL; node = fz_malloc(sizeof(pdf_outline)); - node->title = nil; - node->link = nil; - node->child = nil; - node->next = nil; + node->title = NULL; + node->link = NULL; + node->child = NULL; + node->next = NULL; node->count = 0; - pdf_logpage("load outline {\n"); + pdf_log_page("load outline {\n"); - obj = fz_dictgets(dict, "Title"); + obj = fz_dict_gets(dict, "Title"); if (obj) { - node->title = pdf_toutf8(obj); - pdf_logpage("title %s\n", node->title); + node->title = pdf_to_utf8(obj); + pdf_log_page("title %s\n", node->title); } - obj = fz_dictgets(dict, "Count"); + obj = fz_dict_gets(dict, "Count"); if (obj) { - node->count = fz_toint(obj); + node->count = fz_to_int(obj); } - if (fz_dictgets(dict, "Dest") || fz_dictgets(dict, "A")) + if (fz_dict_gets(dict, "Dest") || fz_dict_gets(dict, "A")) { - node->link = pdf_loadlink(xref, dict); + node->link = pdf_load_link(xref, dict); } - obj = fz_dictgets(dict, "First"); + obj = fz_dict_gets(dict, "First"); if (obj) { - node->child = pdf_loadoutlineimp(xref, obj); + node->child = pdf_load_outline_imp(xref, obj); } - pdf_logpage("}\n"); + pdf_log_page("}\n"); - obj = fz_dictgets(dict, "Next"); + obj = fz_dict_gets(dict, "Next"); if (obj) { - node->next = pdf_loadoutlineimp(xref, obj); + node->next = pdf_load_outline_imp(xref, obj); } return node; } pdf_outline * -pdf_loadoutline(pdf_xref *xref) +pdf_load_outline(pdf_xref *xref) { pdf_outline *node; fz_obj *root, *obj, *first; - pdf_logpage("load outlines {\n"); + pdf_log_page("load outlines {\n"); - node = nil; + node = NULL; - root = fz_dictgets(xref->trailer, "Root"); - obj = fz_dictgets(root, "Outlines"); + root = fz_dict_gets(xref->trailer, "Root"); + obj = fz_dict_gets(root, "Outlines"); if (obj) { - first = fz_dictgets(obj, "First"); + first = fz_dict_gets(obj, "First"); if (first) - node = pdf_loadoutlineimp(xref, first); + node = pdf_load_outline_imp(xref, first); } - pdf_logpage("}\n"); + pdf_log_page("}\n"); return node; } void -pdf_freeoutline(pdf_outline *outline) +pdf_free_outline(pdf_outline *outline) { if (outline->child) - pdf_freeoutline(outline->child); + pdf_free_outline(outline->child); if (outline->next) - pdf_freeoutline(outline->next); + pdf_free_outline(outline->next); if (outline->link) - pdf_freelink(outline->link); + pdf_free_link(outline->link); fz_free(outline->title); fz_free(outline); } void -pdf_debugoutline(pdf_outline *outline, int level) +pdf_debug_outline(pdf_outline *outline, int level) { int i; while (outline) @@ -103,15 +103,15 @@ pdf_debugoutline(pdf_outline *outline, int level) if (outline->title) printf("%s ", outline->title); else - printf(" "); + printf(" "); if (outline->link) - fz_debugobj(outline->link->dest); + fz_debug_obj(outline->link->dest); else - printf("\n"); + printf("\n"); if (outline->child) - pdf_debugoutline(outline->child, level + 2); + pdf_debug_outline(outline->child, level + 2); outline = outline->next; } diff --git a/pdf/pdf_page.c b/pdf/pdf_page.c index 869f7a5c..685ec3ae 100644 --- a/pdf/pdf_page.c +++ b/pdf/pdf_page.c @@ -4,36 +4,36 @@ /* we need to combine all sub-streams into one for the content stream interpreter */ static fz_error -pdf_loadpagecontentsarray(fz_buffer **bigbufp, pdf_xref *xref, fz_obj *list) +pdf_load_page_contents_array(fz_buffer **bigbufp, pdf_xref *xref, fz_obj *list) { fz_error error; fz_buffer *big; fz_buffer *one; int i; - pdf_logpage("multiple content streams: %d\n", fz_arraylen(list)); + pdf_log_page("multiple content streams: %d\n", fz_array_len(list)); /* TODO: openstream, read, close into big buffer at once */ - big = fz_newbuffer(32 * 1024); + big = fz_new_buffer(32 * 1024); - for (i = 0; i < fz_arraylen(list); i++) + for (i = 0; i < fz_array_len(list); i++) { - fz_obj *stm = fz_arrayget(list, i); - error = pdf_loadstream(&one, xref, fz_tonum(stm), fz_togen(stm)); + fz_obj *stm = fz_array_get(list, i); + error = pdf_load_stream(&one, xref, fz_to_num(stm), fz_to_gen(stm)); if (error) { - fz_dropbuffer(big); - return fz_rethrow(error, "cannot load content stream part %d/%d (%d %d R)", i + 1, fz_arraylen(list), fz_tonum(stm), fz_togen(stm)); + fz_drop_buffer(big); + return fz_rethrow(error, "cannot load content stream part %d/%d (%d %d R)", i + 1, fz_array_len(list), fz_to_num(stm), fz_to_gen(stm)); } if (big->len + one->len + 1 > big->cap) - fz_resizebuffer(big, big->len + one->len + 1); + fz_resize_buffer(big, big->len + one->len + 1); memcpy(big->data + big->len, one->data, one->len); big->data[big->len + one->len] = ' '; big->len += one->len + 1; - fz_dropbuffer(one); + fz_drop_buffer(one); } *bigbufp = big; @@ -41,26 +41,26 @@ pdf_loadpagecontentsarray(fz_buffer **bigbufp, pdf_xref *xref, fz_obj *list) } static fz_error -pdf_loadpagecontents(fz_buffer **bufp, pdf_xref *xref, fz_obj *obj) +pdf_load_page_contents(fz_buffer **bufp, pdf_xref *xref, fz_obj *obj) { fz_error error; - if (fz_isarray(obj)) + if (fz_is_array(obj)) { - error = pdf_loadpagecontentsarray(bufp, xref, obj); + error = pdf_load_page_contents_array(bufp, xref, obj); if (error) - return fz_rethrow(error, "cannot load content stream array (%d 0 R)", fz_tonum(obj)); + return fz_rethrow(error, "cannot load content stream array (%d 0 R)", fz_to_num(obj)); } - else if (pdf_isstream(xref, fz_tonum(obj), fz_togen(obj))) + else if (pdf_is_stream(xref, fz_to_num(obj), fz_to_gen(obj))) { - error = pdf_loadstream(bufp, xref, fz_tonum(obj), fz_togen(obj)); + error = pdf_load_stream(bufp, xref, fz_to_num(obj), fz_to_gen(obj)); if (error) - return fz_rethrow(error, "cannot load content stream (%d 0 R)", fz_tonum(obj)); + return fz_rethrow(error, "cannot load content stream (%d 0 R)", fz_to_num(obj)); } else { fz_warn("page contents missing, leaving page blank"); - *bufp = fz_newbuffer(0); + *bufp = fz_new_buffer(0); } return fz_okay; @@ -68,112 +68,112 @@ pdf_loadpagecontents(fz_buffer **bufp, pdf_xref *xref, fz_obj *obj) /* We need to know whether to install a page-level transparency group */ -static int pdf_resourcesuseblending(fz_obj *rdb); +static int pdf_resources_use_blending(fz_obj *rdb); static int -pdf_extgstateusesblending(fz_obj *dict) +pdf_extgstate_uses_blending(fz_obj *dict) { fz_obj *obj; - obj = fz_dictgets(dict, "BM"); - if (fz_isname(obj) && strcmp(fz_toname(obj), "Normal")) + obj = fz_dict_gets(dict, "BM"); + if (fz_is_name(obj) && strcmp(fz_to_name(obj), "Normal")) return 1; return 0; } static int -pdf_patternusesblending(fz_obj *dict) +pdf_pattern_uses_blending(fz_obj *dict) { fz_obj *obj; - obj = fz_dictgets(dict, "Resources"); - if (fz_isdict(obj) && pdf_resourcesuseblending(obj)) + obj = fz_dict_gets(dict, "Resources"); + if (fz_is_dict(obj) && pdf_resources_use_blending(obj)) return 1; - obj = fz_dictgets(dict, "ExtGState"); - if (fz_isdict(obj) && pdf_extgstateusesblending(obj)) + obj = fz_dict_gets(dict, "ExtGState"); + if (fz_is_dict(obj) && pdf_extgstate_uses_blending(obj)) return 1; return 0; } static int -pdf_xobjectusesblending(fz_obj *dict) +pdf_xobject_uses_blending(fz_obj *dict) { fz_obj *obj; - obj = fz_dictgets(dict, "Resources"); - if (fz_isdict(obj) && pdf_resourcesuseblending(obj)) + obj = fz_dict_gets(dict, "Resources"); + if (fz_is_dict(obj) && pdf_resources_use_blending(obj)) return 1; return 0; } static int -pdf_resourcesuseblending(fz_obj *rdb) +pdf_resources_use_blending(fz_obj *rdb) { fz_obj *dict; fz_obj *tmp; int i; /* stop on cyclic resource dependencies */ - if (fz_dictgets(rdb, ".useBM")) - return fz_tobool(fz_dictgets(rdb, ".useBM")); + if (fz_dict_gets(rdb, ".useBM")) + return fz_to_bool(fz_dict_gets(rdb, ".useBM")); - tmp = fz_newbool(0); - fz_dictputs(rdb, ".useBM", tmp); - fz_dropobj(tmp); + tmp = fz_new_bool(0); + fz_dict_puts(rdb, ".useBM", tmp); + fz_drop_obj(tmp); - dict = fz_dictgets(rdb, "ExtGState"); - for (i = 0; i < fz_dictlen(dict); i++) - if (pdf_extgstateusesblending(fz_dictgetval(dict, i))) + dict = fz_dict_gets(rdb, "ExtGState"); + for (i = 0; i < fz_dict_len(dict); i++) + if (pdf_extgstate_uses_blending(fz_dict_get_val(dict, i))) goto found; - dict = fz_dictgets(rdb, "Pattern"); - for (i = 0; i < fz_dictlen(dict); i++) - if (pdf_patternusesblending(fz_dictgetval(dict, i))) + dict = fz_dict_gets(rdb, "Pattern"); + for (i = 0; i < fz_dict_len(dict); i++) + if (pdf_pattern_uses_blending(fz_dict_get_val(dict, i))) goto found; - dict = fz_dictgets(rdb, "XObject"); - for (i = 0; i < fz_dictlen(dict); i++) - if (pdf_xobjectusesblending(fz_dictgetval(dict, i))) + dict = fz_dict_gets(rdb, "XObject"); + for (i = 0; i < fz_dict_len(dict); i++) + if (pdf_xobject_uses_blending(fz_dict_get_val(dict, i))) goto found; return 0; found: - tmp = fz_newbool(1); - fz_dictputs(rdb, ".useBM", tmp); - fz_dropobj(tmp); + tmp = fz_new_bool(1); + fz_dict_puts(rdb, ".useBM", tmp); + fz_drop_obj(tmp); return 1; } fz_error -pdf_loadpage(pdf_page **pagep, pdf_xref *xref, fz_obj *dict) +pdf_load_page(pdf_page **pagep, pdf_xref *xref, fz_obj *dict) { fz_error error; pdf_page *page; fz_obj *obj; fz_bbox bbox; - pdf_logpage("load page {\n"); + pdf_log_page("load page {\n"); // TODO: move this to a more appropriate place /* Ensure that we have a store for resource objects */ if (!xref->store) - xref->store = pdf_newstore(); + xref->store = pdf_new_store(); page = fz_malloc(sizeof(pdf_page)); - page->resources = nil; - page->contents = nil; + page->resources = NULL; + page->contents = NULL; page->transparency = 0; - page->links = nil; - page->annots = nil; + page->links = NULL; + page->annots = NULL; - obj = fz_dictgets(dict, "MediaBox"); - bbox = fz_roundrect(pdf_torect(obj)); - if (fz_isemptyrect(pdf_torect(obj))) + obj = fz_dict_gets(dict, "MediaBox"); + bbox = fz_round_rect(pdf_to_rect(obj)); + if (fz_is_empty_rect(pdf_to_rect(obj))) { fz_warn("cannot find page bounds, guessing page bounds."); bbox.x0 = 0; @@ -182,11 +182,11 @@ pdf_loadpage(pdf_page **pagep, pdf_xref *xref, fz_obj *dict) bbox.y1 = 792; } - obj = fz_dictgets(dict, "CropBox"); - if (fz_isarray(obj)) + obj = fz_dict_gets(dict, "CropBox"); + if (fz_is_array(obj)) { - fz_bbox cropbox = fz_roundrect(pdf_torect(obj)); - bbox = fz_intersectbbox(bbox, cropbox); + fz_bbox cropbox = fz_round_rect(pdf_to_rect(obj)); + bbox = fz_intersect_bbox(bbox, cropbox); } page->mediabox.x0 = MIN(bbox.x0, bbox.x1); @@ -197,50 +197,50 @@ pdf_loadpage(pdf_page **pagep, pdf_xref *xref, fz_obj *dict) if (page->mediabox.x1 - page->mediabox.x0 < 1 || page->mediabox.y1 - page->mediabox.y0 < 1) return fz_throw("invalid page size"); - page->rotate = fz_toint(fz_dictgets(dict, "Rotate")); + page->rotate = fz_to_int(fz_dict_gets(dict, "Rotate")); - pdf_logpage("bbox [%d %d %d %d]\n", bbox.x0, bbox.y0, bbox.x1, bbox.y1); - pdf_logpage("rotate %d\n", page->rotate); + pdf_log_page("bbox [%d %d %d %d]\n", bbox.x0, bbox.y0, bbox.x1, bbox.y1); + pdf_log_page("rotate %d\n", page->rotate); - obj = fz_dictgets(dict, "Annots"); + obj = fz_dict_gets(dict, "Annots"); if (obj) { - pdf_loadlinks(&page->links, xref, obj); - pdf_loadannots(&page->annots, xref, obj); + pdf_load_links(&page->links, xref, obj); + pdf_load_annots(&page->annots, xref, obj); } - page->resources = fz_dictgets(dict, "Resources"); + page->resources = fz_dict_gets(dict, "Resources"); if (page->resources) - fz_keepobj(page->resources); + fz_keep_obj(page->resources); - obj = fz_dictgets(dict, "Contents"); - error = pdf_loadpagecontents(&page->contents, xref, obj); + obj = fz_dict_gets(dict, "Contents"); + error = pdf_load_page_contents(&page->contents, xref, obj); if (error) { - pdf_freepage(page); - return fz_rethrow(error, "cannot load page contents (%d %d R)", fz_tonum(obj), fz_togen(obj)); + pdf_free_page(page); + return fz_rethrow(error, "cannot load page contents (%d %d R)", fz_to_num(obj), fz_to_gen(obj)); } - if (page->resources && pdf_resourcesuseblending(page->resources)) + if (page->resources && pdf_resources_use_blending(page->resources)) page->transparency = 1; - pdf_logpage("} %p\n", page); + pdf_log_page("} %p\n", page); *pagep = page; return fz_okay; } void -pdf_freepage(pdf_page *page) +pdf_free_page(pdf_page *page) { - pdf_logpage("drop page %p\n", page); + pdf_log_page("drop page %p\n", page); if (page->resources) - fz_dropobj(page->resources); + fz_drop_obj(page->resources); if (page->contents) - fz_dropbuffer(page->contents); + fz_drop_buffer(page->contents); if (page->links) - pdf_freelink(page->links); + pdf_free_link(page->links); if (page->annots) - pdf_freeannot(page->annots); + pdf_free_annot(page->annots); fz_free(page); } diff --git a/pdf/pdf_pagetree.c b/pdf/pdf_pagetree.c index df3c8b8a..9320bb9c 100644 --- a/pdf/pdf_pagetree.c +++ b/pdf/pdf_pagetree.c @@ -10,132 +10,132 @@ struct info }; int -pdf_getpagecount(pdf_xref *xref) +pdf_get_page_count(pdf_xref *xref) { - return xref->pagelen; + return xref->page_len; } fz_obj * -pdf_getpageobject(pdf_xref *xref, int number) +pdf_get_page_object(pdf_xref *xref, int number) { - if (number > 0 && number <= xref->pagelen) - return xref->pageobjs[number - 1]; - return nil; + if (number > 0 && number <= xref->page_len) + return xref->page_objs[number - 1]; + return NULL; } fz_obj * -pdf_getpageref(pdf_xref *xref, int number) +pdf_get_page_ref(pdf_xref *xref, int number) { - if (number > 0 && number <= xref->pagelen) - return xref->pagerefs[number - 1]; - return nil; + if (number > 0 && number <= xref->page_len) + return xref->page_refs[number - 1]; + return NULL; } int -pdf_findpageobject(pdf_xref *xref, fz_obj *page) +pdf_find_page_object(pdf_xref *xref, fz_obj *page) { - int num = fz_tonum(page); - int gen = fz_togen(page); + int num = fz_to_num(page); + int gen = fz_to_gen(page); int i; - for (i = 0; i < xref->pagelen; i++) - if (num == fz_tonum(xref->pagerefs[i]) && gen == fz_togen(xref->pagerefs[i])) + for (i = 0; i < xref->page_len; i++) + if (num == fz_to_num(xref->page_refs[i]) && gen == fz_to_gen(xref->page_refs[i])) return i + 1; return 0; } static void -pdf_loadpagetreenode(pdf_xref *xref, fz_obj *node, struct info info) +pdf_load_page_tree_node(pdf_xref *xref, fz_obj *node, struct info info) { fz_obj *dict, *kids, *count; fz_obj *obj, *tmp; int i, n; /* prevent infinite recursion */ - if (fz_dictgets(node, ".seen")) + if (fz_dict_gets(node, ".seen")) return; - kids = fz_dictgets(node, "Kids"); - count = fz_dictgets(node, "Count"); + kids = fz_dict_gets(node, "Kids"); + count = fz_dict_gets(node, "Count"); - if (fz_isarray(kids) && fz_isint(count)) + if (fz_is_array(kids) && fz_is_int(count)) { - obj = fz_dictgets(node, "Resources"); + obj = fz_dict_gets(node, "Resources"); if (obj) info.resources = obj; - obj = fz_dictgets(node, "MediaBox"); + obj = fz_dict_gets(node, "MediaBox"); if (obj) info.mediabox = obj; - obj = fz_dictgets(node, "CropBox"); + obj = fz_dict_gets(node, "CropBox"); if (obj) info.cropbox = obj; - obj = fz_dictgets(node, "Rotate"); + obj = fz_dict_gets(node, "Rotate"); if (obj) info.rotate = obj; - tmp = fz_newnull(); - fz_dictputs(node, ".seen", tmp); - fz_dropobj(tmp); + tmp = fz_new_null(); + fz_dict_puts(node, ".seen", tmp); + fz_drop_obj(tmp); - n = fz_arraylen(kids); + n = fz_array_len(kids); for (i = 0; i < n; i++) { - obj = fz_arrayget(kids, i); - pdf_loadpagetreenode(xref, obj, info); + obj = fz_array_get(kids, i); + pdf_load_page_tree_node(xref, obj, info); } - fz_dictdels(node, ".seen"); + fz_dict_dels(node, ".seen"); } else { - dict = fz_resolveindirect(node); - - if (info.resources && !fz_dictgets(dict, "Resources")) - fz_dictputs(dict, "Resources", info.resources); - if (info.mediabox && !fz_dictgets(dict, "MediaBox")) - fz_dictputs(dict, "MediaBox", info.mediabox); - if (info.cropbox && !fz_dictgets(dict, "CropBox")) - fz_dictputs(dict, "CropBox", info.cropbox); - if (info.rotate && !fz_dictgets(dict, "Rotate")) - fz_dictputs(dict, "Rotate", info.rotate); - - if (xref->pagelen == xref->pagecap) + dict = fz_resolve_indirect(node); + + if (info.resources && !fz_dict_gets(dict, "Resources")) + fz_dict_puts(dict, "Resources", info.resources); + if (info.mediabox && !fz_dict_gets(dict, "MediaBox")) + fz_dict_puts(dict, "MediaBox", info.mediabox); + if (info.cropbox && !fz_dict_gets(dict, "CropBox")) + fz_dict_puts(dict, "CropBox", info.cropbox); + if (info.rotate && !fz_dict_gets(dict, "Rotate")) + fz_dict_puts(dict, "Rotate", info.rotate); + + if (xref->page_len == xref->page_cap) { fz_warn("found more pages than expected"); - xref->pagecap ++; - xref->pagerefs = fz_realloc(xref->pagerefs, xref->pagecap, sizeof(fz_obj*)); - xref->pageobjs = fz_realloc(xref->pageobjs, xref->pagecap, sizeof(fz_obj*)); + xref->page_cap ++; + xref->page_refs = fz_realloc(xref->page_refs, xref->page_cap, sizeof(fz_obj*)); + xref->page_objs = fz_realloc(xref->page_objs, xref->page_cap, sizeof(fz_obj*)); } - xref->pagerefs[xref->pagelen] = fz_keepobj(node); - xref->pageobjs[xref->pagelen] = fz_keepobj(dict); - xref->pagelen ++; + xref->page_refs[xref->page_len] = fz_keep_obj(node); + xref->page_objs[xref->page_len] = fz_keep_obj(dict); + xref->page_len ++; } } fz_error -pdf_loadpagetree(pdf_xref *xref) +pdf_load_page_tree(pdf_xref *xref) { struct info info; - fz_obj *catalog = fz_dictgets(xref->trailer, "Root"); - fz_obj *pages = fz_dictgets(catalog, "Pages"); - fz_obj *count = fz_dictgets(pages, "Count"); + fz_obj *catalog = fz_dict_gets(xref->trailer, "Root"); + fz_obj *pages = fz_dict_gets(catalog, "Pages"); + fz_obj *count = fz_dict_gets(pages, "Count"); - if (!fz_isdict(pages)) + if (!fz_is_dict(pages)) return fz_throw("missing page tree"); - if (!fz_isint(count)) + if (!fz_is_int(count)) return fz_throw("missing page count"); - xref->pagecap = fz_toint(count); - xref->pagelen = 0; - xref->pagerefs = fz_calloc(xref->pagecap, sizeof(fz_obj*)); - xref->pageobjs = fz_calloc(xref->pagecap, sizeof(fz_obj*)); + xref->page_cap = fz_to_int(count); + xref->page_len = 0; + xref->page_refs = fz_calloc(xref->page_cap, sizeof(fz_obj*)); + xref->page_objs = fz_calloc(xref->page_cap, sizeof(fz_obj*)); - info.resources = nil; - info.mediabox = nil; - info.cropbox = nil; - info.rotate = nil; + info.resources = NULL; + info.mediabox = NULL; + info.cropbox = NULL; + info.rotate = NULL; - pdf_loadpagetreenode(xref, pages, info); + pdf_load_page_tree_node(xref, pages, info); return fz_okay; } diff --git a/pdf/pdf_parse.c b/pdf/pdf_parse.c index b32f4d01..9f9d33b1 100644 --- a/pdf/pdf_parse.c +++ b/pdf/pdf_parse.c @@ -1,13 +1,13 @@ #include "fitz.h" #include "mupdf.h" -fz_rect pdf_torect(fz_obj *array) +fz_rect pdf_to_rect(fz_obj *array) { fz_rect r; - float a = fz_toreal(fz_arrayget(array, 0)); - float b = fz_toreal(fz_arrayget(array, 1)); - float c = fz_toreal(fz_arrayget(array, 2)); - float d = fz_toreal(fz_arrayget(array, 3)); + float a = fz_to_real(fz_array_get(array, 0)); + float b = fz_to_real(fz_array_get(array, 1)); + float c = fz_to_real(fz_array_get(array, 2)); + float d = fz_to_real(fz_array_get(array, 3)); r.x0 = MIN(a, c); r.y0 = MIN(b, d); r.x1 = MAX(a, c); @@ -15,24 +15,24 @@ fz_rect pdf_torect(fz_obj *array) return r; } -fz_matrix pdf_tomatrix(fz_obj *array) +fz_matrix pdf_to_matrix(fz_obj *array) { fz_matrix m; - m.a = fz_toreal(fz_arrayget(array, 0)); - m.b = fz_toreal(fz_arrayget(array, 1)); - m.c = fz_toreal(fz_arrayget(array, 2)); - m.d = fz_toreal(fz_arrayget(array, 3)); - m.e = fz_toreal(fz_arrayget(array, 4)); - m.f = fz_toreal(fz_arrayget(array, 5)); + m.a = fz_to_real(fz_array_get(array, 0)); + m.b = fz_to_real(fz_array_get(array, 1)); + m.c = fz_to_real(fz_array_get(array, 2)); + m.d = fz_to_real(fz_array_get(array, 3)); + m.e = fz_to_real(fz_array_get(array, 4)); + m.f = fz_to_real(fz_array_get(array, 5)); return m; } char * -pdf_toutf8(fz_obj *src) +pdf_to_utf8(fz_obj *src) { - unsigned char *srcptr = (unsigned char *) fz_tostrbuf(src); + unsigned char *srcptr = (unsigned char *) fz_to_str_buf(src); char *dstptr, *dst; - int srclen = fz_tostrlen(src); + int srclen = fz_to_str_len(src); int dstlen = 0; int ucs; int i; @@ -57,13 +57,13 @@ pdf_toutf8(fz_obj *src) else { for (i = 0; i < srclen; i++) - dstlen += runelen(pdf_docencoding[srcptr[i]]); + dstlen += runelen(pdf_doc_encoding[srcptr[i]]); dstptr = dst = fz_malloc(dstlen + 1); for (i = 0; i < srclen; i++) { - ucs = pdf_docencoding[srcptr[i]]; + ucs = pdf_doc_encoding[srcptr[i]]; dstptr += runetochar(dstptr, &ucs); } } @@ -73,11 +73,11 @@ pdf_toutf8(fz_obj *src) } unsigned short * -pdf_toucs2(fz_obj *src) +pdf_to_ucs2(fz_obj *src) { - unsigned char *srcptr = (unsigned char *) fz_tostrbuf(src); + unsigned char *srcptr = (unsigned char *) fz_to_str_buf(src); unsigned short *dstptr, *dst; - int srclen = fz_tostrlen(src); + int srclen = fz_to_str_len(src); int i; if (srclen > 2 && srcptr[0] == 254 && srcptr[1] == 255) @@ -91,7 +91,7 @@ pdf_toucs2(fz_obj *src) { dstptr = dst = fz_calloc(srclen + 1, sizeof(short)); for (i = 0; i < srclen; i++) - *dstptr++ = pdf_docencoding[srcptr[i]]; + *dstptr++ = pdf_doc_encoding[srcptr[i]]; } *dstptr = '\0'; @@ -99,68 +99,68 @@ pdf_toucs2(fz_obj *src) } fz_obj * -pdf_toutf8name(fz_obj *src) +pdf_to_utf8_name(fz_obj *src) { - char *buf = pdf_toutf8(src); - fz_obj *dst = fz_newname(buf); + char *buf = pdf_to_utf8(src); + fz_obj *dst = fz_new_name(buf); fz_free(buf); return dst; } fz_error -pdf_parsearray(fz_obj **op, pdf_xref *xref, fz_stream *file, char *buf, int cap) +pdf_parse_array(fz_obj **op, pdf_xref *xref, fz_stream *file, char *buf, int cap) { fz_error error = fz_okay; - fz_obj *ary = nil; - fz_obj *obj = nil; + fz_obj *ary = NULL; + fz_obj *obj = NULL; int a = 0, b = 0, n = 0; int tok; int len; - ary = fz_newarray(4); + ary = fz_new_array(4); while (1) { error = pdf_lex(&tok, file, buf, cap, &len); if (error) { - fz_dropobj(ary); + fz_drop_obj(ary); return fz_rethrow(error, "cannot parse array"); } - if (tok != PDF_TINT && tok != PDF_TR) + if (tok != PDF_TOK_INT && tok != PDF_TOK_R) { if (n > 0) { - obj = fz_newint(a); - fz_arraypush(ary, obj); - fz_dropobj(obj); + obj = fz_new_int(a); + fz_array_push(ary, obj); + fz_drop_obj(obj); } if (n > 1) { - obj = fz_newint(b); - fz_arraypush(ary, obj); - fz_dropobj(obj); + obj = fz_new_int(b); + fz_array_push(ary, obj); + fz_drop_obj(obj); } n = 0; } - if (tok == PDF_TINT && n == 2) + if (tok == PDF_TOK_INT && n == 2) { - obj = fz_newint(a); - fz_arraypush(ary, obj); - fz_dropobj(obj); + obj = fz_new_int(a); + fz_array_push(ary, obj); + fz_drop_obj(obj); a = b; n --; } switch (tok) { - case PDF_TCARRAY: + case PDF_TOK_CLOSE_ARRAY: *op = ary; return fz_okay; - case PDF_TINT: + case PDF_TOK_INT: if (n == 0) a = atoi(buf); if (n == 1) @@ -168,212 +168,212 @@ pdf_parsearray(fz_obj **op, pdf_xref *xref, fz_stream *file, char *buf, int cap) n ++; break; - case PDF_TR: + case PDF_TOK_R: if (n != 2) { - fz_dropobj(ary); + fz_drop_obj(ary); return fz_throw("cannot parse indirect reference in array"); } - obj = fz_newindirect(a, b, xref); - fz_arraypush(ary, obj); - fz_dropobj(obj); + obj = fz_new_indirect(a, b, xref); + fz_array_push(ary, obj); + fz_drop_obj(obj); n = 0; break; - case PDF_TOARRAY: - error = pdf_parsearray(&obj, xref, file, buf, cap); + case PDF_TOK_OPEN_ARRAY: + error = pdf_parse_array(&obj, xref, file, buf, cap); if (error) { - fz_dropobj(ary); + fz_drop_obj(ary); return fz_rethrow(error, "cannot parse array"); } - fz_arraypush(ary, obj); - fz_dropobj(obj); + fz_array_push(ary, obj); + fz_drop_obj(obj); break; - case PDF_TODICT: - error = pdf_parsedict(&obj, xref, file, buf, cap); + case PDF_TOK_OPEN_DICT: + error = pdf_parse_dict(&obj, xref, file, buf, cap); if (error) { - fz_dropobj(ary); + fz_drop_obj(ary); return fz_rethrow(error, "cannot parse array"); } - fz_arraypush(ary, obj); - fz_dropobj(obj); + fz_array_push(ary, obj); + fz_drop_obj(obj); break; - case PDF_TNAME: - obj = fz_newname(buf); - fz_arraypush(ary, obj); - fz_dropobj(obj); + case PDF_TOK_NAME: + obj = fz_new_name(buf); + fz_array_push(ary, obj); + fz_drop_obj(obj); break; - case PDF_TREAL: - obj = fz_newreal(atof(buf)); - fz_arraypush(ary, obj); - fz_dropobj(obj); + case PDF_TOK_REAL: + obj = fz_new_real(atof(buf)); + fz_array_push(ary, obj); + fz_drop_obj(obj); break; - case PDF_TSTRING: - obj = fz_newstring(buf, len); - fz_arraypush(ary, obj); - fz_dropobj(obj); + case PDF_TOK_STRING: + obj = fz_new_string(buf, len); + fz_array_push(ary, obj); + fz_drop_obj(obj); break; - case PDF_TTRUE: - obj = fz_newbool(1); - fz_arraypush(ary, obj); - fz_dropobj(obj); + case PDF_TOK_TRUE: + obj = fz_new_bool(1); + fz_array_push(ary, obj); + fz_drop_obj(obj); break; - case PDF_TFALSE: - obj = fz_newbool(0); - fz_arraypush(ary, obj); - fz_dropobj(obj); + case PDF_TOK_FALSE: + obj = fz_new_bool(0); + fz_array_push(ary, obj); + fz_drop_obj(obj); break; - case PDF_TNULL: - obj = fz_newnull(); - fz_arraypush(ary, obj); - fz_dropobj(obj); + case PDF_TOK_NULL: + obj = fz_new_null(); + fz_array_push(ary, obj); + fz_drop_obj(obj); break; default: - fz_dropobj(ary); + fz_drop_obj(ary); return fz_throw("cannot parse token in array"); } } } fz_error -pdf_parsedict(fz_obj **op, pdf_xref *xref, fz_stream *file, char *buf, int cap) +pdf_parse_dict(fz_obj **op, pdf_xref *xref, fz_stream *file, char *buf, int cap) { fz_error error = fz_okay; - fz_obj *dict = nil; - fz_obj *key = nil; - fz_obj *val = nil; + fz_obj *dict = NULL; + fz_obj *key = NULL; + fz_obj *val = NULL; int tok; int len; int a, b; - dict = fz_newdict(8); + dict = fz_new_dict(8); while (1) { error = pdf_lex(&tok, file, buf, cap, &len); if (error) { - fz_dropobj(dict); + fz_drop_obj(dict); return fz_rethrow(error, "cannot parse dict"); } skip: - if (tok == PDF_TCDICT) + if (tok == PDF_TOK_CLOSE_DICT) { *op = dict; return fz_okay; } /* for BI .. ID .. EI in content streams */ - if (tok == PDF_TKEYWORD && !strcmp(buf, "ID")) + if (tok == PDF_TOK_KEYWORD && !strcmp(buf, "ID")) { *op = dict; return fz_okay; } - if (tok != PDF_TNAME) + if (tok != PDF_TOK_NAME) { - fz_dropobj(dict); + fz_drop_obj(dict); return fz_throw("invalid key in dict"); } - key = fz_newname(buf); + key = fz_new_name(buf); error = pdf_lex(&tok, file, buf, cap, &len); if (error) { - fz_dropobj(key); - fz_dropobj(dict); + fz_drop_obj(key); + fz_drop_obj(dict); return fz_rethrow(error, "cannot parse dict"); } switch (tok) { - case PDF_TOARRAY: - error = pdf_parsearray(&val, xref, file, buf, cap); + case PDF_TOK_OPEN_ARRAY: + error = pdf_parse_array(&val, xref, file, buf, cap); if (error) { - fz_dropobj(key); - fz_dropobj(dict); + fz_drop_obj(key); + fz_drop_obj(dict); return fz_rethrow(error, "cannot parse dict"); } break; - case PDF_TODICT: - error = pdf_parsedict(&val, xref, file, buf, cap); + case PDF_TOK_OPEN_DICT: + error = pdf_parse_dict(&val, xref, file, buf, cap); if (error) { - fz_dropobj(key); - fz_dropobj(dict); + fz_drop_obj(key); + fz_drop_obj(dict); return fz_rethrow(error, "cannot parse dict"); } break; - case PDF_TNAME: val = fz_newname(buf); break; - case PDF_TREAL: val = fz_newreal(atof(buf)); break; - case PDF_TSTRING: val = fz_newstring(buf, len); break; - case PDF_TTRUE: val = fz_newbool(1); break; - case PDF_TFALSE: val = fz_newbool(0); break; - case PDF_TNULL: val = fz_newnull(); break; + case PDF_TOK_NAME: val = fz_new_name(buf); break; + case PDF_TOK_REAL: val = fz_new_real(atof(buf)); break; + case PDF_TOK_STRING: val = fz_new_string(buf, len); break; + case PDF_TOK_TRUE: val = fz_new_bool(1); break; + case PDF_TOK_FALSE: val = fz_new_bool(0); break; + case PDF_TOK_NULL: val = fz_new_null(); break; - case PDF_TINT: + case PDF_TOK_INT: /* 64-bit to allow for numbers > INT_MAX and overflow */ a = (int) strtoll(buf, 0, 10); error = pdf_lex(&tok, file, buf, cap, &len); if (error) { - fz_dropobj(key); - fz_dropobj(dict); + fz_drop_obj(key); + fz_drop_obj(dict); return fz_rethrow(error, "cannot parse dict"); } - if (tok == PDF_TCDICT || tok == PDF_TNAME || - (tok == PDF_TKEYWORD && !strcmp(buf, "ID"))) + if (tok == PDF_TOK_CLOSE_DICT || tok == PDF_TOK_NAME || + (tok == PDF_TOK_KEYWORD && !strcmp(buf, "ID"))) { - val = fz_newint(a); - fz_dictput(dict, key, val); - fz_dropobj(val); - fz_dropobj(key); + val = fz_new_int(a); + fz_dict_put(dict, key, val); + fz_drop_obj(val); + fz_drop_obj(key); goto skip; } - if (tok == PDF_TINT) + if (tok == PDF_TOK_INT) { b = atoi(buf); error = pdf_lex(&tok, file, buf, cap, &len); if (error) { - fz_dropobj(key); - fz_dropobj(dict); + fz_drop_obj(key); + fz_drop_obj(dict); return fz_rethrow(error, "cannot parse dict"); } - if (tok == PDF_TR) + if (tok == PDF_TOK_R) { - val = fz_newindirect(a, b, xref); + val = fz_new_indirect(a, b, xref); break; } } - fz_dropobj(key); - fz_dropobj(dict); + fz_drop_obj(key); + fz_drop_obj(dict); return fz_throw("invalid indirect reference in dict"); default: - fz_dropobj(key); - fz_dropobj(dict); + fz_drop_obj(key); + fz_drop_obj(dict); return fz_throw("unknown token in dict"); } - fz_dictput(dict, key, val); - fz_dropobj(val); - fz_dropobj(key); + fz_dict_put(dict, key, val); + fz_drop_obj(val); + fz_drop_obj(key); } } fz_error -pdf_parsestmobj(fz_obj **op, pdf_xref *xref, fz_stream *file, char *buf, int cap) +pdf_parse_stm_obj(fz_obj **op, pdf_xref *xref, fz_stream *file, char *buf, int cap) { fz_error error; int tok; @@ -385,23 +385,23 @@ pdf_parsestmobj(fz_obj **op, pdf_xref *xref, fz_stream *file, char *buf, int cap switch (tok) { - case PDF_TOARRAY: - error = pdf_parsearray(op, xref, file, buf, cap); + case PDF_TOK_OPEN_ARRAY: + error = pdf_parse_array(op, xref, file, buf, cap); if (error) return fz_rethrow(error, "cannot parse object stream"); break; - case PDF_TODICT: - error = pdf_parsedict(op, xref, file, buf, cap); + case PDF_TOK_OPEN_DICT: + error = pdf_parse_dict(op, xref, file, buf, cap); if (error) return fz_rethrow(error, "cannot parse object stream"); break; - case PDF_TNAME: *op = fz_newname(buf); break; - case PDF_TREAL: *op = fz_newreal(atof(buf)); break; - case PDF_TSTRING: *op = fz_newstring(buf, len); break; - case PDF_TTRUE: *op = fz_newbool(1); break; - case PDF_TFALSE: *op = fz_newbool(0); break; - case PDF_TNULL: *op = fz_newnull(); break; - case PDF_TINT: *op = fz_newint(atoi(buf)); break; + case PDF_TOK_NAME: *op = fz_new_name(buf); break; + case PDF_TOK_REAL: *op = fz_new_real(atof(buf)); break; + case PDF_TOK_STRING: *op = fz_new_string(buf, len); break; + case PDF_TOK_TRUE: *op = fz_new_bool(1); break; + case PDF_TOK_FALSE: *op = fz_new_bool(0); break; + case PDF_TOK_NULL: *op = fz_new_null(); break; + case PDF_TOK_INT: *op = fz_new_int(atoi(buf)); break; default: return fz_throw("unknown token in object stream"); } @@ -409,13 +409,13 @@ pdf_parsestmobj(fz_obj **op, pdf_xref *xref, fz_stream *file, char *buf, int cap } fz_error -pdf_parseindobj(fz_obj **op, pdf_xref *xref, +pdf_parse_ind_obj(fz_obj **op, pdf_xref *xref, fz_stream *file, char *buf, int cap, int *onum, int *ogen, int *ostmofs) { fz_error error = fz_okay; - fz_obj *obj = nil; - int num = 0, gen = 0, stmofs; + fz_obj *obj = NULL; + int num = 0, gen = 0, stm_ofs; int tok; int len; int a, b; @@ -423,21 +423,21 @@ pdf_parseindobj(fz_obj **op, pdf_xref *xref, error = pdf_lex(&tok, file, buf, cap, &len); if (error) return fz_rethrow(error, "cannot parse indirect object (%d %d R)", num, gen); - if (tok != PDF_TINT) + if (tok != PDF_TOK_INT) return fz_throw("expected object number (%d %d R)", num, gen); num = atoi(buf); error = pdf_lex(&tok, file, buf, cap, &len); if (error) return fz_rethrow(error, "cannot parse indirect object (%d %d R)", num, gen); - if (tok != PDF_TINT) + if (tok != PDF_TOK_INT) return fz_throw("expected generation number (%d %d R)", num, gen); gen = atoi(buf); error = pdf_lex(&tok, file, buf, cap, &len); if (error) return fz_rethrow(error, "cannot parse indirect object (%d %d R)", num, gen); - if (tok != PDF_TOBJ) + if (tok != PDF_TOK_OBJ) return fz_throw("expected 'obj' keyword (%d %d R)", num, gen); error = pdf_lex(&tok, file, buf, cap, &len); @@ -446,51 +446,51 @@ pdf_parseindobj(fz_obj **op, pdf_xref *xref, switch (tok) { - case PDF_TOARRAY: - error = pdf_parsearray(&obj, xref, file, buf, cap); + case PDF_TOK_OPEN_ARRAY: + error = pdf_parse_array(&obj, xref, file, buf, cap); if (error) return fz_rethrow(error, "cannot parse indirect object (%d %d R)", num, gen); break; - case PDF_TODICT: - error = pdf_parsedict(&obj, xref, file, buf, cap); + case PDF_TOK_OPEN_DICT: + error = pdf_parse_dict(&obj, xref, file, buf, cap); if (error) return fz_rethrow(error, "cannot parse indirect object (%d %d R)", num, gen); break; - case PDF_TNAME: obj = fz_newname(buf); break; - case PDF_TREAL: obj = fz_newreal(atof(buf)); break; - case PDF_TSTRING: obj = fz_newstring(buf, len); break; - case PDF_TTRUE: obj = fz_newbool(1); break; - case PDF_TFALSE: obj = fz_newbool(0); break; - case PDF_TNULL: obj = fz_newnull(); break; + case PDF_TOK_NAME: obj = fz_new_name(buf); break; + case PDF_TOK_REAL: obj = fz_new_real(atof(buf)); break; + case PDF_TOK_STRING: obj = fz_new_string(buf, len); break; + case PDF_TOK_TRUE: obj = fz_new_bool(1); break; + case PDF_TOK_FALSE: obj = fz_new_bool(0); break; + case PDF_TOK_NULL: obj = fz_new_null(); break; - case PDF_TINT: + case PDF_TOK_INT: a = atoi(buf); error = pdf_lex(&tok, file, buf, cap, &len); if (error) return fz_rethrow(error, "cannot parse indirect object (%d %d R)", num, gen); - if (tok == PDF_TSTREAM || tok == PDF_TENDOBJ) + if (tok == PDF_TOK_STREAM || tok == PDF_TOK_ENDOBJ) { - obj = fz_newint(a); + obj = fz_new_int(a); goto skip; } - if (tok == PDF_TINT) + if (tok == PDF_TOK_INT) { b = atoi(buf); error = pdf_lex(&tok, file, buf, cap, &len); if (error) return fz_rethrow(error, "cannot parse indirect object (%d %d R)", num, gen); - if (tok == PDF_TR) + if (tok == PDF_TOK_R) { - obj = fz_newindirect(a, b, xref); + obj = fz_new_indirect(a, b, xref); break; } } return fz_throw("expected 'R' keyword (%d %d R)", num, gen); - case PDF_TENDOBJ: - obj = fz_newnull(); + case PDF_TOK_ENDOBJ: + obj = fz_new_null(); goto skip; default: @@ -500,39 +500,39 @@ pdf_parseindobj(fz_obj **op, pdf_xref *xref, error = pdf_lex(&tok, file, buf, cap, &len); if (error) { - fz_dropobj(obj); + fz_drop_obj(obj); return fz_rethrow(error, "cannot parse indirect object (%d %d R)", num, gen); } skip: - if (tok == PDF_TSTREAM) + if (tok == PDF_TOK_STREAM) { - int c = fz_readbyte(file); + int c = fz_read_byte(file); while (c == ' ') - c = fz_readbyte(file); + c = fz_read_byte(file); if (c == '\r') { - c = fz_peekbyte(file); + c = fz_peek_byte(file); if (c != '\n') fz_warn("line feed missing after stream begin marker (%d %d R)", num, gen); else - fz_readbyte(file); + fz_read_byte(file); } - stmofs = fz_tell(file); + stm_ofs = fz_tell(file); } - else if (tok == PDF_TENDOBJ) + else if (tok == PDF_TOK_ENDOBJ) { - stmofs = 0; + stm_ofs = 0; } else { fz_warn("expected 'endobj' or 'stream' keyword (%d %d R)", num, gen); - stmofs = 0; + stm_ofs = 0; } if (onum) *onum = num; if (ogen) *ogen = gen; - if (ostmofs) *ostmofs = stmofs; + if (ostmofs) *ostmofs = stm_ofs; *op = obj; return fz_okay; } diff --git a/pdf/pdf_pattern.c b/pdf/pdf_pattern.c index 7d3a38d1..ab464cfd 100644 --- a/pdf/pdf_pattern.c +++ b/pdf/pdf_pattern.c @@ -2,88 +2,88 @@ #include "mupdf.h" fz_error -pdf_loadpattern(pdf_pattern **patp, pdf_xref *xref, fz_obj *dict) +pdf_load_pattern(pdf_pattern **patp, pdf_xref *xref, fz_obj *dict) { fz_error error; pdf_pattern *pat; fz_obj *obj; - if ((*patp = pdf_finditem(xref->store, pdf_droppattern, dict))) + if ((*patp = pdf_find_item(xref->store, pdf_drop_pattern, dict))) { - pdf_keeppattern(*patp); + pdf_keep_pattern(*patp); return fz_okay; } - pdf_logrsrc("load pattern (%d %d R) {\n", fz_tonum(dict), fz_togen(dict)); + pdf_log_rsrc("load pattern (%d %d R) {\n", fz_to_num(dict), fz_to_gen(dict)); pat = fz_malloc(sizeof(pdf_pattern)); pat->refs = 1; - pat->resources = nil; - pat->contents = nil; + pat->resources = NULL; + pat->contents = NULL; /* Store pattern now, to avoid possible recursion if objects refer back to this one */ - pdf_storeitem(xref->store, pdf_keeppattern, pdf_droppattern, dict, pat); + pdf_store_item(xref->store, pdf_keep_pattern, pdf_drop_pattern, dict, pat); - 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")); + pat->ismask = fz_to_int(fz_dict_gets(dict, "PaintType")) == 2; + pat->xstep = fz_to_real(fz_dict_gets(dict, "XStep")); + pat->ystep = fz_to_real(fz_dict_gets(dict, "YStep")); - pdf_logrsrc("mask %d\n", pat->ismask); - pdf_logrsrc("xstep %g\n", pat->xstep); - pdf_logrsrc("ystep %g\n", pat->ystep); + pdf_log_rsrc("mask %d\n", pat->ismask); + pdf_log_rsrc("xstep %g\n", pat->xstep); + pdf_log_rsrc("ystep %g\n", pat->ystep); - obj = fz_dictgets(dict, "BBox"); - pat->bbox = pdf_torect(obj); + obj = fz_dict_gets(dict, "BBox"); + pat->bbox = pdf_to_rect(obj); - pdf_logrsrc("bbox [%g %g %g %g]\n", + pdf_log_rsrc("bbox [%g %g %g %g]\n", pat->bbox.x0, pat->bbox.y0, pat->bbox.x1, pat->bbox.y1); - obj = fz_dictgets(dict, "Matrix"); + obj = fz_dict_gets(dict, "Matrix"); if (obj) - pat->matrix = pdf_tomatrix(obj); + pat->matrix = pdf_to_matrix(obj); else pat->matrix = fz_identity; - pdf_logrsrc("matrix [%g %g %g %g %g %g]\n", + pdf_log_rsrc("matrix [%g %g %g %g %g %g]\n", pat->matrix.a, pat->matrix.b, pat->matrix.c, pat->matrix.d, pat->matrix.e, pat->matrix.f); - pat->resources = fz_dictgets(dict, "Resources"); + pat->resources = fz_dict_gets(dict, "Resources"); if (pat->resources) - fz_keepobj(pat->resources); + fz_keep_obj(pat->resources); - error = pdf_loadstream(&pat->contents, xref, fz_tonum(dict), fz_togen(dict)); + error = pdf_load_stream(&pat->contents, xref, fz_to_num(dict), fz_to_gen(dict)); if (error) { - pdf_removeitem(xref->store, pdf_droppattern, dict); - pdf_droppattern(pat); - return fz_rethrow(error, "cannot load pattern stream (%d %d R)", fz_tonum(dict), fz_togen(dict)); + pdf_remove_item(xref->store, pdf_drop_pattern, dict); + pdf_drop_pattern(pat); + return fz_rethrow(error, "cannot load pattern stream (%d %d R)", fz_to_num(dict), fz_to_gen(dict)); } - pdf_logrsrc("}\n"); + pdf_log_rsrc("}\n"); *patp = pat; return fz_okay; } pdf_pattern * -pdf_keeppattern(pdf_pattern *pat) +pdf_keep_pattern(pdf_pattern *pat) { pat->refs ++; return pat; } void -pdf_droppattern(pdf_pattern *pat) +pdf_drop_pattern(pdf_pattern *pat) { if (pat && --pat->refs == 0) { if (pat->resources) - fz_dropobj(pat->resources); + fz_drop_obj(pat->resources); if (pat->contents) - fz_dropbuffer(pat->contents); + fz_drop_buffer(pat->contents); fz_free(pat); } } diff --git a/pdf/pdf_repair.c b/pdf/pdf_repair.c index 436f7303..45310fc6 100644 --- a/pdf/pdf_repair.c +++ b/pdf/pdf_repair.c @@ -8,93 +8,93 @@ struct entry int num; int gen; int ofs; - int stmofs; - int stmlen; + int stm_ofs; + int stm_len; }; static fz_error -fz_repairobj(fz_stream *file, char *buf, int cap, int *stmofsp, int *stmlenp, fz_obj **encrypt, fz_obj **id) +pdf_repair_obj(fz_stream *file, char *buf, int cap, int *stmofsp, int *stmlenp, fz_obj **encrypt, fz_obj **id) { fz_error error; int tok; - int stmlen; + int stm_len; int len; int n; *stmofsp = 0; *stmlenp = -1; - stmlen = 0; + stm_len = 0; error = pdf_lex(&tok, file, buf, cap, &len); if (error) return fz_rethrow(error, "cannot parse object"); - if (tok == PDF_TODICT) + if (tok == PDF_TOK_OPEN_DICT) { fz_obj *dict, *obj; - /* Send nil xref so we don't try to resolve references */ - error = pdf_parsedict(&dict, nil, file, buf, cap); + /* Send NULL xref so we don't try to resolve references */ + error = pdf_parse_dict(&dict, NULL, file, buf, cap); if (error) return fz_rethrow(error, "cannot parse object"); - obj = fz_dictgets(dict, "Type"); - if (fz_isname(obj) && !strcmp(fz_toname(obj), "XRef")) + obj = fz_dict_gets(dict, "Type"); + if (fz_is_name(obj) && !strcmp(fz_to_name(obj), "XRef")) { - obj = fz_dictgets(dict, "Encrypt"); + obj = fz_dict_gets(dict, "Encrypt"); if (obj) { if (*encrypt) - fz_dropobj(*encrypt); - *encrypt = fz_keepobj(obj); + fz_drop_obj(*encrypt); + *encrypt = fz_keep_obj(obj); } - obj = fz_dictgets(dict, "ID"); + obj = fz_dict_gets(dict, "ID"); if (obj) { if (*id) - fz_dropobj(*id); - *id = fz_keepobj(obj); + fz_drop_obj(*id); + *id = fz_keep_obj(obj); } } - obj = fz_dictgets(dict, "Length"); - if (fz_isint(obj)) - stmlen = fz_toint(obj); + obj = fz_dict_gets(dict, "Length"); + if (fz_is_int(obj)) + stm_len = fz_to_int(obj); - fz_dropobj(dict); + fz_drop_obj(dict); } - while ( tok != PDF_TSTREAM && - tok != PDF_TENDOBJ && - tok != PDF_TERROR && - tok != PDF_TEOF ) + while ( tok != PDF_TOK_STREAM && + tok != PDF_TOK_ENDOBJ && + tok != PDF_TOK_ERROR && + tok != PDF_TOK_EOF ) { error = pdf_lex(&tok, file, buf, cap, &len); if (error) return fz_rethrow(error, "cannot scan for endobj or stream token"); } - if (tok == PDF_TSTREAM) + if (tok == PDF_TOK_STREAM) { - int c = fz_readbyte(file); + int c = fz_read_byte(file); if (c == '\r') { - c = fz_peekbyte(file); + c = fz_peek_byte(file); if (c == '\n') - fz_readbyte(file); + fz_read_byte(file); } *stmofsp = fz_tell(file); if (*stmofsp < 0) return fz_throw("cannot seek in file"); - if (stmlen > 0) + if (stm_len > 0) { - fz_seek(file, *stmofsp + stmlen, 0); + fz_seek(file, *stmofsp + stm_len, 0); error = pdf_lex(&tok, file, buf, cap, &len); if (error) fz_catch(error, "cannot find endstream token, falling back to scanning"); - if (tok == PDF_TENDSTREAM) + if (tok == PDF_TOK_ENDSTREAM) goto atobjend; fz_seek(file, *stmofsp, 0); } @@ -105,7 +105,7 @@ fz_repairobj(fz_stream *file, char *buf, int cap, int *stmofsp, int *stmlenp, fz while (memcmp(buf, "endstream", 9) != 0) { - c = fz_readbyte(file); + c = fz_read_byte(file); if (c == EOF) break; memmove(buf, buf + 1, 8); @@ -118,7 +118,7 @@ atobjend: error = pdf_lex(&tok, file, buf, cap, &len); if (error) return fz_rethrow(error, "cannot scan for endobj token"); - if (tok != PDF_TENDOBJ) + if (tok != PDF_TOK_ENDOBJ) fz_warn("object missing 'endobj' token"); } @@ -126,7 +126,7 @@ atobjend: } static fz_error -pdf_repairobjstm(pdf_xref *xref, int num, int gen) +pdf_repair_obj_stm(pdf_xref *xref, int num, int gen) { fz_error error; fz_obj *obj; @@ -135,22 +135,22 @@ pdf_repairobjstm(pdf_xref *xref, int num, int gen) int i, n, count; char buf[256]; - error = pdf_loadobject(&obj, xref, num, gen); + error = pdf_load_object(&obj, xref, num, gen); if (error) return fz_rethrow(error, "cannot load object stream object (%d %d R)", num, gen); - count = fz_toint(fz_dictgets(obj, "N")); + count = fz_to_int(fz_dict_gets(obj, "N")); - fz_dropobj(obj); + fz_drop_obj(obj); - error = pdf_openstream(&stm, xref, num, gen); + error = pdf_open_stream(&stm, xref, num, gen); if (error) return fz_rethrow(error, "cannot open object stream object (%d %d R)", num, gen); for (i = 0; i < count; i++) { error = pdf_lex(&tok, stm, buf, sizeof buf, &n); - if (error || tok != PDF_TINT) + if (error || tok != PDF_TOK_INT) { fz_close(stm); return fz_rethrow(error, "corrupt object stream (%d %d R)", num, gen); @@ -158,16 +158,16 @@ pdf_repairobjstm(pdf_xref *xref, int num, int gen) n = atoi(buf); if (n >= xref->len) - pdf_resizexref(xref, n + 1); + pdf_resize_xref(xref, n + 1); xref->table[n].ofs = num; xref->table[n].gen = i; - xref->table[n].stmofs = 0; - xref->table[n].obj = nil; + xref->table[n].stm_ofs = 0; + xref->table[n].obj = NULL; xref->table[n].type = 'o'; error = pdf_lex(&tok, stm, buf, sizeof buf, &n); - if (error || tok != PDF_TINT) + if (error || tok != PDF_TOK_INT) { fz_close(stm); return fz_rethrow(error, "corrupt object stream (%d %d R)", num, gen); @@ -179,18 +179,18 @@ pdf_repairobjstm(pdf_xref *xref, int num, int gen) } fz_error -pdf_repairxref(pdf_xref *xref, char *buf, int bufsize) +pdf_repair_xref(pdf_xref *xref, char *buf, int bufsize) { fz_error error; fz_obj *dict, *obj; fz_obj *length; - fz_obj *encrypt = nil; - fz_obj *id = nil; - fz_obj *root = nil; - fz_obj *info = nil; + fz_obj *encrypt = NULL; + fz_obj *id = NULL; + fz_obj *root = NULL; + fz_obj *info = NULL; - struct entry *list = nil; + struct entry *list = NULL; int listlen; int listcap; int maxnum = 0; @@ -198,12 +198,12 @@ pdf_repairxref(pdf_xref *xref, char *buf, int bufsize) int num = 0; int gen = 0; int tmpofs, numofs = 0, genofs = 0; - int stmlen, stmofs = 0; + int stm_len, stm_ofs = 0; int tok; int next; int i, n; - pdf_logxref("repairxref %p\n", xref); + pdf_log_xref("repairxref %p\n", xref); fz_seek(xref->file, 0, 0); @@ -245,7 +245,7 @@ pdf_repairxref(pdf_xref *xref, char *buf, int bufsize) break; } - if (tok == PDF_TINT) + if (tok == PDF_TOK_INT) { numofs = genofs; num = gen; @@ -253,16 +253,16 @@ pdf_repairxref(pdf_xref *xref, char *buf, int bufsize) gen = atoi(buf); } - if (tok == PDF_TOBJ) + if (tok == PDF_TOK_OBJ) { - error = fz_repairobj(xref->file, buf, bufsize, &stmofs, &stmlen, &encrypt, &id); + error = pdf_repair_obj(xref->file, buf, bufsize, &stm_ofs, &stm_len, &encrypt, &id); if (error) { error = fz_rethrow(error, "cannot parse object (%d %d R)", num, gen); goto cleanup; } - pdf_logxref("found object: (%d %d R)\n", num, gen); + pdf_log_xref("found object: (%d %d R)\n", num, gen); if (listlen + 1 == listcap) { @@ -273,8 +273,8 @@ pdf_repairxref(pdf_xref *xref, char *buf, int bufsize) list[listlen].num = num; list[listlen].gen = gen; list[listlen].ofs = numofs; - list[listlen].stmofs = stmofs; - list[listlen].stmlen = stmlen; + list[listlen].stm_ofs = stm_ofs; + list[listlen].stm_len = stm_len; listlen ++; if (num > maxnum) @@ -282,60 +282,60 @@ pdf_repairxref(pdf_xref *xref, char *buf, int bufsize) } /* trailer dictionary */ - if (tok == PDF_TODICT) + if (tok == PDF_TOK_OPEN_DICT) { - error = pdf_parsedict(&dict, xref, xref->file, buf, bufsize); + error = pdf_parse_dict(&dict, xref, xref->file, buf, bufsize); if (error) { error = fz_rethrow(error, "cannot parse object"); goto cleanup; } - obj = fz_dictgets(dict, "Encrypt"); + obj = fz_dict_gets(dict, "Encrypt"); if (obj) { if (encrypt) - fz_dropobj(encrypt); - encrypt = fz_keepobj(obj); + fz_drop_obj(encrypt); + encrypt = fz_keep_obj(obj); } - obj = fz_dictgets(dict, "ID"); + obj = fz_dict_gets(dict, "ID"); if (obj) { if (id) - fz_dropobj(id); - id = fz_keepobj(obj); + fz_drop_obj(id); + id = fz_keep_obj(obj); } - obj = fz_dictgets(dict, "Root"); + obj = fz_dict_gets(dict, "Root"); if (obj) { if (root) - fz_dropobj(root); - root = fz_keepobj(obj); + fz_drop_obj(root); + root = fz_keep_obj(obj); } - obj = fz_dictgets(dict, "Info"); + obj = fz_dict_gets(dict, "Info"); if (obj) { if (info) - fz_dropobj(info); - info = fz_keepobj(obj); + fz_drop_obj(info); + info = fz_keep_obj(obj); } - fz_dropobj(dict); + fz_drop_obj(dict); } - if (tok == PDF_TERROR) - fz_readbyte(xref->file); + if (tok == PDF_TOK_ERROR) + fz_read_byte(xref->file); - if (tok == PDF_TEOF) + if (tok == PDF_TOK_EOF) break; } /* make xref reasonable */ - pdf_resizexref(xref, maxnum + 1); + pdf_resize_xref(xref, maxnum + 1); for (i = 0; i < listlen; i++) { @@ -343,26 +343,26 @@ pdf_repairxref(pdf_xref *xref, char *buf, int bufsize) xref->table[list[i].num].ofs = list[i].ofs; xref->table[list[i].num].gen = list[i].gen; - xref->table[list[i].num].stmofs = list[i].stmofs; + xref->table[list[i].num].stm_ofs = list[i].stm_ofs; /* corrected stream length */ - if (list[i].stmlen >= 0) + if (list[i].stm_len >= 0) { - pdf_logxref("correct stream length %d %d = %d\n", - list[i].num, list[i].gen, list[i].stmlen); + pdf_log_xref("correct stream length %d %d = %d\n", + list[i].num, list[i].gen, list[i].stm_len); - error = pdf_loadobject(&dict, xref, list[i].num, list[i].gen); + error = pdf_load_object(&dict, xref, list[i].num, list[i].gen); if (error) { error = fz_rethrow(error, "cannot load stream object (%d %d R)", list[i].num, list[i].gen); goto cleanup; } - length = fz_newint(list[i].stmlen); - fz_dictputs(dict, "Length", length); - fz_dropobj(length); + length = fz_new_int(list[i].stm_len); + fz_dict_puts(dict, "Length", length); + fz_drop_obj(length); - fz_dropobj(dict); + fz_drop_obj(dict); } } @@ -370,8 +370,8 @@ pdf_repairxref(pdf_xref *xref, char *buf, int bufsize) xref->table[0].type = 'f'; xref->table[0].ofs = 0; xref->table[0].gen = 65535; - xref->table[0].stmofs = 0; - xref->table[0].obj = nil; + xref->table[0].stm_ofs = 0; + xref->table[0].obj = NULL; next = 0; for (i = xref->len - 1; i >= 0; i--) @@ -387,75 +387,75 @@ pdf_repairxref(pdf_xref *xref, char *buf, int bufsize) /* create a repaired trailer, Root will be added later */ - xref->trailer = fz_newdict(5); + xref->trailer = fz_new_dict(5); - obj = fz_newint(maxnum + 1); - fz_dictputs(xref->trailer, "Size", obj); - fz_dropobj(obj); + obj = fz_new_int(maxnum + 1); + fz_dict_puts(xref->trailer, "Size", obj); + fz_drop_obj(obj); if (root) { - fz_dictputs(xref->trailer, "Root", root); - fz_dropobj(root); + fz_dict_puts(xref->trailer, "Root", root); + fz_drop_obj(root); } if (info) { - fz_dictputs(xref->trailer, "Info", info); - fz_dropobj(info); + fz_dict_puts(xref->trailer, "Info", info); + fz_drop_obj(info); } if (encrypt) { - if (fz_isindirect(encrypt)) + if (fz_is_indirect(encrypt)) { - /* create new reference with non-nil xref pointer */ - obj = fz_newindirect(fz_tonum(encrypt), fz_togen(encrypt), xref); - fz_dropobj(encrypt); + /* create new reference with non-NULL xref pointer */ + obj = fz_new_indirect(fz_to_num(encrypt), fz_to_gen(encrypt), xref); + fz_drop_obj(encrypt); encrypt = obj; } - fz_dictputs(xref->trailer, "Encrypt", encrypt); - fz_dropobj(encrypt); + fz_dict_puts(xref->trailer, "Encrypt", encrypt); + fz_drop_obj(encrypt); } if (id) { - if (fz_isindirect(id)) + if (fz_is_indirect(id)) { - /* create new reference with non-nil xref pointer */ - obj = fz_newindirect(fz_tonum(id), fz_togen(id), xref); - fz_dropobj(id); + /* create new reference with non-NULL xref pointer */ + obj = fz_new_indirect(fz_to_num(id), fz_to_gen(id), xref); + fz_drop_obj(id); id = obj; } - fz_dictputs(xref->trailer, "ID", id); - fz_dropobj(id); + fz_dict_puts(xref->trailer, "ID", id); + fz_drop_obj(id); } fz_free(list); return fz_okay; cleanup: - if (encrypt) fz_dropobj(encrypt); - if (id) fz_dropobj(id); - if (root) fz_dropobj(root); - if (info) fz_dropobj(info); + if (encrypt) fz_drop_obj(encrypt); + if (id) fz_drop_obj(id); + if (root) fz_drop_obj(root); + if (info) fz_drop_obj(info); fz_free(list); return error; /* already rethrown */ } fz_error -pdf_repairobjstms(pdf_xref *xref) +pdf_repair_obj_stms(pdf_xref *xref) { fz_obj *dict; int i; for (i = 0; i < xref->len; i++) { - if (xref->table[i].stmofs) + if (xref->table[i].stm_ofs) { - pdf_loadobject(&dict, xref, i, 0); - if (!strcmp(fz_toname(fz_dictgets(dict, "Type")), "ObjStm")) - pdf_repairobjstm(xref, i, 0); - fz_dropobj(dict); + pdf_load_object(&dict, xref, i, 0); + if (!strcmp(fz_to_name(fz_dict_gets(dict, "Type")), "ObjStm")) + pdf_repair_obj_stm(xref, i, 0); + fz_drop_obj(dict); } } diff --git a/pdf/pdf_shade.c b/pdf/pdf_shade.c index 1b301724..46392059 100644 --- a/pdf/pdf_shade.c +++ b/pdf/pdf_shade.c @@ -9,70 +9,70 @@ struct vertex { float x, y; - float c[FZ_MAXCOLORS]; + float c[FZ_MAX_COLORS]; }; static void -pdf_growmesh(fz_shade *shade, int amount) +pdf_grow_mesh(fz_shade *shade, int amount) { - if (shade->meshlen + amount < shade->meshcap) + if (shade->mesh_len + amount < shade->mesh_cap) return; - if (shade->meshcap == 0) - shade->meshcap = 1024; + if (shade->mesh_cap == 0) + shade->mesh_cap = 1024; - while (shade->meshlen + amount > shade->meshcap) - shade->meshcap = (shade->meshcap * 3) / 2; + while (shade->mesh_len + amount > shade->mesh_cap) + shade->mesh_cap = (shade->mesh_cap * 3) / 2; - shade->mesh = fz_realloc(shade->mesh, shade->meshcap, sizeof(float)); + shade->mesh = fz_realloc(shade->mesh, shade->mesh_cap, sizeof(float)); } static void -pdf_addvertex(fz_shade *shade, struct vertex *v) +pdf_add_vertex(fz_shade *shade, struct vertex *v) { - int ncomp = shade->usefunction ? 1 : shade->colorspace->n; + int ncomp = shade->use_function ? 1 : shade->colorspace->n; int i; - pdf_growmesh(shade, 2 + ncomp); - shade->mesh[shade->meshlen++] = v->x; - shade->mesh[shade->meshlen++] = v->y; + pdf_grow_mesh(shade, 2 + ncomp); + shade->mesh[shade->mesh_len++] = v->x; + shade->mesh[shade->mesh_len++] = v->y; for (i = 0; i < ncomp; i++) - shade->mesh[shade->meshlen++] = v->c[i]; + shade->mesh[shade->mesh_len++] = v->c[i]; } static void -pdf_addtriangle(fz_shade *shade, +pdf_add_triangle(fz_shade *shade, struct vertex *v0, struct vertex *v1, struct vertex *v2) { - pdf_addvertex(shade, v0); - pdf_addvertex(shade, v1); - pdf_addvertex(shade, v2); + pdf_add_vertex(shade, v0); + pdf_add_vertex(shade, v1); + pdf_add_vertex(shade, v2); } static void -pdf_addquad(fz_shade *shade, +pdf_add_quad(fz_shade *shade, struct vertex *v0, struct vertex *v1, struct vertex *v2, struct vertex *v3) { - pdf_addtriangle(shade, v0, v1, v3); - pdf_addtriangle(shade, v1, v3, v2); + pdf_add_triangle(shade, v0, v1, v3); + pdf_add_triangle(shade, v1, v3, v2); } /* Subdivide and tesselate tensor-patches */ -typedef struct pdf_tensorpatch_s pdf_tensorpatch; +typedef struct pdf_tensor_patch_s pdf_tensor_patch; -struct pdf_tensorpatch_s +struct pdf_tensor_patch_s { fz_point pole[4][4]; - float color[4][FZ_MAXCOLORS]; + float color[4][FZ_MAX_COLORS]; }; static void -triangulatepatch(pdf_tensorpatch p, fz_shade *shade) +triangulate_patch(pdf_tensor_patch p, fz_shade *shade) { struct vertex v0, v1, v2, v3; @@ -92,19 +92,19 @@ triangulatepatch(pdf_tensorpatch p, fz_shade *shade) v3.y = p.pole[3][0].y; memcpy(v3.c, p.color[3], sizeof(v3.c)); - pdf_addquad(shade, &v0, &v1, &v2, &v3); + pdf_add_quad(shade, &v0, &v1, &v2, &v3); } static inline void midcolor(float *c, float *c1, float *c2) { int i; - for (i = 0; i < FZ_MAXCOLORS; i++) + for (i = 0; i < FZ_MAX_COLORS; i++) c[i] = (c1[i] + c2[i]) * 0.5f; } static inline void -splitcurve(fz_point *pole, fz_point *q0, fz_point *q1, int polestep) +split_curve(fz_point *pole, fz_point *q0, fz_point *q1, int polestep) { /* split bezier curve given by control points pole[0]..pole[3] @@ -140,16 +140,16 @@ splitcurve(fz_point *pole, fz_point *q0, fz_point *q1, int polestep) } static inline void -splitstripe(pdf_tensorpatch *p, pdf_tensorpatch *s0, pdf_tensorpatch *s1) +split_stripe(pdf_tensor_patch *p, pdf_tensor_patch *s0, pdf_tensor_patch *s1) { /* split all horizontal bezier curves in patch, creating two new patches with half the width. */ - splitcurve(&p->pole[0][0], &s0->pole[0][0], &s1->pole[0][0], 4); - splitcurve(&p->pole[0][1], &s0->pole[0][1], &s1->pole[0][1], 4); - splitcurve(&p->pole[0][2], &s0->pole[0][2], &s1->pole[0][2], 4); - splitcurve(&p->pole[0][3], &s0->pole[0][3], &s1->pole[0][3], 4); + split_curve(&p->pole[0][0], &s0->pole[0][0], &s1->pole[0][0], 4); + split_curve(&p->pole[0][1], &s0->pole[0][1], &s1->pole[0][1], 4); + split_curve(&p->pole[0][2], &s0->pole[0][2], &s1->pole[0][2], 4); + split_curve(&p->pole[0][3], &s0->pole[0][3], &s1->pole[0][3], 4); /* interpolate the colors for the two new patches. */ memcpy(s0->color[0], p->color[0], sizeof(s0->color[0])); @@ -164,39 +164,39 @@ splitstripe(pdf_tensorpatch *p, pdf_tensorpatch *s0, pdf_tensorpatch *s1) } static void -drawstripe(pdf_tensorpatch *p, fz_shade *shade, int depth) +draw_stripe(pdf_tensor_patch *p, fz_shade *shade, int depth) { - pdf_tensorpatch s0, s1; + pdf_tensor_patch s0, s1; /* split patch into two half-height patches */ - splitstripe(p, &s0, &s1); + split_stripe(p, &s0, &s1); depth--; if (depth == 0) { /* if no more subdividing, draw two new patches... */ - triangulatepatch(s0, shade); - triangulatepatch(s1, shade); + triangulate_patch(s0, shade); + triangulate_patch(s1, shade); } else { /* ...otherwise, continue subdividing. */ - drawstripe(&s0, shade, depth); - drawstripe(&s1, shade, depth); + draw_stripe(&s0, shade, depth); + draw_stripe(&s1, shade, depth); } } static inline void -splitpatch(pdf_tensorpatch *p, pdf_tensorpatch *s0, pdf_tensorpatch *s1) +split_patch(pdf_tensor_patch *p, pdf_tensor_patch *s0, pdf_tensor_patch *s1) { /* split all vertical bezier curves in patch, creating two new patches with half the height. */ - splitcurve(p->pole[0], s0->pole[0], s1->pole[0], 1); - splitcurve(p->pole[1], s0->pole[1], s1->pole[1], 1); - splitcurve(p->pole[2], s0->pole[2], s1->pole[2], 1); - splitcurve(p->pole[3], s0->pole[3], s1->pole[3], 1); + split_curve(p->pole[0], s0->pole[0], s1->pole[0], 1); + split_curve(p->pole[1], s0->pole[1], s1->pole[1], 1); + split_curve(p->pole[2], s0->pole[2], s1->pole[2], 1); + split_curve(p->pole[3], s0->pole[3], s1->pole[3], 1); /* interpolate the colors for the two new patches. */ memcpy(s0->color[0], p->color[0], sizeof(s0->color[0])); @@ -211,30 +211,30 @@ splitpatch(pdf_tensorpatch *p, pdf_tensorpatch *s0, pdf_tensorpatch *s1) } static void -drawpatch(fz_shade *shade, pdf_tensorpatch *p, int depth, int origdepth) +draw_patch(fz_shade *shade, pdf_tensor_patch *p, int depth, int origdepth) { - pdf_tensorpatch s0, s1; + pdf_tensor_patch s0, s1; /* split patch into two half-width patches */ - splitpatch(p, &s0, &s1); + split_patch(p, &s0, &s1); depth--; if (depth == 0) { /* if no more subdividing, draw two new patches... */ - drawstripe(&s0, shade, origdepth); - drawstripe(&s1, shade, origdepth); + draw_stripe(&s0, shade, origdepth); + draw_stripe(&s1, shade, origdepth); } else { /* ...otherwise, continue subdividing. */ - drawpatch(shade, &s0, depth, origdepth); - drawpatch(shade, &s1, depth, origdepth); + draw_patch(shade, &s0, depth, origdepth); + draw_patch(shade, &s1, depth, origdepth); } } static inline fz_point -pdf_computetensorinterior( +pdf_compute_tensor_interior( fz_point a, fz_point b, fz_point c, fz_point d, fz_point e, fz_point f, fz_point g, fz_point h) { @@ -260,7 +260,7 @@ pdf_computetensorinterior( } static inline void -pdf_maketensorpatch(pdf_tensorpatch *p, int type, fz_point *pt) +pdf_make_tensor_patch(pdf_tensor_patch *p, int type, fz_point *pt) { if (type == 6) { @@ -281,19 +281,19 @@ pdf_maketensorpatch(pdf_tensorpatch *p, int type, fz_point *pt) /* see equations at page 330 in pdf 1.7 */ - p->pole[1][1] = pdf_computetensorinterior( + p->pole[1][1] = pdf_compute_tensor_interior( p->pole[0][0], p->pole[0][1], p->pole[1][0], p->pole[0][3], p->pole[3][0], p->pole[3][1], p->pole[1][3], p->pole[3][3]); - p->pole[1][2] = pdf_computetensorinterior( + p->pole[1][2] = pdf_compute_tensor_interior( p->pole[0][3], p->pole[0][2], p->pole[1][3], p->pole[0][0], p->pole[3][3], p->pole[3][2], p->pole[1][0], p->pole[3][0]); - p->pole[2][1] = pdf_computetensorinterior( + p->pole[2][1] = pdf_compute_tensor_interior( p->pole[3][0], p->pole[3][1], p->pole[2][0], p->pole[3][3], p->pole[0][0], p->pole[0][1], p->pole[2][3], p->pole[0][3]); - p->pole[2][2] = pdf_computetensorinterior( + p->pole[2][2] = pdf_compute_tensor_interior( p->pole[3][3], p->pole[3][2], p->pole[2][3], p->pole[3][0], p->pole[0][3], p->pole[0][2], p->pole[2][0], p->pole[0][0]); } @@ -323,7 +323,7 @@ pdf_maketensorpatch(pdf_tensorpatch *p, int type, fz_point *pt) /* Sample various functions into lookup tables */ static void -pdf_samplecompositeshadefunction(fz_shade *shade, pdf_function *func, float t0, float t1) +pdf_sample_composite_shade_function(fz_shade *shade, pdf_function *func, float t0, float t1) { int i; float t; @@ -331,13 +331,13 @@ pdf_samplecompositeshadefunction(fz_shade *shade, pdf_function *func, float t0, for (i = 0; i < 256; i++) { t = t0 + (i / 255.0f) * (t1 - t0); - pdf_evalfunction(func, &t, 1, shade->function[i], shade->colorspace->n); + pdf_eval_function(func, &t, 1, shade->function[i], shade->colorspace->n); shade->function[i][shade->colorspace->n] = 1; } } static void -pdf_samplecomponentshadefunction(fz_shade *shade, int funcs, pdf_function **func, float t0, float t1) +pdf_sample_component_shade_function(fz_shade *shade, int funcs, pdf_function **func, float t0, float t1) { int i, k; float t; @@ -346,25 +346,25 @@ pdf_samplecomponentshadefunction(fz_shade *shade, int funcs, pdf_function **func { t = t0 + (i / 255.0f) * (t1 - t0); for (k = 0; k < funcs; k++) - pdf_evalfunction(func[k], &t, 1, &shade->function[i][k], 1); + pdf_eval_function(func[k], &t, 1, &shade->function[i][k], 1); shade->function[i][k] = 1; } } static void -pdf_sampleshadefunction(fz_shade *shade, int funcs, pdf_function **func, float t0, float t1) +pdf_sample_shade_function(fz_shade *shade, int funcs, pdf_function **func, float t0, float t1) { - shade->usefunction = 1; + shade->use_function = 1; if (funcs == 1) - pdf_samplecompositeshadefunction(shade, func[0], t0, t1); + pdf_sample_composite_shade_function(shade, func[0], t0, t1); else - pdf_samplecomponentshadefunction(shade, funcs, func, t0, t1); + pdf_sample_component_shade_function(shade, funcs, func, t0, t1); } /* Type 1-3 -- Function-based, axial and radial shadings */ static void -pdf_loadfunctionbasedshading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, pdf_function *func) +pdf_load_function_based_shading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, pdf_function *func) { fz_obj *obj; float x0, y0, x1, y1; @@ -375,23 +375,23 @@ pdf_loadfunctionbasedshading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, pdf_ float xn, yn; int i; - pdf_logshade("load type1 (function-based) shading\n"); + pdf_log_shade("load type1 (function-based) shading\n"); x0 = y0 = 0; x1 = y1 = 1; - obj = fz_dictgets(dict, "Domain"); - if (fz_arraylen(obj) == 4) + obj = fz_dict_gets(dict, "Domain"); + if (fz_array_len(obj) == 4) { - x0 = fz_toreal(fz_arrayget(obj, 0)); - x1 = fz_toreal(fz_arrayget(obj, 1)); - y0 = fz_toreal(fz_arrayget(obj, 2)); - y1 = fz_toreal(fz_arrayget(obj, 3)); + x0 = fz_to_real(fz_array_get(obj, 0)); + x1 = fz_to_real(fz_array_get(obj, 1)); + y0 = fz_to_real(fz_array_get(obj, 2)); + y1 = fz_to_real(fz_array_get(obj, 3)); } matrix = fz_identity; - obj = fz_dictgets(dict, "Matrix"); - if (fz_arraylen(obj) == 6) - matrix = pdf_tomatrix(obj); + obj = fz_dict_gets(dict, "Matrix"); + if (fz_array_len(obj) == 6) + matrix = pdf_to_matrix(obj); for (yy = 0; yy < FUNSEGS; yy++) { @@ -415,22 +415,22 @@ pdf_loadfunctionbasedshading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, pdf_ fv[0] = v[i].x; fv[1] = v[i].y; - pdf_evalfunction(func, fv, 2, v[i].c, shade->colorspace->n); + pdf_eval_function(func, fv, 2, v[i].c, shade->colorspace->n); pt.x = v[i].x; pt.y = v[i].y; - pt = fz_transformpoint(matrix, pt); + pt = fz_transform_point(matrix, pt); v[i].x = pt.x; v[i].y = pt.y; } - pdf_addquad(shade, &v[0], &v[1], &v[2], &v[3]); + pdf_add_quad(shade, &v[0], &v[1], &v[2], &v[3]); } } } static void -pdf_loadaxialshading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, int funcs, pdf_function **func) +pdf_load_axial_shading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, int funcs, pdf_function **func) { fz_obj *obj; float d0, d1; @@ -438,32 +438,32 @@ pdf_loadaxialshading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, int funcs, p float x0, y0, x1, y1; struct vertex p1, p2; - pdf_logshade("load type2 (axial) shading\n"); + pdf_log_shade("load type2 (axial) shading\n"); - obj = fz_dictgets(dict, "Coords"); - x0 = fz_toreal(fz_arrayget(obj, 0)); - y0 = fz_toreal(fz_arrayget(obj, 1)); - x1 = fz_toreal(fz_arrayget(obj, 2)); - y1 = fz_toreal(fz_arrayget(obj, 3)); + obj = fz_dict_gets(dict, "Coords"); + x0 = fz_to_real(fz_array_get(obj, 0)); + y0 = fz_to_real(fz_array_get(obj, 1)); + x1 = fz_to_real(fz_array_get(obj, 2)); + y1 = fz_to_real(fz_array_get(obj, 3)); d0 = 0; d1 = 1; - obj = fz_dictgets(dict, "Domain"); - if (fz_arraylen(obj) == 2) + obj = fz_dict_gets(dict, "Domain"); + if (fz_array_len(obj) == 2) { - d0 = fz_toreal(fz_arrayget(obj, 0)); - d1 = fz_toreal(fz_arrayget(obj, 1)); + d0 = fz_to_real(fz_array_get(obj, 0)); + d1 = fz_to_real(fz_array_get(obj, 1)); } e0 = e1 = 0; - obj = fz_dictgets(dict, "Extend"); - if (fz_arraylen(obj) == 2) + obj = fz_dict_gets(dict, "Extend"); + if (fz_array_len(obj) == 2) { - e0 = fz_tobool(fz_arrayget(obj, 0)); - e1 = fz_tobool(fz_arrayget(obj, 1)); + e0 = fz_to_bool(fz_array_get(obj, 0)); + e1 = fz_to_bool(fz_array_get(obj, 1)); } - pdf_sampleshadefunction(shade, funcs, func, d0, d1); + pdf_sample_shade_function(shade, funcs, func, d0, d1); shade->type = FZ_LINEAR; @@ -473,16 +473,16 @@ pdf_loadaxialshading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, int funcs, p p1.x = x0; p1.y = y0; p1.c[0] = 0; - pdf_addvertex(shade, &p1); + pdf_add_vertex(shade, &p1); p2.x = x1; p2.y = y1; p2.c[0] = 0; - pdf_addvertex(shade, &p2); + pdf_add_vertex(shade, &p2); } static void -pdf_loadradialshading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, int funcs, pdf_function **func) +pdf_load_radial_shading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, int funcs, pdf_function **func) { fz_obj *obj; float d0, d1; @@ -490,34 +490,34 @@ pdf_loadradialshading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, int funcs, float x0, y0, r0, x1, y1, r1; struct vertex p1, p2; - pdf_logshade("load type3 (radial) shading\n"); + pdf_log_shade("load type3 (radial) shading\n"); - obj = fz_dictgets(dict, "Coords"); - x0 = fz_toreal(fz_arrayget(obj, 0)); - y0 = fz_toreal(fz_arrayget(obj, 1)); - r0 = fz_toreal(fz_arrayget(obj, 2)); - x1 = fz_toreal(fz_arrayget(obj, 3)); - y1 = fz_toreal(fz_arrayget(obj, 4)); - r1 = fz_toreal(fz_arrayget(obj, 5)); + obj = fz_dict_gets(dict, "Coords"); + x0 = fz_to_real(fz_array_get(obj, 0)); + y0 = fz_to_real(fz_array_get(obj, 1)); + r0 = fz_to_real(fz_array_get(obj, 2)); + x1 = fz_to_real(fz_array_get(obj, 3)); + y1 = fz_to_real(fz_array_get(obj, 4)); + r1 = fz_to_real(fz_array_get(obj, 5)); d0 = 0; d1 = 1; - obj = fz_dictgets(dict, "Domain"); - if (fz_arraylen(obj) == 2) + obj = fz_dict_gets(dict, "Domain"); + if (fz_array_len(obj) == 2) { - d0 = fz_toreal(fz_arrayget(obj, 0)); - d1 = fz_toreal(fz_arrayget(obj, 1)); + d0 = fz_to_real(fz_array_get(obj, 0)); + d1 = fz_to_real(fz_array_get(obj, 1)); } e0 = e1 = 0; - obj = fz_dictgets(dict, "Extend"); - if (fz_arraylen(obj) == 2) + obj = fz_dict_gets(dict, "Extend"); + if (fz_array_len(obj) == 2) { - e0 = fz_tobool(fz_arrayget(obj, 0)); - e1 = fz_tobool(fz_arrayget(obj, 1)); + e0 = fz_to_bool(fz_array_get(obj, 0)); + e1 = fz_to_bool(fz_array_get(obj, 1)); } - pdf_sampleshadefunction(shade, funcs, func, d0, d1); + pdf_sample_shade_function(shade, funcs, func, d0, d1); shade->type = FZ_RADIAL; @@ -527,25 +527,25 @@ pdf_loadradialshading(fz_shade *shade, pdf_xref *xref, fz_obj *dict, int funcs, p1.x = x0; p1.y = y0; p1.c[0] = r0; - pdf_addvertex(shade, &p1); + pdf_add_vertex(shade, &p1); p2.x = x1; p2.y = y1; p2.c[0] = r1; - pdf_addvertex(shade, &p2); + pdf_add_vertex(shade, &p2); } /* Type 4-7 -- Triangle and patch mesh shadings */ static inline float -readsample(fz_stream *stream, int bits, float min, float max) +read_sample(fz_stream *stream, int bits, float min, float max) { /* we use pow(2,x) because (1<x0 = p->y0 = 0; p->x1 = p->y1 = 1; - for (i = 0; i < FZ_MAXCOLORS; i++) + for (i = 0; i < FZ_MAX_COLORS; i++) { p->c0[i] = 0; p->c1[i] = 1; } - p->vprow = fz_toint(fz_dictgets(dict, "VerticesPerRow")); - p->bpflag = fz_toint(fz_dictgets(dict, "BitsPerFlag")); - p->bpcoord = fz_toint(fz_dictgets(dict, "BitsPerCoordinate")); - p->bpcomp = fz_toint(fz_dictgets(dict, "BitsPerComponent")); + p->vprow = fz_to_int(fz_dict_gets(dict, "VerticesPerRow")); + p->bpflag = fz_to_int(fz_dict_gets(dict, "BitsPerFlag")); + p->bpcoord = fz_to_int(fz_dict_gets(dict, "BitsPerCoordinate")); + p->bpcomp = fz_to_int(fz_dict_gets(dict, "BitsPerComponent")); - obj = fz_dictgets(dict, "Decode"); - if (fz_arraylen(obj) >= 6) + obj = fz_dict_gets(dict, "Decode"); + if (fz_array_len(obj) >= 6) { - n = (fz_arraylen(obj) - 4) / 2; - p->x0 = fz_toreal(fz_arrayget(obj, 0)); - p->x1 = fz_toreal(fz_arrayget(obj, 1)); - p->y0 = fz_toreal(fz_arrayget(obj, 2)); - p->y1 = fz_toreal(fz_arrayget(obj, 3)); + n = (fz_array_len(obj) - 4) / 2; + p->x0 = fz_to_real(fz_array_get(obj, 0)); + p->x1 = fz_to_real(fz_array_get(obj, 1)); + p->y0 = fz_to_real(fz_array_get(obj, 2)); + p->y1 = fz_to_real(fz_array_get(obj, 3)); for (i = 0; i < n; i++) { - p->c0[i] = fz_toreal(fz_arrayget(obj, 4 + i * 2)); - p->c1[i] = fz_toreal(fz_arrayget(obj, 5 + i * 2)); + p->c0[i] = fz_to_real(fz_array_get(obj, 4 + i * 2)); + p->c1[i] = fz_to_real(fz_array_get(obj, 5 + i * 2)); } } @@ -608,89 +608,89 @@ pdf_loadmeshparams(pdf_xref *xref, fz_obj *dict, struct meshparams *p) } static void -pdf_loadtype4shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict, +pdf_load_type4_shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict, int funcs, pdf_function **func, fz_stream *stream) { - struct meshparams p; + struct mesh_params p; struct vertex va, vb, vc, vd; int ncomp; int flag; int i; - pdf_logshade("load type4 (free-form triangle mesh) shading\n"); + pdf_log_shade("load type4 (free-form triangle mesh) shading\n"); - pdf_loadmeshparams(xref, dict, &p); + pdf_load_mesh_params(xref, dict, &p); if (funcs > 0) { ncomp = 1; - pdf_sampleshadefunction(shade, funcs, func, p.c0[0], p.c1[0]); + pdf_sample_shade_function(shade, funcs, func, p.c0[0], p.c1[0]); } else ncomp = shade->colorspace->n; - while (!fz_iseofbits(stream)) + while (!fz_is_eof_bits(stream)) { - flag = fz_readbits(stream, p.bpflag); - vd.x = readsample(stream, p.bpcoord, p.x0, p.x1); - vd.y = readsample(stream, p.bpcoord, p.y0, p.y1); + flag = fz_read_bits(stream, p.bpflag); + vd.x = read_sample(stream, p.bpcoord, p.x0, p.x1); + vd.y = read_sample(stream, p.bpcoord, p.y0, p.y1); for (i = 0; i < ncomp; i++) - vd.c[i] = readsample(stream, p.bpcomp, p.c0[i], p.c1[i]); + vd.c[i] = read_sample(stream, p.bpcomp, p.c0[i], p.c1[i]); switch (flag) { case 0: /* start new triangle */ va = vd; - fz_readbits(stream, p.bpflag); - vb.x = readsample(stream, p.bpcoord, p.x0, p.x1); - vb.y = readsample(stream, p.bpcoord, p.y0, p.y1); + fz_read_bits(stream, p.bpflag); + vb.x = read_sample(stream, p.bpcoord, p.x0, p.x1); + vb.y = read_sample(stream, p.bpcoord, p.y0, p.y1); for (i = 0; i < ncomp; i++) - vb.c[i] = readsample(stream, p.bpcomp, p.c0[i], p.c1[i]); + vb.c[i] = read_sample(stream, p.bpcomp, p.c0[i], p.c1[i]); - fz_readbits(stream, p.bpflag); - vc.x = readsample(stream, p.bpcoord, p.x0, p.x1); - vc.y = readsample(stream, p.bpcoord, p.y0, p.y1); + fz_read_bits(stream, p.bpflag); + vc.x = read_sample(stream, p.bpcoord, p.x0, p.x1); + vc.y = read_sample(stream, p.bpcoord, p.y0, p.y1); for (i = 0; i < ncomp; i++) - vc.c[i] = readsample(stream, p.bpcomp, p.c0[i], p.c1[i]); + vc.c[i] = read_sample(stream, p.bpcomp, p.c0[i], p.c1[i]); - pdf_addtriangle(shade, &va, &vb, &vc); + pdf_add_triangle(shade, &va, &vb, &vc); break; case 1: /* Vb, Vc, Vd */ va = vb; vb = vc; vc = vd; - pdf_addtriangle(shade, &va, &vb, &vc); + pdf_add_triangle(shade, &va, &vb, &vc); break; case 2: /* Va, Vc, Vd */ vb = vc; vc = vd; - pdf_addtriangle(shade, &va, &vb, &vc); + pdf_add_triangle(shade, &va, &vb, &vc); break; } } } static void -pdf_loadtype5shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict, +pdf_load_type5_shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict, int funcs, pdf_function **func, fz_stream *stream) { - struct meshparams p; + struct mesh_params p; struct vertex *buf, *ref; int first; int ncomp; int i, k; - pdf_logshade("load type5 (lattice-form triangle mesh) shading\n"); + pdf_log_shade("load type5 (lattice-form triangle mesh) shading\n"); - pdf_loadmeshparams(xref, dict, &p); + pdf_load_mesh_params(xref, dict, &p); if (funcs > 0) { ncomp = 1; - pdf_sampleshadefunction(shade, funcs, func, p.c0[0], p.c1[0]); + pdf_sample_shade_function(shade, funcs, func, p.c0[0], p.c1[0]); } else ncomp = shade->colorspace->n; @@ -699,19 +699,19 @@ pdf_loadtype5shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict, buf = fz_calloc(p.vprow, sizeof(struct vertex)); first = 1; - while (!fz_iseofbits(stream)) + while (!fz_is_eof_bits(stream)) { for (i = 0; i < p.vprow; i++) { - buf[i].x = readsample(stream, p.bpcoord, p.x0, p.x1); - buf[i].y = readsample(stream, p.bpcoord, p.y0, p.y1); + buf[i].x = read_sample(stream, p.bpcoord, p.x0, p.x1); + buf[i].y = read_sample(stream, p.bpcoord, p.y0, p.y1); for (k = 0; k < ncomp; k++) - buf[i].c[k] = readsample(stream, p.bpcomp, p.c0[k], p.c1[k]); + buf[i].c[k] = read_sample(stream, p.bpcomp, p.c0[k], p.c1[k]); } if (!first) for (i = 0; i < p.vprow - 1; i++) - pdf_addquad(shade, + pdf_add_quad(shade, &ref[i], &ref[i+1], &buf[i+1], &buf[i]); memcpy(ref, buf, p.vprow * sizeof(struct vertex)); @@ -725,39 +725,39 @@ pdf_loadtype5shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict, /* Type 6 & 7 -- Patch mesh shadings */ static void -pdf_loadtype6shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict, +pdf_load_type6_shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict, int funcs, pdf_function **func, fz_stream *stream) { - struct meshparams p; + struct mesh_params p; int haspatch, hasprevpatch; - float prevc[4][FZ_MAXCOLORS]; + float prevc[4][FZ_MAX_COLORS]; fz_point prevp[12]; int ncomp; int i, k; - pdf_logshade("load type6 (coons patch mesh) shading\n"); + pdf_log_shade("load type6 (coons patch mesh) shading\n"); - pdf_loadmeshparams(xref, dict, &p); + pdf_load_mesh_params(xref, dict, &p); if (funcs > 0) { ncomp = 1; - pdf_sampleshadefunction(shade, funcs, func, p.c0[0], p.c1[0]); + pdf_sample_shade_function(shade, funcs, func, p.c0[0], p.c1[0]); } else ncomp = shade->colorspace->n; hasprevpatch = 0; - while (!fz_iseofbits(stream)) + while (!fz_is_eof_bits(stream)) { - float c[4][FZ_MAXCOLORS]; + float c[4][FZ_MAX_COLORS]; fz_point v[12]; int startcolor; int startpt; int flag; - flag = fz_readbits(stream, p.bpflag); + flag = fz_read_bits(stream, p.bpflag); if (flag == 0) { @@ -772,14 +772,14 @@ pdf_loadtype6shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict, for (i = startpt; i < 12; i++) { - v[i].x = readsample(stream, p.bpcoord, p.x0, p.x1); - v[i].y = readsample(stream, p.bpcoord, p.y0, p.y1); + v[i].x = read_sample(stream, p.bpcoord, p.x0, p.x1); + v[i].y = read_sample(stream, p.bpcoord, p.y0, p.y1); } for (i = startcolor; i < 4; i++) { for (k = 0; k < ncomp; k++) - c[i][k] = readsample(stream, p.bpcomp, p.c0[k], p.c1[k]); + c[i][k] = read_sample(stream, p.bpcomp, p.c0[k], p.c1[k]); } haspatch = 0; @@ -824,14 +824,14 @@ pdf_loadtype6shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict, if (haspatch) { - pdf_tensorpatch patch; + pdf_tensor_patch patch; - pdf_maketensorpatch(&patch, 6, v); + pdf_make_tensor_patch(&patch, 6, v); for (i = 0; i < 4; i++) memcpy(patch.color[i], c[i], ncomp * sizeof(float)); - drawpatch(shade, &patch, SUBDIV, SUBDIV); + draw_patch(shade, &patch, SUBDIV, SUBDIV); for (i = 0; i < 12; i++) prevp[i] = v[i]; @@ -845,39 +845,39 @@ pdf_loadtype6shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict, } static void -pdf_loadtype7shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict, +pdf_load_type7_shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict, int funcs, pdf_function **func, fz_stream *stream) { - struct meshparams p; + struct mesh_params p; int haspatch, hasprevpatch; - float prevc[4][FZ_MAXCOLORS]; + float prevc[4][FZ_MAX_COLORS]; fz_point prevp[16]; int ncomp; int i, k; - pdf_logshade("load type7 (tensor-product patch mesh) shading\n"); + pdf_log_shade("load type7 (tensor-product patch mesh) shading\n"); - pdf_loadmeshparams(xref, dict, &p); + pdf_load_mesh_params(xref, dict, &p); if (funcs > 0) { ncomp = 1; - pdf_sampleshadefunction(shade, funcs, func, p.c0[0], p.c1[0]); + pdf_sample_shade_function(shade, funcs, func, p.c0[0], p.c1[0]); } else ncomp = shade->colorspace->n; hasprevpatch = 0; - while (!fz_iseofbits(stream)) + while (!fz_is_eof_bits(stream)) { - float c[4][FZ_MAXCOLORS]; + float c[4][FZ_MAX_COLORS]; fz_point v[16]; int startcolor; int startpt; int flag; - flag = fz_readbits(stream, p.bpflag); + flag = fz_read_bits(stream, p.bpflag); if (flag == 0) { @@ -892,14 +892,14 @@ pdf_loadtype7shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict, for (i = startpt; i < 16; i++) { - v[i].x = readsample(stream, p.bpcoord, p.x0, p.x1); - v[i].y = readsample(stream, p.bpcoord, p.y0, p.y1); + v[i].x = read_sample(stream, p.bpcoord, p.x0, p.x1); + v[i].y = read_sample(stream, p.bpcoord, p.y0, p.y1); } for (i = startcolor; i < 4; i++) { for (k = 0; k < ncomp; k++) - c[i][k] = readsample(stream, p.bpcomp, p.c0[k], p.c1[k]); + c[i][k] = read_sample(stream, p.bpcomp, p.c0[k], p.c1[k]); } haspatch = 0; @@ -944,20 +944,20 @@ pdf_loadtype7shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict, if (haspatch) { - pdf_tensorpatch patch; + pdf_tensor_patch patch; - pdf_maketensorpatch(&patch, 7, v); + pdf_make_tensor_patch(&patch, 7, v); for (i = 0; i < 4; i++) memcpy(patch.color[i], c[i], ncomp * sizeof(float)); - drawpatch(shade, &patch, SUBDIV, SUBDIV); + draw_patch(shade, &patch, SUBDIV, SUBDIV); for (i = 0; i < 16; i++) prevp[i] = v[i]; for (i = 0; i < 4; i++) - memcpy(prevc[i], c[i], FZ_MAXCOLORS * sizeof(float)); + memcpy(prevc[i], c[i], FZ_MAX_COLORS * sizeof(float)); hasprevpatch = 1; } @@ -967,84 +967,84 @@ pdf_loadtype7shade(fz_shade *shade, pdf_xref *xref, fz_obj *dict, /* Load all of the shading dictionary parameters, then switch on the shading type. */ static fz_error -pdf_loadshadingdict(fz_shade **shadep, pdf_xref *xref, fz_obj *dict, fz_matrix transform) +pdf_load_shading_dict(fz_shade **shadep, pdf_xref *xref, fz_obj *dict, fz_matrix transform) { fz_error error; fz_shade *shade; - pdf_function *func[FZ_MAXCOLORS] = { nil }; - fz_stream *stream = nil; + pdf_function *func[FZ_MAX_COLORS] = { NULL }; + fz_stream *stream = NULL; fz_obj *obj; int funcs; int type; int i; - pdf_logshade("load shading dict (%d %d R) {\n", fz_tonum(dict), fz_togen(dict)); + pdf_log_shade("load shading dict (%d %d R) {\n", fz_to_num(dict), fz_to_gen(dict)); shade = fz_malloc(sizeof(fz_shade)); shade->refs = 1; shade->type = FZ_MESH; - shade->usebackground = 0; - shade->usefunction = 0; + shade->use_background = 0; + shade->use_function = 0; shade->matrix = transform; - shade->bbox = fz_infiniterect; + shade->bbox = fz_infinite_rect; shade->extend[0] = 0; shade->extend[1] = 0; - shade->meshlen = 0; - shade->meshcap = 0; - shade->mesh = nil; + shade->mesh_len = 0; + shade->mesh_cap = 0; + shade->mesh = NULL; - shade->colorspace = nil; + shade->colorspace = NULL; funcs = 0; - obj = fz_dictgets(dict, "ShadingType"); - type = fz_toint(obj); + obj = fz_dict_gets(dict, "ShadingType"); + type = fz_to_int(obj); - obj = fz_dictgets(dict, "ColorSpace"); + obj = fz_dict_gets(dict, "ColorSpace"); if (!obj) { - fz_dropshade(shade); + fz_drop_shade(shade); return fz_throw("shading colorspace is missing"); } - error = pdf_loadcolorspace(&shade->colorspace, xref, obj); + error = pdf_load_colorspace(&shade->colorspace, xref, obj); if (error) { - fz_dropshade(shade); - return fz_rethrow(error, "cannot load colorspace (%d %d R)", fz_tonum(obj), fz_togen(obj)); + fz_drop_shade(shade); + return fz_rethrow(error, "cannot load colorspace (%d %d R)", fz_to_num(obj), fz_to_gen(obj)); } - pdf_logshade("colorspace %s\n", shade->colorspace->name); + pdf_log_shade("colorspace %s\n", shade->colorspace->name); - obj = fz_dictgets(dict, "Background"); + obj = fz_dict_gets(dict, "Background"); if (obj) { - pdf_logshade("background\n"); - shade->usebackground = 1; + pdf_log_shade("background\n"); + shade->use_background = 1; for (i = 0; i < shade->colorspace->n; i++) - shade->background[i] = fz_toreal(fz_arrayget(obj, i)); + shade->background[i] = fz_to_real(fz_array_get(obj, i)); } - obj = fz_dictgets(dict, "BBox"); - if (fz_isarray(obj)) + obj = fz_dict_gets(dict, "BBox"); + if (fz_is_array(obj)) { - shade->bbox = pdf_torect(obj); + shade->bbox = pdf_to_rect(obj); } - obj = fz_dictgets(dict, "Function"); - if (fz_isdict(obj)) + obj = fz_dict_gets(dict, "Function"); + if (fz_is_dict(obj)) { funcs = 1; - error = pdf_loadfunction(&func[0], xref, obj); + error = pdf_load_function(&func[0], xref, obj); if (error) { - error = fz_rethrow(error, "cannot load shading function (%d %d R)", fz_tonum(obj), fz_togen(obj)); + error = fz_rethrow(error, "cannot load shading function (%d %d R)", fz_to_num(obj), fz_to_gen(obj)); goto cleanup; } } - else if (fz_isarray(obj)) + else if (fz_is_array(obj)) { - funcs = fz_arraylen(obj); + funcs = fz_array_len(obj); if (funcs != 1 && funcs != shade->colorspace->n) { error = fz_throw("incorrect number of shading functions"); @@ -1053,10 +1053,10 @@ pdf_loadshadingdict(fz_shade **shadep, pdf_xref *xref, fz_obj *dict, fz_matrix t for (i = 0; i < funcs; i++) { - error = pdf_loadfunction(&func[i], xref, fz_arrayget(obj, i)); + error = pdf_load_function(&func[i], xref, fz_array_get(obj, i)); if (error) { - error = fz_rethrow(error, "cannot load shading function (%d %d R)", fz_tonum(obj), fz_togen(obj)); + error = fz_rethrow(error, "cannot load shading function (%d %d R)", fz_to_num(obj), fz_to_gen(obj)); goto cleanup; } } @@ -1064,23 +1064,23 @@ pdf_loadshadingdict(fz_shade **shadep, pdf_xref *xref, fz_obj *dict, fz_matrix t if (type >= 4 && type <= 7) { - error = pdf_openstream(&stream, xref, fz_tonum(dict), fz_togen(dict)); + error = pdf_open_stream(&stream, xref, fz_to_num(dict), fz_to_gen(dict)); if (error) { - error = fz_rethrow(error, "cannot open shading stream (%d %d R)", fz_tonum(dict), fz_togen(dict)); + error = fz_rethrow(error, "cannot open shading stream (%d %d R)", fz_to_num(dict), fz_to_gen(dict)); goto cleanup; } } switch (type) { - case 1: pdf_loadfunctionbasedshading(shade, xref, dict, func[0]); break; - case 2: pdf_loadaxialshading(shade, xref, dict, funcs, func); break; - case 3: pdf_loadradialshading(shade, xref, dict, funcs, func); break; - case 4: pdf_loadtype4shade(shade, xref, dict, funcs, func, stream); break; - case 5: pdf_loadtype5shade(shade, xref, dict, funcs, func, stream); break; - case 6: pdf_loadtype6shade(shade, xref, dict, funcs, func, stream); break; - case 7: pdf_loadtype7shade(shade, xref, dict, funcs, func, stream); break; + case 1: pdf_load_function_based_shading(shade, xref, dict, func[0]); break; + case 2: pdf_load_axial_shading(shade, xref, dict, funcs, func); break; + case 3: pdf_load_radial_shading(shade, xref, dict, funcs, func); break; + case 4: pdf_load_type4_shade(shade, xref, dict, funcs, func, stream); break; + case 5: pdf_load_type5_shade(shade, xref, dict, funcs, func, stream); break; + case 6: pdf_load_type6_shade(shade, xref, dict, funcs, func, stream); break; + case 7: pdf_load_type7_shade(shade, xref, dict, funcs, func, stream); break; default: error = fz_throw("unknown shading type: %d", type); goto cleanup; @@ -1090,9 +1090,9 @@ pdf_loadshadingdict(fz_shade **shadep, pdf_xref *xref, fz_obj *dict, fz_matrix t fz_close(stream); for (i = 0; i < funcs; i++) if (func[i]) - pdf_dropfunction(func[i]); + pdf_drop_function(func[i]); - pdf_logshade("}\n"); + pdf_log_shade("}\n"); *shadep = shade; return fz_okay; @@ -1102,35 +1102,35 @@ cleanup: fz_close(stream); for (i = 0; i < funcs; i++) if (func[i]) - pdf_dropfunction(func[i]); - fz_dropshade(shade); + pdf_drop_function(func[i]); + fz_drop_shade(shade); - return fz_rethrow(error, "cannot load shading type %d (%d %d R)", type, fz_tonum(dict), fz_togen(dict)); + return fz_rethrow(error, "cannot load shading type %d (%d %d R)", type, fz_to_num(dict), fz_to_gen(dict)); } fz_error -pdf_loadshading(fz_shade **shadep, pdf_xref *xref, fz_obj *dict) +pdf_load_shading(fz_shade **shadep, pdf_xref *xref, fz_obj *dict) { fz_error error; fz_matrix mat; fz_obj *obj; - if ((*shadep = pdf_finditem(xref->store, fz_dropshade, dict))) + if ((*shadep = pdf_find_item(xref->store, fz_drop_shade, dict))) { - fz_keepshade(*shadep); + fz_keep_shade(*shadep); return fz_okay; } /* Type 2 pattern dictionary */ - if (fz_dictgets(dict, "PatternType")) + if (fz_dict_gets(dict, "PatternType")) { - pdf_logshade("load shading pattern (%d %d R) {\n", fz_tonum(dict), fz_togen(dict)); + pdf_log_shade("load shading pattern (%d %d R) {\n", fz_to_num(dict), fz_to_gen(dict)); - obj = fz_dictgets(dict, "Matrix"); + obj = fz_dict_gets(dict, "Matrix"); if (obj) { - mat = pdf_tomatrix(obj); - pdf_logshade("matrix [%g %g %g %g %g %g]\n", + mat = pdf_to_matrix(obj); + pdf_log_shade("matrix [%g %g %g %g %g %g]\n", mat.a, mat.b, mat.c, mat.d, mat.e, mat.f); } else @@ -1138,35 +1138,35 @@ pdf_loadshading(fz_shade **shadep, pdf_xref *xref, fz_obj *dict) mat = fz_identity; } - obj = fz_dictgets(dict, "ExtGState"); + obj = fz_dict_gets(dict, "ExtGState"); if (obj) { - if (fz_dictgets(obj, "CA") || fz_dictgets(obj, "ca")) + if (fz_dict_gets(obj, "CA") || fz_dict_gets(obj, "ca")) { fz_warn("shading with alpha not supported"); } } - obj = fz_dictgets(dict, "Shading"); + obj = fz_dict_gets(dict, "Shading"); if (!obj) return fz_throw("syntaxerror: missing shading dictionary"); - error = pdf_loadshadingdict(shadep, xref, obj, mat); + error = pdf_load_shading_dict(shadep, xref, obj, mat); if (error) - return fz_rethrow(error, "cannot load shading dictionary (%d %d R)", fz_tonum(obj), fz_togen(obj)); + return fz_rethrow(error, "cannot load shading dictionary (%d %d R)", fz_to_num(obj), fz_to_gen(obj)); - pdf_logshade("}\n"); + pdf_log_shade("}\n"); } /* Naked shading dictionary */ else { - error = pdf_loadshadingdict(shadep, xref, dict, fz_identity); + error = pdf_load_shading_dict(shadep, xref, dict, fz_identity); if (error) - return fz_rethrow(error, "cannot load shading dictionary (%d %d R)", fz_tonum(dict), fz_togen(dict)); + return fz_rethrow(error, "cannot load shading dictionary (%d %d R)", fz_to_num(dict), fz_to_gen(dict)); } - pdf_storeitem(xref->store, fz_keepshade, fz_dropshade, dict, *shadep); + pdf_store_item(xref->store, fz_keep_shade, fz_drop_shade, dict, *shadep); return fz_okay; } diff --git a/pdf/pdf_store.c b/pdf/pdf_store.c index d6be2088..cccfc76c 100644 --- a/pdf/pdf_store.c +++ b/pdf/pdf_store.c @@ -5,7 +5,7 @@ typedef struct pdf_item_s pdf_item; struct pdf_item_s { - void *dropfunc; + void *drop_func; fz_obj *key; void *val; int age; @@ -14,29 +14,29 @@ struct pdf_item_s struct refkey { - void *dropfunc; + void *drop_func; int num; int gen; }; struct pdf_store_s { - fz_hashtable *hash; /* hash for num/gen keys */ + fz_hash_table *hash; /* hash for num/gen keys */ pdf_item *root; /* linked list for everything else */ }; pdf_store * -pdf_newstore(void) +pdf_new_store(void) { pdf_store *store; store = fz_malloc(sizeof(pdf_store)); - store->hash = fz_newhash(4096, sizeof(struct refkey)); - store->root = nil; + store->hash = fz_new_hash_table(4096, sizeof(struct refkey)); + store->root = NULL; return store; } void -pdf_storeitem(pdf_store *store, void *keepfunc, void *dropfunc, fz_obj *key, void *val) +pdf_store_item(pdf_store *store, void *keepfunc, void *drop_func, fz_obj *key, void *val) { pdf_item *item; @@ -44,47 +44,47 @@ pdf_storeitem(pdf_store *store, void *keepfunc, void *dropfunc, fz_obj *key, voi return; item = fz_malloc(sizeof(pdf_item)); - item->dropfunc = dropfunc; - item->key = fz_keepobj(key); + item->drop_func = drop_func; + item->key = fz_keep_obj(key); item->val = ((void*(*)(void*))keepfunc)(val); item->age = 0; - item->next = nil; + item->next = NULL; - if (fz_isindirect(key)) + if (fz_is_indirect(key)) { struct refkey refkey; - pdf_logrsrc("store item (%d %d R) ptr=%p\n", fz_tonum(key), fz_togen(key), val); - refkey.dropfunc = dropfunc; - refkey.num = fz_tonum(key); - refkey.gen = fz_togen(key); - fz_hashinsert(store->hash, &refkey, item); + pdf_log_rsrc("store item (%d %d R) ptr=%p\n", fz_to_num(key), fz_to_gen(key), val); + refkey.drop_func = drop_func; + refkey.num = fz_to_num(key); + refkey.gen = fz_to_gen(key); + fz_hash_insert(store->hash, &refkey, item); } else { - pdf_logrsrc("store item (...) = %p\n", val); + pdf_log_rsrc("store item (...) = %p\n", val); item->next = store->root; store->root = item; } } void * -pdf_finditem(pdf_store *store, void *dropfunc, fz_obj *key) +pdf_find_item(pdf_store *store, void *drop_func, fz_obj *key) { struct refkey refkey; pdf_item *item; if (!store) - return nil; + return NULL; - if (key == nil) - return nil; + if (key == NULL) + return NULL; - if (fz_isindirect(key)) + if (fz_is_indirect(key)) { - refkey.dropfunc = dropfunc; - refkey.num = fz_tonum(key); - refkey.gen = fz_togen(key); - item = fz_hashfind(store->hash, &refkey); + refkey.drop_func = drop_func; + refkey.num = fz_to_num(key); + refkey.gen = fz_to_gen(key); + item = fz_hash_find(store->hash, &refkey); if (item) { item->age = 0; @@ -95,7 +95,7 @@ pdf_finditem(pdf_store *store, void *dropfunc, fz_obj *key) { for (item = store->root; item; item = item->next) { - if (item->dropfunc == dropfunc && !fz_objcmp(item->key, key)) + if (item->drop_func == drop_func && !fz_objcmp(item->key, key)) { item->age = 0; return item->val; @@ -103,43 +103,43 @@ pdf_finditem(pdf_store *store, void *dropfunc, fz_obj *key) } } - return nil; + return NULL; } void -pdf_removeitem(pdf_store *store, void *dropfunc, fz_obj *key) +pdf_remove_item(pdf_store *store, void *drop_func, fz_obj *key) { struct refkey refkey; pdf_item *item, *prev, *next; - if (fz_isindirect(key)) + if (fz_is_indirect(key)) { - refkey.dropfunc = dropfunc; - refkey.num = fz_tonum(key); - refkey.gen = fz_togen(key); - item = fz_hashfind(store->hash, &refkey); + refkey.drop_func = drop_func; + refkey.num = fz_to_num(key); + refkey.gen = fz_to_gen(key); + item = fz_hash_find(store->hash, &refkey); if (item) { - fz_hashremove(store->hash, &refkey); - ((void(*)(void*))item->dropfunc)(item->val); - fz_dropobj(item->key); + fz_hash_remove(store->hash, &refkey); + ((void(*)(void*))item->drop_func)(item->val); + fz_drop_obj(item->key); fz_free(item); } } else { - prev = nil; + prev = NULL; for (item = store->root; item; item = next) { next = item->next; - if (item->dropfunc == dropfunc && !fz_objcmp(item->key, key)) + if (item->drop_func == drop_func && !fz_objcmp(item->key, key)) { if (!prev) store->root = next; else prev->next = next; - ((void(*)(void*))item->dropfunc)(item->val); - fz_dropobj(item->key); + ((void(*)(void*))item->drop_func)(item->val); + fz_drop_obj(item->key); fz_free(item); } else @@ -149,27 +149,27 @@ pdf_removeitem(pdf_store *store, void *dropfunc, fz_obj *key) } void -pdf_agestore(pdf_store *store, int maxage) +pdf_age_store(pdf_store *store, int maxage) { struct refkey *refkey; pdf_item *item, *prev, *next; int i; - for (i = 0; i < fz_hashlen(store->hash); i++) + for (i = 0; i < fz_hash_len(store->hash); i++) { - refkey = fz_hashgetkey(store->hash, i); - item = fz_hashgetval(store->hash, i); + refkey = fz_hash_get_key(store->hash, i); + item = fz_hash_get_val(store->hash, i); if (item && ++item->age > maxage) { - fz_hashremove(store->hash, refkey); - ((void(*)(void*))item->dropfunc)(item->val); - fz_dropobj(item->key); + fz_hash_remove(store->hash, refkey); + ((void(*)(void*))item->drop_func)(item->val); + fz_drop_obj(item->key); fz_free(item); i--; /* items with same hash may move into place */ } } - prev = nil; + prev = NULL; for (item = store->root; item; item = next) { next = item->next; @@ -179,8 +179,8 @@ pdf_agestore(pdf_store *store, int maxage) store->root = next; else prev->next = next; - ((void(*)(void*))item->dropfunc)(item->val); - fz_dropobj(item->key); + ((void(*)(void*))item->drop_func)(item->val); + fz_drop_obj(item->key); fz_free(item); } else @@ -189,15 +189,15 @@ pdf_agestore(pdf_store *store, int maxage) } void -pdf_freestore(pdf_store *store) +pdf_free_store(pdf_store *store) { - pdf_agestore(store, 0); - fz_freehash(store->hash); + pdf_age_store(store, 0); + fz_free_hash(store->hash); fz_free(store); } void -pdf_debugstore(pdf_store *store) +pdf_debug_store(pdf_store *store) { pdf_item *item; pdf_item *next; @@ -206,10 +206,10 @@ pdf_debugstore(pdf_store *store) printf("-- resource store contents --\n"); - for (i = 0; i < fz_hashlen(store->hash); i++) + for (i = 0; i < fz_hash_len(store->hash); i++) { - refkey = fz_hashgetkey(store->hash, i); - item = fz_hashgetval(store->hash, i); + refkey = fz_hash_get_key(store->hash, i); + item = fz_hash_get_val(store->hash, i); if (item) printf("store[%d] (%d %d R) = %p\n", i, refkey->num, refkey->gen, item->val); } @@ -218,7 +218,7 @@ pdf_debugstore(pdf_store *store) { next = item->next; printf("store[*] "); - fz_debugobj(item->key); + fz_debug_obj(item->key); printf(" = %p\n", item->val); } } diff --git a/pdf/pdf_stream.c b/pdf/pdf_stream.c index cae95a89..79b39d07 100644 --- a/pdf/pdf_stream.c +++ b/pdf/pdf_stream.c @@ -5,44 +5,44 @@ * Check if an object is a stream or not. */ int -pdf_isstream(pdf_xref *xref, int num, int gen) +pdf_is_stream(pdf_xref *xref, int num, int gen) { fz_error error; if (num < 0 || num >= xref->len) return 0; - error = pdf_cacheobject(xref, num, gen); + error = pdf_cache_object(xref, num, gen); if (error) { fz_catch(error, "cannot load object, ignoring error"); return 0; } - return xref->table[num].stmofs > 0; + return xref->table[num].stm_ofs > 0; } /* * Scan stream dictionary for an explicit /Crypt filter */ static int -pdf_streamhascrypt(fz_obj *stm) +pdf_stream_has_crypt(fz_obj *stm) { fz_obj *filters; fz_obj *obj; int i; - filters = fz_dictgetsa(stm, "Filter", "F"); + filters = fz_dict_getsa(stm, "Filter", "F"); if (filters) { - if (!strcmp(fz_toname(filters), "Crypt")) + if (!strcmp(fz_to_name(filters), "Crypt")) return 1; - if (fz_isarray(filters)) + if (fz_is_array(filters)) { - for (i = 0; i < fz_arraylen(filters); i++) + for (i = 0; i < fz_array_len(filters); i++) { - obj = fz_arrayget(filters, i); - if (!strcmp(fz_toname(obj), "Crypt")) + obj = fz_array_get(filters, i); + if (!strcmp(fz_to_name(obj), "Crypt")) return 1; } } @@ -54,58 +54,58 @@ pdf_streamhascrypt(fz_obj *stm) * Create a filter given a name and param dictionary. */ static fz_stream * -buildfilter(fz_stream *chain, pdf_xref * xref, fz_obj * f, fz_obj * p, int num, int gen) +build_filter(fz_stream *chain, pdf_xref * xref, fz_obj * f, fz_obj * p, int num, int gen) { fz_error error; char *s; - s = fz_toname(f); + s = fz_to_name(f); if (!strcmp(s, "ASCIIHexDecode") || !strcmp(s, "AHx")) - return fz_openahxd(chain); + return fz_open_ahxd(chain); else if (!strcmp(s, "ASCII85Decode") || !strcmp(s, "A85")) - return fz_opena85d(chain); + return fz_open_a85d(chain); else if (!strcmp(s, "CCITTFaxDecode") || !strcmp(s, "CCF")) - return fz_openfaxd(chain, p); + return fz_open_faxd(chain, p); else if (!strcmp(s, "DCTDecode") || !strcmp(s, "DCT")) - return fz_opendctd(chain, p); + return fz_open_dctd(chain, p); else if (!strcmp(s, "RunLengthDecode") || !strcmp(s, "RL")) - return fz_openrld(chain); + return fz_open_rld(chain); else if (!strcmp(s, "FlateDecode") || !strcmp(s, "Fl")) { - fz_obj *obj = fz_dictgets(p, "Predictor"); - if (fz_toint(obj) > 1) - return fz_openpredict(fz_openflated(chain), p); - return fz_openflated(chain); + fz_obj *obj = fz_dict_gets(p, "Predictor"); + if (fz_to_int(obj) > 1) + return fz_open_predict(fz_open_flated(chain), p); + return fz_open_flated(chain); } else if (!strcmp(s, "LZWDecode") || !strcmp(s, "LZW")) { - fz_obj *obj = fz_dictgets(p, "Predictor"); - if (fz_toint(obj) > 1) - return fz_openpredict(fz_openlzwd(chain, p), p); - return fz_openlzwd(chain, p); + fz_obj *obj = fz_dict_gets(p, "Predictor"); + if (fz_to_int(obj) > 1) + return fz_open_predict(fz_open_lzwd(chain, p), p); + return fz_open_lzwd(chain, p); } else if (!strcmp(s, "JBIG2Decode")) { - fz_obj *obj = fz_dictgets(p, "JBIG2Globals"); + fz_obj *obj = fz_dict_gets(p, "JBIG2Globals"); if (obj) { fz_buffer *globals; - error = pdf_loadstream(&globals, xref, fz_tonum(obj), fz_togen(obj)); + error = pdf_load_stream(&globals, xref, fz_to_num(obj), fz_to_gen(obj)); if (error) fz_catch(error, "cannot load jbig2 global segments"); - chain = fz_openjbig2d(chain, globals); - fz_dropbuffer(globals); + chain = fz_open_jbig2d(chain, globals); + fz_drop_buffer(globals); return chain; } - return fz_openjbig2d(chain, nil); + return fz_open_jbig2d(chain, NULL); } else if (!strcmp(s, "JPXDecode")) @@ -113,7 +113,7 @@ buildfilter(fz_stream *chain, pdf_xref * xref, fz_obj * f, fz_obj * p, int num, else if (!strcmp(s, "Crypt")) { - pdf_cryptfilter cf; + pdf_crypt_filter cf; fz_obj *name; if (!xref->crypt) @@ -122,17 +122,17 @@ buildfilter(fz_stream *chain, pdf_xref * xref, fz_obj * f, fz_obj * p, int num, return chain; } - name = fz_dictgets(p, "Name"); - if (fz_isname(name) && strcmp(fz_toname(name), "Identity") != 0) + name = fz_dict_gets(p, "Name"); + if (fz_is_name(name) && strcmp(fz_to_name(name), "Identity") != 0) { - fz_obj *obj = fz_dictget(xref->crypt->cf, name); - if (fz_isdict(obj)) + fz_obj *obj = fz_dict_get(xref->crypt->cf, name); + if (fz_is_dict(obj)) { - error = pdf_parsecryptfilter(&cf, obj, xref->crypt->length); + error = pdf_parse_crypt_filter(&cf, obj, xref->crypt->length); if (error) - fz_catch(error, "cannot parse crypt filter (%d %d R)", fz_tonum(obj), fz_togen(obj)); + fz_catch(error, "cannot parse crypt filter (%d %d R)", fz_to_num(obj), fz_to_gen(obj)); else - return pdf_opencrypt(chain, xref->crypt, &cf, num, gen); + return pdf_open_crypt(chain, xref->crypt, &cf, num, gen); } } @@ -149,17 +149,17 @@ buildfilter(fz_stream *chain, pdf_xref * xref, fz_obj * f, fz_obj * p, int num, * Assume ownership of head. */ static fz_stream * -buildfilterchain(fz_stream *chain, pdf_xref *xref, fz_obj *fs, fz_obj *ps, int num, int gen) +build_filter_chain(fz_stream *chain, pdf_xref *xref, fz_obj *fs, fz_obj *ps, int num, int gen) { fz_obj *f; fz_obj *p; int i; - for (i = 0; i < fz_arraylen(fs); i++) + for (i = 0; i < fz_array_len(fs); i++) { - f = fz_arrayget(fs, i); - p = fz_arrayget(ps, i); - chain = buildfilter(chain, xref, f, p, num, gen); + f = fz_array_get(fs, i); + p = fz_array_get(ps, i); + chain = build_filter(chain, xref, f, p, num, gen); } return chain; @@ -171,20 +171,20 @@ buildfilterchain(fz_stream *chain, pdf_xref *xref, fz_obj *fs, fz_obj *ps, int n * stream length, followed by a decryption filter. */ static fz_stream * -pdf_openrawfilter(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int num, int gen) +pdf_open_raw_filter(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int num, int gen) { int hascrypt; int len; /* don't close chain when we close this filter */ - fz_keepstream(chain); + fz_keep_stream(chain); - len = fz_toint(fz_dictgets(stmobj, "Length")); - chain = fz_opennull(chain, len); + len = fz_to_int(fz_dict_gets(stmobj, "Length")); + chain = fz_open_null(chain, len); - hascrypt = pdf_streamhascrypt(stmobj); + hascrypt = pdf_stream_has_crypt(stmobj); if (xref->crypt && !hascrypt) - chain = pdf_opencrypt(chain, xref->crypt, &xref->crypt->stmf, num, gen); + chain = pdf_open_crypt(chain, xref->crypt, &xref->crypt->stmf, num, gen); return chain; } @@ -194,20 +194,20 @@ pdf_openrawfilter(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int num, int * to stream length and decrypting. */ static fz_stream * -pdf_openfilter(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int num, int gen) +pdf_open_filter(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int num, int gen) { fz_obj *filters; fz_obj *params; - filters = fz_dictgetsa(stmobj, "Filter", "F"); - params = fz_dictgetsa(stmobj, "DecodeParms", "DP"); + filters = fz_dict_getsa(stmobj, "Filter", "F"); + params = fz_dict_getsa(stmobj, "DecodeParms", "DP"); - chain = pdf_openrawfilter(chain, xref, stmobj, num, gen); + chain = pdf_open_raw_filter(chain, xref, stmobj, num, gen); - if (fz_isname(filters)) - return buildfilter(chain, xref, filters, params, num, gen); - if (fz_arraylen(filters) > 0) - return buildfilterchain(chain, xref, filters, params, num, gen); + if (fz_is_name(filters)) + return build_filter(chain, xref, filters, params, num, gen); + if (fz_array_len(filters) > 0) + return build_filter_chain(chain, xref, filters, params, num, gen); return chain; } @@ -217,23 +217,23 @@ pdf_openfilter(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int num, int ge * constraining to stream length, and without decryption. */ fz_stream * -pdf_openinlinestream(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int length) +pdf_open_inline_stream(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int length) { fz_obj *filters; fz_obj *params; - filters = fz_dictgetsa(stmobj, "Filter", "F"); - params = fz_dictgetsa(stmobj, "DecodeParms", "DP"); + filters = fz_dict_getsa(stmobj, "Filter", "F"); + params = fz_dict_getsa(stmobj, "DecodeParms", "DP"); /* don't close chain when we close this filter */ - fz_keepstream(chain); + fz_keep_stream(chain); - if (fz_isname(filters)) - return buildfilter(chain, xref, filters, params, 0, 0); - if (fz_arraylen(filters) > 0) - return buildfilterchain(chain, xref, filters, params, 0, 0); + if (fz_is_name(filters)) + return build_filter(chain, xref, filters, params, 0, 0); + if (fz_array_len(filters) > 0) + return build_filter_chain(chain, xref, filters, params, 0, 0); - return fz_opennull(chain, length); + return fz_open_null(chain, length); } /* @@ -241,9 +241,9 @@ pdf_openinlinestream(fz_stream *chain, pdf_xref *xref, fz_obj *stmobj, int lengt * Using xref->file while this is open is a bad idea. */ fz_error -pdf_openrawstream(fz_stream **stmp, pdf_xref *xref, int num, int gen) +pdf_open_raw_stream(fz_stream **stmp, pdf_xref *xref, int num, int gen) { - pdf_xrefentry *x; + pdf_xref_entry *x; fz_error error; if (num < 0 || num >= xref->len) @@ -251,14 +251,14 @@ pdf_openrawstream(fz_stream **stmp, pdf_xref *xref, int num, int gen) x = xref->table + num; - error = pdf_cacheobject(xref, num, gen); + error = pdf_cache_object(xref, num, gen); if (error) return fz_rethrow(error, "cannot load stream object (%d %d R)", num, gen); - if (x->stmofs) + if (x->stm_ofs) { - *stmp = pdf_openrawfilter(xref->file, xref, x->obj, num, gen); - fz_seek(xref->file, x->stmofs, 0); + *stmp = pdf_open_raw_filter(xref->file, xref, x->obj, num, gen); + fz_seek(xref->file, x->stm_ofs, 0); return fz_okay; } @@ -271,9 +271,9 @@ pdf_openrawstream(fz_stream **stmp, pdf_xref *xref, int num, int gen) * Using xref->file while a stream is open is a Bad idea. */ fz_error -pdf_openstream(fz_stream **stmp, pdf_xref *xref, int num, int gen) +pdf_open_stream(fz_stream **stmp, pdf_xref *xref, int num, int gen) { - pdf_xrefentry *x; + pdf_xref_entry *x; fz_error error; if (num < 0 || num >= xref->len) @@ -281,14 +281,14 @@ pdf_openstream(fz_stream **stmp, pdf_xref *xref, int num, int gen) x = xref->table + num; - error = pdf_cacheobject(xref, num, gen); + error = pdf_cache_object(xref, num, gen); if (error) return fz_rethrow(error, "cannot load stream object (%d %d R)", num, gen); - if (x->stmofs) + if (x->stm_ofs) { - *stmp = pdf_openfilter(xref->file, xref, x->obj, num, gen); - fz_seek(xref->file, x->stmofs, 0); + *stmp = pdf_open_filter(xref->file, xref, x->obj, num, gen); + fz_seek(xref->file, x->stm_ofs, 0); return fz_okay; } @@ -296,12 +296,12 @@ pdf_openstream(fz_stream **stmp, pdf_xref *xref, int num, int gen) } fz_error -pdf_openstreamat(fz_stream **stmp, pdf_xref *xref, int num, int gen, fz_obj *dict, int stmofs) +pdf_open_stream_at(fz_stream **stmp, pdf_xref *xref, int num, int gen, fz_obj *dict, int stm_ofs) { - if (stmofs) + if (stm_ofs) { - *stmp = pdf_openfilter(xref->file, xref, dict, num, gen); - fz_seek(xref->file, stmofs, 0); + *stmp = pdf_open_filter(xref->file, xref, dict, num, gen); + fz_seek(xref->file, stm_ofs, 0); return fz_okay; } return fz_throw("object is not a stream"); @@ -311,26 +311,26 @@ pdf_openstreamat(fz_stream **stmp, pdf_xref *xref, int num, int gen, fz_obj *dic * Load raw (compressed but decrypted) contents of a stream into buf. */ fz_error -pdf_loadrawstream(fz_buffer **bufp, pdf_xref *xref, int num, int gen) +pdf_load_raw_stream(fz_buffer **bufp, pdf_xref *xref, int num, int gen) { fz_error error; fz_stream *stm; fz_obj *dict; int len; - error = pdf_loadobject(&dict, xref, num, gen); + error = pdf_load_object(&dict, xref, num, gen); if (error) return fz_rethrow(error, "cannot load stream dictionary (%d %d R)", num, gen); - len = fz_toint(fz_dictgets(dict, "Length")); + len = fz_to_int(fz_dict_gets(dict, "Length")); - fz_dropobj(dict); + fz_drop_obj(dict); - error = pdf_openrawstream(&stm, xref, num, gen); + error = pdf_open_raw_stream(&stm, xref, num, gen); if (error) return fz_rethrow(error, "cannot open raw stream (%d %d R)", num, gen); - error = fz_readall(bufp, stm, len); + error = fz_read_all(bufp, stm, len); if (error) { fz_close(stm); @@ -342,7 +342,7 @@ pdf_loadrawstream(fz_buffer **bufp, pdf_xref *xref, int num, int gen) } static int -pdf_guessfilterlength(int len, char *filter) +pdf_guess_filter_length(int len, char *filter) { if (!strcmp(filter, "ASCIIHexDecode")) return len / 2; @@ -361,30 +361,30 @@ pdf_guessfilterlength(int len, char *filter) * Load uncompressed contents of a stream into buf. */ fz_error -pdf_loadstream(fz_buffer **bufp, pdf_xref *xref, int num, int gen) +pdf_load_stream(fz_buffer **bufp, pdf_xref *xref, int num, int gen) { fz_error error; fz_stream *stm; fz_obj *dict, *obj; int i, len; - error = pdf_openstream(&stm, xref, num, gen); + error = pdf_open_stream(&stm, xref, num, gen); if (error) return fz_rethrow(error, "cannot open stream (%d %d R)", num, gen); - error = pdf_loadobject(&dict, xref, num, gen); + error = pdf_load_object(&dict, xref, num, gen); if (error) return fz_rethrow(error, "cannot load stream dictionary (%d %d R)", num, gen); - len = fz_toint(fz_dictgets(dict, "Length")); - obj = fz_dictgets(dict, "Filter"); - len = pdf_guessfilterlength(len, fz_toname(obj)); - for (i = 0; i < fz_arraylen(obj); i++) - len = pdf_guessfilterlength(len, fz_toname(fz_arrayget(obj, i))); + len = fz_to_int(fz_dict_gets(dict, "Length")); + obj = fz_dict_gets(dict, "Filter"); + len = pdf_guess_filter_length(len, fz_to_name(obj)); + for (i = 0; i < fz_array_len(obj); i++) + len = pdf_guess_filter_length(len, fz_to_name(fz_array_get(obj, i))); - fz_dropobj(dict); + fz_drop_obj(dict); - error = fz_readall(bufp, stm, len); + error = fz_read_all(bufp, stm, len); if (error) { fz_close(stm); diff --git a/pdf/pdf_type3.c b/pdf/pdf_type3.c index 9cc15596..4c22654b 100644 --- a/pdf/pdf_type3.c +++ b/pdf/pdf_type3.c @@ -2,12 +2,12 @@ #include "mupdf.h" fz_error -pdf_loadtype3font(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict) +pdf_load_type3_font(pdf_font_desc **fontdescp, pdf_xref *xref, fz_obj *rdb, fz_obj *dict) { fz_error error; char buf[256]; char *estrings[256]; - pdf_fontdesc *fontdesc; + pdf_font_desc *fontdesc; fz_obj *encoding; fz_obj *widths; fz_obj *charprocs; @@ -17,91 +17,91 @@ pdf_loadtype3font(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *rdb, fz_obj fz_rect bbox; fz_matrix matrix; - obj = fz_dictgets(dict, "Name"); - if (fz_isname(obj)) - fz_strlcpy(buf, fz_toname(obj), sizeof buf); + obj = fz_dict_gets(dict, "Name"); + if (fz_is_name(obj)) + fz_strlcpy(buf, fz_to_name(obj), sizeof buf); else sprintf(buf, "Unnamed-T3"); - fontdesc = pdf_newfontdesc(); + fontdesc = pdf_new_font_desc(); - pdf_logfont("load type3 font (%d %d R) ptr=%p {\n", fz_tonum(dict), fz_togen(dict), fontdesc); - pdf_logfont("name %s\n", buf); + pdf_log_font("load type3 font (%d %d R) ptr=%p {\n", fz_to_num(dict), fz_to_gen(dict), fontdesc); + pdf_log_font("name %s\n", buf); - obj = fz_dictgets(dict, "FontMatrix"); - matrix = pdf_tomatrix(obj); + obj = fz_dict_gets(dict, "FontMatrix"); + matrix = pdf_to_matrix(obj); - pdf_logfont("matrix [%g %g %g %g %g %g]\n", + pdf_log_font("matrix [%g %g %g %g %g %g]\n", matrix.a, matrix.b, matrix.c, matrix.d, matrix.e, matrix.f); - obj = fz_dictgets(dict, "FontBBox"); - bbox = pdf_torect(obj); + obj = fz_dict_gets(dict, "FontBBox"); + bbox = pdf_to_rect(obj); - pdf_logfont("bbox [%g %g %g %g]\n", + pdf_log_font("bbox [%g %g %g %g]\n", bbox.x0, bbox.y0, bbox.x1, bbox.y1); - fontdesc->font = fz_newtype3font(buf, matrix); + fontdesc->font = fz_new_type3_font(buf, matrix); - fz_setfontbbox(fontdesc->font, bbox.x0, bbox.y0, bbox.x1, bbox.y1); + fz_set_font_bbox(fontdesc->font, bbox.x0, bbox.y0, bbox.x1, bbox.y1); /* Encoding */ for (i = 0; i < 256; i++) - estrings[i] = nil; + estrings[i] = NULL; - encoding = fz_dictgets(dict, "Encoding"); + encoding = fz_dict_gets(dict, "Encoding"); if (!encoding) { error = fz_throw("syntaxerror: Type3 font missing Encoding"); goto cleanup; } - if (fz_isname(encoding)) - pdf_loadencoding(estrings, fz_toname(encoding)); + if (fz_is_name(encoding)) + pdf_load_encoding(estrings, fz_to_name(encoding)); - if (fz_isdict(encoding)) + if (fz_is_dict(encoding)) { fz_obj *base, *diff, *item; - base = fz_dictgets(encoding, "BaseEncoding"); - if (fz_isname(base)) - pdf_loadencoding(estrings, fz_toname(base)); + base = fz_dict_gets(encoding, "BaseEncoding"); + if (fz_is_name(base)) + pdf_load_encoding(estrings, fz_to_name(base)); - diff = fz_dictgets(encoding, "Differences"); - if (fz_isarray(diff)) + diff = fz_dict_gets(encoding, "Differences"); + if (fz_is_array(diff)) { - n = fz_arraylen(diff); + n = fz_array_len(diff); k = 0; for (i = 0; i < n; i++) { - item = fz_arrayget(diff, i); - if (fz_isint(item)) - k = fz_toint(item); - if (fz_isname(item)) - estrings[k++] = fz_toname(item); + item = fz_array_get(diff, i); + if (fz_is_int(item)) + k = fz_to_int(item); + if (fz_is_name(item)) + estrings[k++] = fz_to_name(item); if (k < 0) k = 0; if (k > 255) k = 255; } } } - fontdesc->encoding = pdf_newidentitycmap(0, 1); + fontdesc->encoding = pdf_new_identity_cmap(0, 1); - error = pdf_loadtounicode(fontdesc, xref, estrings, nil, fz_dictgets(dict, "ToUnicode")); + error = pdf_load_to_unicode(fontdesc, xref, estrings, NULL, fz_dict_gets(dict, "ToUnicode")); if (error) goto cleanup; /* Widths */ - pdf_setdefaulthmtx(fontdesc, 0); + pdf_set_default_hmtx(fontdesc, 0); - first = fz_toint(fz_dictgets(dict, "FirstChar")); - last = fz_toint(fz_dictgets(dict, "LastChar")); + first = fz_to_int(fz_dict_gets(dict, "FirstChar")); + last = fz_to_int(fz_dict_gets(dict, "LastChar")); - widths = fz_dictgets(dict, "Widths"); + widths = fz_dict_gets(dict, "Widths"); if (!widths) { error = fz_throw("syntaxerror: Type3 font missing Widths"); @@ -110,30 +110,30 @@ pdf_loadtype3font(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *rdb, fz_obj for (i = first; i <= last; i++) { - float w = fz_toreal(fz_arrayget(widths, i - first)); + float w = fz_to_real(fz_array_get(widths, i - first)); w = fontdesc->font->t3matrix.a * w * 1000; fontdesc->font->t3widths[i] = w * 0.001f; - pdf_addhmtx(fontdesc, i, i, w); + pdf_add_hmtx(fontdesc, i, i, w); } - pdf_endhmtx(fontdesc); + pdf_end_hmtx(fontdesc); /* Resources -- inherit page resources if the font doesn't have its own */ - fontdesc->font->t3resources = fz_dictgets(dict, "Resources"); + fontdesc->font->t3resources = fz_dict_gets(dict, "Resources"); if (!fontdesc->font->t3resources) fontdesc->font->t3resources = rdb; if (fontdesc->font->t3resources) - fz_keepobj(fontdesc->font->t3resources); + fz_keep_obj(fontdesc->font->t3resources); if (!fontdesc->font->t3resources) fz_warn("no resource dictionary for type 3 font!"); fontdesc->font->t3xref = xref; - fontdesc->font->t3run = pdf_runglyph; + fontdesc->font->t3run = pdf_run_glyph; /* CharProcs */ - charprocs = fz_dictgets(dict, "CharProcs"); + charprocs = fz_dict_gets(dict, "CharProcs"); if (!charprocs) { error = fz_throw("syntaxerror: Type3 font missing CharProcs"); @@ -144,23 +144,23 @@ pdf_loadtype3font(pdf_fontdesc **fontdescp, pdf_xref *xref, fz_obj *rdb, fz_obj { if (estrings[i]) { - obj = fz_dictgets(charprocs, estrings[i]); - if (pdf_isstream(xref, fz_tonum(obj), fz_togen(obj))) + obj = fz_dict_gets(charprocs, estrings[i]); + if (pdf_is_stream(xref, fz_to_num(obj), fz_to_gen(obj))) { - error = pdf_loadstream(&fontdesc->font->t3procs[i], xref, fz_tonum(obj), fz_togen(obj)); + error = pdf_load_stream(&fontdesc->font->t3procs[i], xref, fz_to_num(obj), fz_to_gen(obj)); if (error) goto cleanup; } } } - pdf_logfont("}\n"); + pdf_log_font("}\n"); *fontdescp = fontdesc; return fz_okay; cleanup: - fz_dropfont(fontdesc->font); + fz_drop_font(fontdesc->font); fz_free(fontdesc); - return fz_rethrow(error, "cannot load type3 font (%d %d R)", fz_tonum(dict), fz_togen(dict)); + return fz_rethrow(error, "cannot load type3 font (%d %d R)", fz_to_num(dict), fz_to_gen(dict)); } diff --git a/pdf/pdf_unicode.c b/pdf/pdf_unicode.c index 6c2d6372..01326b53 100644 --- a/pdf/pdf_unicode.c +++ b/pdf/pdf_unicode.c @@ -4,7 +4,7 @@ /* Load or synthesize ToUnicode map for fonts */ fz_error -pdf_loadtounicode(pdf_fontdesc *font, pdf_xref *xref, +pdf_load_to_unicode(pdf_font_desc *font, pdf_xref *xref, char **strings, char *collection, fz_obj *cmapstm) { fz_error error = fz_okay; @@ -14,76 +14,76 @@ pdf_loadtounicode(pdf_fontdesc *font, pdf_xref *xref, int ucslen; int i; - if (pdf_isstream(xref, fz_tonum(cmapstm), fz_togen(cmapstm))) + if (pdf_is_stream(xref, fz_to_num(cmapstm), fz_to_gen(cmapstm))) { - pdf_logfont("tounicode embedded cmap\n"); + pdf_log_font("to_unicode embedded cmap\n"); - error = pdf_loadembeddedcmap(&cmap, xref, cmapstm); + error = pdf_load_embedded_cmap(&cmap, xref, cmapstm); if (error) - return fz_rethrow(error, "cannot load embedded cmap (%d %d R)", fz_tonum(cmapstm), fz_togen(cmapstm)); + return fz_rethrow(error, "cannot load embedded cmap (%d %d R)", fz_to_num(cmapstm), fz_to_gen(cmapstm)); - font->tounicode = pdf_newcmap(); + font->to_unicode = pdf_new_cmap(); for (i = 0; i < (strings ? 256 : 65536); i++) { - cid = pdf_lookupcmap(font->encoding, i); + cid = pdf_lookup_cmap(font->encoding, i); if (cid >= 0) { - ucslen = pdf_lookupcmapfull(cmap, i, ucsbuf); + ucslen = pdf_lookup_cmap_full(cmap, i, ucsbuf); if (ucslen == 1) - pdf_maprangetorange(font->tounicode, cid, cid, ucsbuf[0]); + pdf_map_range_to_range(font->to_unicode, cid, cid, ucsbuf[0]); if (ucslen > 1) - pdf_maponetomany(font->tounicode, cid, ucsbuf, ucslen); + pdf_map_one_to_many(font->to_unicode, cid, ucsbuf, ucslen); } } - pdf_sortcmap(font->tounicode); + pdf_sort_cmap(font->to_unicode); - pdf_dropcmap(cmap); + pdf_drop_cmap(cmap); } else if (collection) { - pdf_logfont("tounicode cid collection (%s)\n", collection); + pdf_log_font("to_unicode cid collection (%s)\n", collection); error = fz_okay; if (!strcmp(collection, "Adobe-CNS1")) - error = pdf_loadsystemcmap(&font->tounicode, "Adobe-CNS1-UCS2"); + error = pdf_load_system_cmap(&font->to_unicode, "Adobe-CNS1-UCS2"); else if (!strcmp(collection, "Adobe-GB1")) - error = pdf_loadsystemcmap(&font->tounicode, "Adobe-GB1-UCS2"); + error = pdf_load_system_cmap(&font->to_unicode, "Adobe-GB1-UCS2"); else if (!strcmp(collection, "Adobe-Japan1")) - error = pdf_loadsystemcmap(&font->tounicode, "Adobe-Japan1-UCS2"); + error = pdf_load_system_cmap(&font->to_unicode, "Adobe-Japan1-UCS2"); else if (!strcmp(collection, "Adobe-Japan2")) - error = pdf_loadsystemcmap(&font->tounicode, "Adobe-Japan2-UCS2"); /* where's this? */ + error = pdf_load_system_cmap(&font->to_unicode, "Adobe-Japan2-UCS2"); /* where's this? */ else if (!strcmp(collection, "Adobe-Korea1")) - error = pdf_loadsystemcmap(&font->tounicode, "Adobe-Korea1-UCS2"); + error = pdf_load_system_cmap(&font->to_unicode, "Adobe-Korea1-UCS2"); if (error) - return fz_rethrow(error, "cannot load tounicode system cmap %s-UCS2", collection); + return fz_rethrow(error, "cannot load to_unicode system cmap %s-UCS2", collection); } if (strings) { - pdf_logfont("tounicode strings\n"); + pdf_log_font("to_unicode strings\n"); /* TODO one-to-many mappings */ - font->ncidtoucs = 256; - font->cidtoucs = fz_calloc(256, sizeof(unsigned short)); + font->cid_to_ucs_len = 256; + font->cid_to_ucs = fz_calloc(256, sizeof(unsigned short)); for (i = 0; i < 256; i++) { if (strings[i]) - font->cidtoucs[i] = pdf_lookupagl(strings[i]); + font->cid_to_ucs[i] = pdf_lookup_agl(strings[i]); else - font->cidtoucs[i] = '?'; + font->cid_to_ucs[i] = '?'; } } - if (!font->tounicode && !font->cidtoucs) + if (!font->to_unicode && !font->cid_to_ucs) { - pdf_logfont("tounicode could not be loaded\n"); + pdf_log_font("to_unicode could not be loaded\n"); /* TODO: synthesize a ToUnicode if it's a freetype font with * cmap and/or post tables or if it has glyph names. */ } diff --git a/pdf/pdf_xobject.c b/pdf/pdf_xobject.c index 44389efc..86360d3a 100644 --- a/pdf/pdf_xobject.c +++ b/pdf/pdf_xobject.c @@ -2,43 +2,43 @@ #include "mupdf.h" fz_error -pdf_loadxobject(pdf_xobject **formp, pdf_xref *xref, fz_obj *dict) +pdf_load_xobject(pdf_xobject **formp, pdf_xref *xref, fz_obj *dict) { fz_error error; pdf_xobject *form; fz_obj *obj; - if ((*formp = pdf_finditem(xref->store, pdf_dropxobject, dict))) + if ((*formp = pdf_find_item(xref->store, pdf_drop_xobject, dict))) { - pdf_keepxobject(*formp); + pdf_keep_xobject(*formp); return fz_okay; } form = fz_malloc(sizeof(pdf_xobject)); form->refs = 1; - form->resources = nil; - form->contents = nil; - form->colorspace = nil; + form->resources = NULL; + form->contents = NULL; + form->colorspace = NULL; - pdf_logrsrc("load xobject (%d %d R) ptr=%p {\n", fz_tonum(dict), fz_togen(dict), form); + pdf_log_rsrc("load xobject (%d %d R) ptr=%p {\n", fz_to_num(dict), fz_to_gen(dict), form); /* Store item immediately, to avoid possible recursion if objects refer back to this one */ - pdf_storeitem(xref->store, pdf_keepxobject, pdf_dropxobject, dict, form); + pdf_store_item(xref->store, pdf_keep_xobject, pdf_drop_xobject, dict, form); - obj = fz_dictgets(dict, "BBox"); - form->bbox = pdf_torect(obj); + obj = fz_dict_gets(dict, "BBox"); + form->bbox = pdf_to_rect(obj); - pdf_logrsrc("bbox [%g %g %g %g]\n", + pdf_log_rsrc("bbox [%g %g %g %g]\n", form->bbox.x0, form->bbox.y0, form->bbox.x1, form->bbox.y1); - obj = fz_dictgets(dict, "Matrix"); + obj = fz_dict_gets(dict, "Matrix"); if (obj) - form->matrix = pdf_tomatrix(obj); + form->matrix = pdf_to_matrix(obj); else form->matrix = fz_identity; - pdf_logrsrc("matrix [%g %g %g %g %g %g]\n", + pdf_log_rsrc("matrix [%g %g %g %g %g %g]\n", form->matrix.a, form->matrix.b, form->matrix.c, form->matrix.d, form->matrix.e, form->matrix.f); @@ -47,69 +47,69 @@ pdf_loadxobject(pdf_xobject **formp, pdf_xref *xref, fz_obj *dict) form->knockout = 0; form->transparency = 0; - obj = fz_dictgets(dict, "Group"); + obj = fz_dict_gets(dict, "Group"); if (obj) { fz_obj *attrs = obj; - form->isolated = fz_tobool(fz_dictgets(attrs, "I")); - form->knockout = fz_tobool(fz_dictgets(attrs, "K")); + form->isolated = fz_to_bool(fz_dict_gets(attrs, "I")); + form->knockout = fz_to_bool(fz_dict_gets(attrs, "K")); - obj = fz_dictgets(attrs, "S"); - if (fz_isname(obj) && !strcmp(fz_toname(obj), "Transparency")) + obj = fz_dict_gets(attrs, "S"); + if (fz_is_name(obj) && !strcmp(fz_to_name(obj), "Transparency")) form->transparency = 1; - obj = fz_dictgets(attrs, "CS"); + obj = fz_dict_gets(attrs, "CS"); if (obj) { - error = pdf_loadcolorspace(&form->colorspace, xref, obj); + error = pdf_load_colorspace(&form->colorspace, xref, obj); if (error) fz_catch(error, "cannot load xobject colorspace"); - pdf_logrsrc("colorspace %s\n", form->colorspace->name); + pdf_log_rsrc("colorspace %s\n", form->colorspace->name); } } - pdf_logrsrc("isolated %d\n", form->isolated); - pdf_logrsrc("knockout %d\n", form->knockout); - pdf_logrsrc("transparency %d\n", form->transparency); + pdf_log_rsrc("isolated %d\n", form->isolated); + pdf_log_rsrc("knockout %d\n", form->knockout); + pdf_log_rsrc("transparency %d\n", form->transparency); - form->resources = fz_dictgets(dict, "Resources"); + form->resources = fz_dict_gets(dict, "Resources"); if (form->resources) - fz_keepobj(form->resources); + fz_keep_obj(form->resources); - error = pdf_loadstream(&form->contents, xref, fz_tonum(dict), fz_togen(dict)); + error = pdf_load_stream(&form->contents, xref, fz_to_num(dict), fz_to_gen(dict)); if (error) { - pdf_removeitem(xref->store, pdf_dropxobject, dict); - pdf_dropxobject(form); - return fz_rethrow(error, "cannot load xobject content stream (%d %d R)", fz_tonum(dict), fz_togen(dict)); + pdf_remove_item(xref->store, pdf_drop_xobject, dict); + pdf_drop_xobject(form); + return fz_rethrow(error, "cannot load xobject content stream (%d %d R)", fz_to_num(dict), fz_to_gen(dict)); } - pdf_logrsrc("stream %d bytes\n", form->contents->len); - pdf_logrsrc("}\n"); + pdf_log_rsrc("stream %d bytes\n", form->contents->len); + pdf_log_rsrc("}\n"); *formp = form; return fz_okay; } pdf_xobject * -pdf_keepxobject(pdf_xobject *xobj) +pdf_keep_xobject(pdf_xobject *xobj) { xobj->refs ++; return xobj; } void -pdf_dropxobject(pdf_xobject *xobj) +pdf_drop_xobject(pdf_xobject *xobj) { if (xobj && --xobj->refs == 0) { if (xobj->colorspace) - fz_dropcolorspace(xobj->colorspace); + fz_drop_colorspace(xobj->colorspace); if (xobj->resources) - fz_dropobj(xobj->resources); + fz_drop_obj(xobj->resources); if (xobj->contents) - fz_dropbuffer(xobj->contents); + fz_drop_buffer(xobj->contents); fz_free(xobj); } } diff --git a/pdf/pdf_xref.c b/pdf/pdf_xref.c index 2e98c97e..ce973d39 100644 --- a/pdf/pdf_xref.c +++ b/pdf/pdf_xref.c @@ -13,24 +13,24 @@ static inline int iswhite(int ch) */ static fz_error -pdf_loadversion(pdf_xref *xref) +pdf_load_version(pdf_xref *xref) { char buf[20]; fz_seek(xref->file, 0, 0); - fz_readline(xref->file, buf, sizeof buf); + fz_read_line(xref->file, buf, sizeof buf); if (memcmp(buf, "%PDF-", 5) != 0) return fz_throw("cannot recognize version marker"); xref->version = atof(buf + 5) * 10; - pdf_logxref("version %d.%d\n", xref->version / 10, xref->version % 10); + pdf_log_xref("version %d.%d\n", xref->version / 10, xref->version % 10); return fz_okay; } static fz_error -pdf_readstartxref(pdf_xref *xref) +pdf_read_start_xref(pdf_xref *xref) { unsigned char buf[1024]; int t, n; @@ -38,9 +38,9 @@ pdf_readstartxref(pdf_xref *xref) fz_seek(xref->file, 0, 2); - xref->filesize = fz_tell(xref->file); + xref->file_size = fz_tell(xref->file); - t = MAX(0, xref->filesize - (int)sizeof buf); + t = MAX(0, xref->file_size - (int)sizeof buf); fz_seek(xref->file, t, 0); n = fz_read(xref->file, buf, sizeof buf); @@ -55,7 +55,7 @@ pdf_readstartxref(pdf_xref *xref) while (iswhite(buf[i]) && i < n) i ++; xref->startxref = atoi((char*)(buf + i)); - pdf_logxref("startxref %d\n", xref->startxref); + pdf_log_xref("startxref %d\n", xref->startxref); return fz_okay; } } @@ -68,7 +68,7 @@ pdf_readstartxref(pdf_xref *xref) */ static fz_error -pdf_readoldtrailer(pdf_xref *xref, char *buf, int cap) +pdf_read_old_trailer(pdf_xref *xref, char *buf, int cap) { fz_error error; int len; @@ -78,19 +78,19 @@ pdf_readoldtrailer(pdf_xref *xref, char *buf, int cap) int tok; int c; - pdf_logxref("load old xref format trailer\n"); + pdf_log_xref("load old xref format trailer\n"); - fz_readline(xref->file, buf, cap); + fz_read_line(xref->file, buf, cap); if (strncmp(buf, "xref", 4) != 0) return fz_throw("cannot find xref marker"); while (1) { - c = fz_peekbyte(xref->file); + c = fz_peek_byte(xref->file); if (!(c >= '0' && c <= '9')) break; - fz_readline(xref->file, buf, cap); + fz_read_line(xref->file, buf, cap); s = buf; fz_strsep(&s, " "); /* ignore ofs */ if (!s) @@ -111,55 +111,55 @@ pdf_readoldtrailer(pdf_xref *xref, char *buf, int cap) error = pdf_lex(&tok, xref->file, buf, cap, &n); if (error) return fz_rethrow(error, "cannot parse trailer"); - if (tok != PDF_TTRAILER) + if (tok != PDF_TOK_TRAILER) return fz_throw("expected trailer marker"); error = pdf_lex(&tok, xref->file, buf, cap, &n); if (error) return fz_rethrow(error, "cannot parse trailer"); - if (tok != PDF_TODICT) + if (tok != PDF_TOK_OPEN_DICT) return fz_throw("expected trailer dictionary"); - error = pdf_parsedict(&xref->trailer, xref, xref->file, buf, cap); + error = pdf_parse_dict(&xref->trailer, xref, xref->file, buf, cap); if (error) return fz_rethrow(error, "cannot parse trailer"); return fz_okay; } static fz_error -pdf_readnewtrailer(pdf_xref *xref, char *buf, int cap) +pdf_read_new_trailer(pdf_xref *xref, char *buf, int cap) { fz_error error; - pdf_logxref("load new xref format trailer\n"); + pdf_log_xref("load new xref format trailer\n"); - error = pdf_parseindobj(&xref->trailer, xref, xref->file, buf, cap, nil, nil, nil); + error = pdf_parse_ind_obj(&xref->trailer, xref, xref->file, buf, cap, NULL, NULL, NULL); if (error) return fz_rethrow(error, "cannot parse trailer (compressed)"); return fz_okay; } static fz_error -pdf_readtrailer(pdf_xref *xref, char *buf, int cap) +pdf_read_trailer(pdf_xref *xref, char *buf, int cap) { fz_error error; int c; fz_seek(xref->file, xref->startxref, 0); - while (iswhite(fz_peekbyte(xref->file))) - fz_readbyte(xref->file); + while (iswhite(fz_peek_byte(xref->file))) + fz_read_byte(xref->file); - c = fz_peekbyte(xref->file); + c = fz_peek_byte(xref->file); if (c == 'x') { - error = pdf_readoldtrailer(xref, buf, cap); + error = pdf_read_old_trailer(xref, buf, cap); if (error) return fz_rethrow(error, "cannot read trailer"); } else if (c >= '0' && c <= '9') { - error = pdf_readnewtrailer(xref, buf, cap); + error = pdf_read_new_trailer(xref, buf, cap); if (error) return fz_rethrow(error, "cannot read trailer"); } @@ -176,24 +176,24 @@ pdf_readtrailer(pdf_xref *xref, char *buf, int cap) */ void -pdf_resizexref(pdf_xref *xref, int newlen) +pdf_resize_xref(pdf_xref *xref, int newlen) { int i; - xref->table = fz_realloc(xref->table, newlen, sizeof(pdf_xrefentry)); + xref->table = fz_realloc(xref->table, newlen, sizeof(pdf_xref_entry)); for (i = xref->len; i < newlen; i++) { xref->table[i].type = 0; xref->table[i].ofs = 0; xref->table[i].gen = 0; - xref->table[i].stmofs = 0; - xref->table[i].obj = nil; + xref->table[i].stm_ofs = 0; + xref->table[i].obj = NULL; } xref->len = newlen; } static fz_error -pdf_readoldxref(fz_obj **trailerp, pdf_xref *xref, char *buf, int cap) +pdf_read_old_xref(fz_obj **trailerp, pdf_xref *xref, char *buf, int cap) { fz_error error; int ofs, len; @@ -203,19 +203,19 @@ pdf_readoldxref(fz_obj **trailerp, pdf_xref *xref, char *buf, int cap) int i; int c; - pdf_logxref("load old xref format\n"); + pdf_log_xref("load old xref format\n"); - fz_readline(xref->file, buf, cap); + fz_read_line(xref->file, buf, cap); if (strncmp(buf, "xref", 4) != 0) return fz_throw("cannot find xref marker"); while (1) { - c = fz_peekbyte(xref->file); + c = fz_peek_byte(xref->file); if (!(c >= '0' && c <= '9')) break; - fz_readline(xref->file, buf, cap); + fz_read_line(xref->file, buf, cap); s = buf; ofs = atoi(fz_strsep(&s, " ")); len = atoi(fz_strsep(&s, " ")); @@ -231,7 +231,7 @@ pdf_readoldxref(fz_obj **trailerp, pdf_xref *xref, char *buf, int cap) if (ofs + len > xref->len) { fz_warn("broken xref section, proceeding anyway."); - pdf_resizexref(xref, ofs + len); + pdf_resize_xref(xref, ofs + len); } for (i = ofs; i < ofs + len; i++) @@ -259,23 +259,23 @@ pdf_readoldxref(fz_obj **trailerp, pdf_xref *xref, char *buf, int cap) error = pdf_lex(&tok, xref->file, buf, cap, &n); if (error) return fz_rethrow(error, "cannot parse trailer"); - if (tok != PDF_TTRAILER) + if (tok != PDF_TOK_TRAILER) return fz_throw("expected trailer marker"); error = pdf_lex(&tok, xref->file, buf, cap, &n); if (error) return fz_rethrow(error, "cannot parse trailer"); - if (tok != PDF_TODICT) + if (tok != PDF_TOK_OPEN_DICT) return fz_throw("expected trailer dictionary"); - error = pdf_parsedict(trailerp, xref, xref->file, buf, cap); + error = pdf_parse_dict(trailerp, xref, xref->file, buf, cap); if (error) return fz_rethrow(error, "cannot parse trailer"); return fz_okay; } static fz_error -pdf_readnewxrefsection(pdf_xref *xref, fz_stream *stm, int i0, int i1, int w0, int w1, int w2) +pdf_read_new_xref_section(pdf_xref *xref, fz_stream *stm, int i0, int i1, int w0, int w1, int w2) { int i, n; @@ -288,15 +288,15 @@ pdf_readnewxrefsection(pdf_xref *xref, fz_stream *stm, int i0, int i1, int w0, i int b = 0; int c = 0; - if (fz_iseof(stm)) + if (fz_is_eof(stm)) return fz_throw("truncated xref stream"); for (n = 0; n < w0; n++) - a = (a << 8) + fz_readbyte(stm); + a = (a << 8) + fz_read_byte(stm); for (n = 0; n < w1; n++) - b = (b << 8) + fz_readbyte(stm); + b = (b << 8) + fz_read_byte(stm); for (n = 0; n < w2; n++) - c = (c << 8) + fz_readbyte(stm); + c = (c << 8) + fz_read_byte(stm); if (!xref->table[i].type) { @@ -311,83 +311,83 @@ pdf_readnewxrefsection(pdf_xref *xref, fz_stream *stm, int i0, int i1, int w0, i } static fz_error -pdf_readnewxref(fz_obj **trailerp, pdf_xref *xref, char *buf, int cap) +pdf_read_new_xref(fz_obj **trailerp, pdf_xref *xref, char *buf, int cap) { fz_error error; fz_stream *stm; fz_obj *trailer; fz_obj *index; fz_obj *obj; - int num, gen, stmofs; + int num, gen, stm_ofs; int size, w0, w1, w2; int t; - pdf_logxref("load new xref format\n"); + pdf_log_xref("load new xref format\n"); - error = pdf_parseindobj(&trailer, xref, xref->file, buf, cap, &num, &gen, &stmofs); + error = pdf_parse_ind_obj(&trailer, xref, xref->file, buf, cap, &num, &gen, &stm_ofs); if (error) return fz_rethrow(error, "cannot parse compressed xref stream object"); - obj = fz_dictgets(trailer, "Size"); + obj = fz_dict_gets(trailer, "Size"); if (!obj) { - fz_dropobj(trailer); + fz_drop_obj(trailer); return fz_throw("xref stream missing Size entry (%d %d R)", num, gen); } - size = fz_toint(obj); + size = fz_to_int(obj); if (size > xref->len) { - pdf_resizexref(xref, size); + pdf_resize_xref(xref, size); } if (num < 0 || num >= xref->len) { - fz_dropobj(trailer); + fz_drop_obj(trailer); return fz_throw("object id (%d %d R) out of range (0..%d)", num, gen, xref->len - 1); } - pdf_logxref("\tnum=%d gen=%d size=%d\n", num, gen, size); + pdf_log_xref("\tnum=%d gen=%d size=%d\n", num, gen, size); - obj = fz_dictgets(trailer, "W"); + obj = fz_dict_gets(trailer, "W"); if (!obj) { - fz_dropobj(trailer); + fz_drop_obj(trailer); return fz_throw("xref stream missing W entry (%d %d R)", num, gen); } - w0 = fz_toint(fz_arrayget(obj, 0)); - w1 = fz_toint(fz_arrayget(obj, 1)); - w2 = fz_toint(fz_arrayget(obj, 2)); + w0 = fz_to_int(fz_array_get(obj, 0)); + w1 = fz_to_int(fz_array_get(obj, 1)); + w2 = fz_to_int(fz_array_get(obj, 2)); - index = fz_dictgets(trailer, "Index"); + index = fz_dict_gets(trailer, "Index"); - error = pdf_openstreamat(&stm, xref, num, gen, trailer, stmofs); + error = pdf_open_stream_at(&stm, xref, num, gen, trailer, stm_ofs); if (error) { - fz_dropobj(trailer); + fz_drop_obj(trailer); return fz_rethrow(error, "cannot open compressed xref stream (%d %d R)", num, gen); } if (!index) { - error = pdf_readnewxrefsection(xref, stm, 0, size, w0, w1, w2); + error = pdf_read_new_xref_section(xref, stm, 0, size, w0, w1, w2); if (error) { fz_close(stm); - fz_dropobj(trailer); + fz_drop_obj(trailer); return fz_rethrow(error, "cannot read xref stream (%d %d R)", num, gen); } } else { - for (t = 0; t < fz_arraylen(index); t += 2) + for (t = 0; t < fz_array_len(index); t += 2) { - int i0 = fz_toint(fz_arrayget(index, t + 0)); - int i1 = fz_toint(fz_arrayget(index, t + 1)); - error = pdf_readnewxrefsection(xref, stm, i0, i1, w0, w1, w2); + int i0 = fz_to_int(fz_array_get(index, t + 0)); + int i1 = fz_to_int(fz_array_get(index, t + 1)); + error = pdf_read_new_xref_section(xref, stm, i0, i1, w0, w1, w2); if (error) { fz_close(stm); - fz_dropobj(trailer); + fz_drop_obj(trailer); return fz_rethrow(error, "cannot read xref stream section (%d %d R)", num, gen); } } @@ -401,26 +401,26 @@ pdf_readnewxref(fz_obj **trailerp, pdf_xref *xref, char *buf, int cap) } static fz_error -pdf_readxref(fz_obj **trailerp, pdf_xref *xref, int ofs, char *buf, int cap) +pdf_read_xref(fz_obj **trailerp, pdf_xref *xref, int ofs, char *buf, int cap) { fz_error error; int c; fz_seek(xref->file, ofs, 0); - while (iswhite(fz_peekbyte(xref->file))) - fz_readbyte(xref->file); + while (iswhite(fz_peek_byte(xref->file))) + fz_read_byte(xref->file); - c = fz_peekbyte(xref->file); + c = fz_peek_byte(xref->file); if (c == 'x') { - error = pdf_readoldxref(trailerp, xref, buf, cap); + error = pdf_read_old_xref(trailerp, xref, buf, cap); if (error) return fz_rethrow(error, "cannot read xref (ofs=%d)", ofs); } else if (c >= '0' && c <= '9') { - error = pdf_readnewxref(trailerp, xref, buf, cap); + error = pdf_read_new_xref(trailerp, xref, buf, cap); if (error) return fz_rethrow(error, "cannot read xref (ofs=%d)", ofs); } @@ -433,43 +433,43 @@ pdf_readxref(fz_obj **trailerp, pdf_xref *xref, int ofs, char *buf, int cap) } static fz_error -pdf_readxrefsections(pdf_xref *xref, int ofs, char *buf, int cap) +pdf_read_xref_sections(pdf_xref *xref, int ofs, char *buf, int cap) { fz_error error; fz_obj *trailer; fz_obj *prev; fz_obj *xrefstm; - error = pdf_readxref(&trailer, xref, ofs, buf, cap); + error = pdf_read_xref(&trailer, xref, ofs, buf, cap); if (error) return fz_rethrow(error, "cannot read xref section"); /* FIXME: do we overwrite free entries properly? */ - xrefstm = fz_dictgets(trailer, "XRefStm"); + xrefstm = fz_dict_gets(trailer, "XRefStm"); if (xrefstm) { - pdf_logxref("load xrefstm\n"); - error = pdf_readxrefsections(xref, fz_toint(xrefstm), buf, cap); + pdf_log_xref("load xrefstm\n"); + error = pdf_read_xref_sections(xref, fz_to_int(xrefstm), buf, cap); if (error) { - fz_dropobj(trailer); + fz_drop_obj(trailer); return fz_rethrow(error, "cannot read /XRefStm xref section"); } } - prev = fz_dictgets(trailer, "Prev"); + prev = fz_dict_gets(trailer, "Prev"); if (prev) { - pdf_logxref("load prev at %#x\n", fz_toint(prev)); - error = pdf_readxrefsections(xref, fz_toint(prev), buf, cap); + pdf_log_xref("load prev at %#x\n", fz_to_int(prev)); + error = pdf_read_xref_sections(xref, fz_to_int(prev), buf, cap); if (error) { - fz_dropobj(trailer); + fz_drop_obj(trailer); return fz_rethrow(error, "cannot read /Prev xref section"); } } - fz_dropobj(trailer); + fz_drop_obj(trailer); return fz_okay; } @@ -478,33 +478,33 @@ pdf_readxrefsections(pdf_xref *xref, int ofs, char *buf, int cap) */ static fz_error -pdf_loadxref(pdf_xref *xref, char *buf, int bufsize) +pdf_load_xref(pdf_xref *xref, char *buf, int bufsize) { fz_error error; fz_obj *size; int i; - error = pdf_loadversion(xref); + error = pdf_load_version(xref); if (error) return fz_rethrow(error, "cannot read version marker"); - error = pdf_readstartxref(xref); + error = pdf_read_start_xref(xref); if (error) return fz_rethrow(error, "cannot read startxref"); - error = pdf_readtrailer(xref, buf, bufsize); + error = pdf_read_trailer(xref, buf, bufsize); if (error) return fz_rethrow(error, "cannot read trailer"); - size = fz_dictgets(xref->trailer, "Size"); + size = fz_dict_gets(xref->trailer, "Size"); if (!size) return fz_throw("trailer missing Size entry"); - pdf_logxref("\tsize %d at %#x\n", fz_toint(size), xref->startxref); + pdf_log_xref("\tsize %d at %#x\n", fz_to_int(size), xref->startxref); - pdf_resizexref(xref, fz_toint(size)); + pdf_resize_xref(xref, fz_to_int(size)); - error = pdf_readxrefsections(xref, xref->startxref, buf, bufsize); + error = pdf_read_xref_sections(xref, xref->startxref, buf, bufsize); if (error) return fz_rethrow(error, "cannot read xref"); @@ -515,7 +515,7 @@ pdf_loadxref(pdf_xref *xref, char *buf, int bufsize) /* broken pdfs where object offsets are out of range */ for (i = 0; i < xref->len; i++) if (xref->table[i].type == 'n') - if (xref->table[i].ofs <= 0 || xref->table[i].ofs >= xref->filesize) + if (xref->table[i].ofs <= 0 || xref->table[i].ofs >= xref->file_size) return fz_throw("object offset out of range: %d (%d 0 R)", xref->table[i].ofs, i); return fz_okay; @@ -527,7 +527,7 @@ pdf_loadxref(pdf_xref *xref, char *buf, int bufsize) */ fz_error -pdf_openxrefwithstream(pdf_xref **xrefp, fz_stream *file, char *password) +pdf_open_xref_with_stream(pdf_xref **xrefp, fz_stream *file, char *password) { pdf_xref *xref; fz_error error; @@ -536,61 +536,61 @@ pdf_openxrefwithstream(pdf_xref **xrefp, fz_stream *file, char *password) int i, repaired = 0; /* install pdf specific callback */ - fz_resolveindirect = pdf_resolveindirect; + fz_resolve_indirect = pdf_resolve_indirect; xref = fz_malloc(sizeof(pdf_xref)); memset(xref, 0, sizeof(pdf_xref)); - pdf_logxref("openxref %p\n", xref); + pdf_log_xref("openxref %p\n", xref); - xref->file = fz_keepstream(file); + xref->file = fz_keep_stream(file); - error = pdf_loadxref(xref, xref->scratch, sizeof xref->scratch); + error = pdf_load_xref(xref, xref->scratch, sizeof xref->scratch); if (error) { fz_catch(error, "trying to repair"); if (xref->table) { fz_free(xref->table); - xref->table = nil; + xref->table = NULL; xref->len = 0; } if (xref->trailer) { - fz_dropobj(xref->trailer); - xref->trailer = nil; + fz_drop_obj(xref->trailer); + xref->trailer = NULL; } - error = pdf_repairxref(xref, xref->scratch, sizeof xref->scratch); + error = pdf_repair_xref(xref, xref->scratch, sizeof xref->scratch); if (error) { - pdf_freexref(xref); + pdf_free_xref(xref); return fz_rethrow(error, "cannot repair document"); } repaired = 1; } - encrypt = fz_dictgets(xref->trailer, "Encrypt"); - id = fz_dictgets(xref->trailer, "ID"); - if (fz_isdict(encrypt)) + encrypt = fz_dict_gets(xref->trailer, "Encrypt"); + id = fz_dict_gets(xref->trailer, "ID"); + if (fz_is_dict(encrypt)) { - error = pdf_newcrypt(&xref->crypt, encrypt, id); + error = pdf_new_crypt(&xref->crypt, encrypt, id); if (error) { - pdf_freexref(xref); + pdf_free_xref(xref); return fz_rethrow(error, "cannot decrypt document"); } } - if (pdf_needspassword(xref)) + if (pdf_needs_password(xref)) { /* Only care if we have a password */ if (password) { - int okay = pdf_authenticatepassword(xref, password); + int okay = pdf_authenticate_password(xref, password); if (!okay) { - pdf_freexref(xref); + pdf_free_xref(xref); return fz_throw("invalid password"); } } @@ -600,22 +600,22 @@ pdf_openxrefwithstream(pdf_xref **xrefp, fz_stream *file, char *password) { int hasroot, hasinfo; - error = pdf_repairobjstms(xref); + error = pdf_repair_obj_stms(xref); if (error) { - pdf_freexref(xref); + pdf_free_xref(xref); return fz_rethrow(error, "cannot repair document"); } - hasroot = fz_dictgets(xref->trailer, "Root") != nil; - hasinfo = fz_dictgets(xref->trailer, "Info") != nil; + hasroot = fz_dict_gets(xref->trailer, "Root") != NULL; + hasinfo = fz_dict_gets(xref->trailer, "Info") != NULL; for (i = 1; i < xref->len; i++) { if (xref->table[i].type == 0 || xref->table[i].type == 'f') continue; - error = pdf_loadobject(&dict, xref, i, 0); + error = pdf_load_object(&dict, xref, i, 0); if (error) { fz_catch(error, "ignoring broken object (%d 0 R)", i); @@ -624,28 +624,28 @@ pdf_openxrefwithstream(pdf_xref **xrefp, fz_stream *file, char *password) if (!hasroot) { - obj = fz_dictgets(dict, "Type"); - if (fz_isname(obj) && !strcmp(fz_toname(obj), "Catalog")) + obj = fz_dict_gets(dict, "Type"); + if (fz_is_name(obj) && !strcmp(fz_to_name(obj), "Catalog")) { - pdf_logxref("found catalog: (%d %d R)\n", i, 0); - obj = fz_newindirect(i, 0, xref); - fz_dictputs(xref->trailer, "Root", obj); - fz_dropobj(obj); + pdf_log_xref("found catalog: (%d %d R)\n", i, 0); + obj = fz_new_indirect(i, 0, xref); + fz_dict_puts(xref->trailer, "Root", obj); + fz_drop_obj(obj); } } if (!hasinfo) { - if (fz_dictgets(dict, "Creator") || fz_dictgets(dict, "Producer")) + if (fz_dict_gets(dict, "Creator") || fz_dict_gets(dict, "Producer")) { - pdf_logxref("found info: (%d %d R)\n", i, 0); - obj = fz_newindirect(i, 0, xref); - fz_dictputs(xref->trailer, "Info", obj); - fz_dropobj(obj); + pdf_log_xref("found info: (%d %d R)\n", i, 0); + obj = fz_new_indirect(i, 0, xref); + fz_dict_puts(xref->trailer, "Info", obj); + fz_drop_obj(obj); } } - fz_dropobj(dict); + fz_drop_obj(dict); } } @@ -654,14 +654,14 @@ pdf_openxrefwithstream(pdf_xref **xrefp, fz_stream *file, char *password) } void -pdf_freexref(pdf_xref *xref) +pdf_free_xref(pdf_xref *xref) { int i; - pdf_logxref("freexref %p\n", xref); + pdf_log_xref("freexref %p\n", xref); if (xref->store) - pdf_freestore(xref->store); + pdf_free_store(xref->store); if (xref->table) { @@ -669,50 +669,50 @@ pdf_freexref(pdf_xref *xref) { if (xref->table[i].obj) { - fz_dropobj(xref->table[i].obj); - xref->table[i].obj = nil; + fz_drop_obj(xref->table[i].obj); + xref->table[i].obj = NULL; } } fz_free(xref->table); } - if (xref->pageobjs) + if (xref->page_objs) { - for (i = 0; i < xref->pagelen; i++) - fz_dropobj(xref->pageobjs[i]); - fz_free(xref->pageobjs); + for (i = 0; i < xref->page_len; i++) + fz_drop_obj(xref->page_objs[i]); + fz_free(xref->page_objs); } - if (xref->pagerefs) + if (xref->page_refs) { - for (i = 0; i < xref->pagelen; i++) - fz_dropobj(xref->pagerefs[i]); - fz_free(xref->pagerefs); + for (i = 0; i < xref->page_len; i++) + fz_drop_obj(xref->page_refs[i]); + fz_free(xref->page_refs); } if (xref->file) fz_close(xref->file); if (xref->trailer) - fz_dropobj(xref->trailer); + fz_drop_obj(xref->trailer); if (xref->crypt) - pdf_freecrypt(xref->crypt); + pdf_free_crypt(xref->crypt); fz_free(xref); } void -pdf_debugxref(pdf_xref *xref) +pdf_debug_xref(pdf_xref *xref) { int i; printf("xref\n0 %d\n", xref->len); for (i = 0; i < xref->len; i++) { - printf("%05d: %010d %05d %c (refs=%d, stmofs=%d)\n", i, + printf("%05d: %010d %05d %c (refs=%d, stm_ofs=%d)\n", i, xref->table[i].ofs, xref->table[i].gen, xref->table[i].type ? xref->table[i].type : '-', xref->table[i].obj ? xref->table[i].obj->refs : 0, - xref->table[i].stmofs); + xref->table[i].stm_ofs); } } @@ -721,7 +721,7 @@ pdf_debugxref(pdf_xref *xref) */ static fz_error -pdf_loadobjstm(pdf_xref *xref, int num, int gen, char *buf, int cap) +pdf_load_obj_stm(pdf_xref *xref, int num, int gen, char *buf, int cap) { fz_error error; fz_stream *stm; @@ -735,21 +735,21 @@ pdf_loadobjstm(pdf_xref *xref, int num, int gen, char *buf, int cap) int i, n; int tok; - pdf_logxref("loadobjstm (%d %d R)\n", num, gen); + pdf_log_xref("loadobjstm (%d %d R)\n", num, gen); - error = pdf_loadobject(&objstm, xref, num, gen); + error = pdf_load_object(&objstm, xref, num, gen); if (error) return fz_rethrow(error, "cannot load object stream object (%d %d R)", num, gen); - count = fz_toint(fz_dictgets(objstm, "N")); - first = fz_toint(fz_dictgets(objstm, "First")); + count = fz_to_int(fz_dict_gets(objstm, "N")); + first = fz_to_int(fz_dict_gets(objstm, "First")); - pdf_logxref("\tcount %d\n", count); + pdf_log_xref("\tcount %d\n", count); numbuf = fz_calloc(count, sizeof(int)); ofsbuf = fz_calloc(count, sizeof(int)); - error = pdf_openstream(&stm, xref, num, gen); + error = pdf_open_stream(&stm, xref, num, gen); if (error) { error = fz_rethrow(error, "cannot open object stream (%d %d R)", num, gen); @@ -759,7 +759,7 @@ pdf_loadobjstm(pdf_xref *xref, int num, int gen, char *buf, int cap) for (i = 0; i < count; i++) { error = pdf_lex(&tok, stm, buf, cap, &n); - if (error || tok != PDF_TINT) + if (error || tok != PDF_TOK_INT) { error = fz_rethrow(error, "corrupt object stream (%d %d R)", num, gen); goto cleanupstm; @@ -767,7 +767,7 @@ pdf_loadobjstm(pdf_xref *xref, int num, int gen, char *buf, int cap) numbuf[i] = atoi(buf); error = pdf_lex(&tok, stm, buf, cap, &n); - if (error || tok != PDF_TINT) + if (error || tok != PDF_TOK_INT) { error = fz_rethrow(error, "corrupt object stream (%d %d R)", num, gen); goto cleanupstm; @@ -781,7 +781,7 @@ pdf_loadobjstm(pdf_xref *xref, int num, int gen, char *buf, int cap) { fz_seek(stm, first + ofsbuf[i], 0); - error = pdf_parsestmobj(&obj, xref, stm, buf, cap); + error = pdf_parse_stm_obj(&obj, xref, stm, buf, cap); if (error) { error = fz_rethrow(error, "cannot parse object %d in stream (%d %d R)", i, num, gen); @@ -790,7 +790,7 @@ pdf_loadobjstm(pdf_xref *xref, int num, int gen, char *buf, int cap) if (numbuf[i] < 1 || numbuf[i] >= xref->len) { - fz_dropobj(obj); + fz_drop_obj(obj); error = fz_throw("object id (%d 0 R) out of range (0..%d)", numbuf[i], xref->len - 1); goto cleanupstm; } @@ -798,19 +798,19 @@ pdf_loadobjstm(pdf_xref *xref, int num, int gen, char *buf, int cap) if (xref->table[numbuf[i]].type == 'o' && xref->table[numbuf[i]].ofs == num) { if (xref->table[numbuf[i]].obj) - fz_dropobj(xref->table[numbuf[i]].obj); + fz_drop_obj(xref->table[numbuf[i]].obj); xref->table[numbuf[i]].obj = obj; } else { - fz_dropobj(obj); + fz_drop_obj(obj); } } fz_close(stm); fz_free(ofsbuf); fz_free(numbuf); - fz_dropobj(objstm); + fz_drop_obj(objstm); return fz_okay; cleanupstm: @@ -818,7 +818,7 @@ cleanupstm: cleanupbuf: fz_free(ofsbuf); fz_free(numbuf); - fz_dropobj(objstm); + fz_drop_obj(objstm); return error; /* already rethrown */ } @@ -827,10 +827,10 @@ cleanupbuf: */ fz_error -pdf_cacheobject(pdf_xref *xref, int num, int gen) +pdf_cache_object(pdf_xref *xref, int num, int gen) { fz_error error; - pdf_xrefentry *x; + pdf_xref_entry *x; int rnum, rgen; if (num < 0 || num >= xref->len) @@ -843,15 +843,15 @@ pdf_cacheobject(pdf_xref *xref, int num, int gen) if (x->type == 'f') { - x->obj = fz_newnull(); + x->obj = fz_new_null(); return fz_okay; } else if (x->type == 'n') { fz_seek(xref->file, x->ofs, 0); - error = pdf_parseindobj(&x->obj, xref, xref->file, xref->scratch, sizeof xref->scratch, - &rnum, &rgen, &x->stmofs); + error = pdf_parse_ind_obj(&x->obj, xref, xref->file, xref->scratch, sizeof xref->scratch, + &rnum, &rgen, &x->stm_ofs); if (error) return fz_rethrow(error, "cannot parse object (%d %d R)", num, gen); @@ -859,13 +859,13 @@ pdf_cacheobject(pdf_xref *xref, int num, int gen) return fz_throw("found object (%d %d R) instead of (%d %d R)", rnum, rgen, num, gen); if (xref->crypt) - pdf_cryptobj(xref->crypt, x->obj, num, gen); + pdf_crypt_obj(xref->crypt, x->obj, num, gen); } else if (x->type == 'o') { if (!x->obj) { - error = pdf_loadobjstm(xref, x->ofs, 0, xref->scratch, sizeof xref->scratch); + error = pdf_load_obj_stm(xref, x->ofs, 0, xref->scratch, sizeof xref->scratch); if (error) return fz_rethrow(error, "cannot load object stream containing object (%d %d R)", num, gen); if (!x->obj) @@ -881,32 +881,32 @@ pdf_cacheobject(pdf_xref *xref, int num, int gen) } fz_error -pdf_loadobject(fz_obj **objp, pdf_xref *xref, int num, int gen) +pdf_load_object(fz_obj **objp, pdf_xref *xref, int num, int gen) { fz_error error; - error = pdf_cacheobject(xref, num, gen); + error = pdf_cache_object(xref, num, gen); if (error) return fz_rethrow(error, "cannot load object (%d %d R) into cache", num, gen); assert(xref->table[num].obj); - *objp = fz_keepobj(xref->table[num].obj); + *objp = fz_keep_obj(xref->table[num].obj); return fz_okay; } fz_obj * -pdf_resolveindirect(fz_obj *ref) +pdf_resolve_indirect(fz_obj *ref) { - if (fz_isindirect(ref)) + if (fz_is_indirect(ref)) { pdf_xref *xref = ref->u.r.xref; - int num = fz_tonum(ref); - int gen = fz_togen(ref); + int num = fz_to_num(ref); + int gen = fz_to_gen(ref); if (xref) { - fz_error error = pdf_cacheobject(xref, num, gen); + fz_error error = pdf_cache_object(xref, num, gen); if (error) { fz_catch(error, "cannot load object (%d %d R) into cache", num, gen); @@ -921,9 +921,9 @@ pdf_resolveindirect(fz_obj *ref) /* Replace numbered object -- for use by pdfclean and similar tools */ void -pdf_updateobject(pdf_xref *xref, int num, int gen, fz_obj *newobj) +pdf_update_object(pdf_xref *xref, int num, int gen, fz_obj *newobj) { - pdf_xrefentry *x; + pdf_xref_entry *x; if (num < 0 || num >= xref->len) { @@ -934,29 +934,29 @@ pdf_updateobject(pdf_xref *xref, int num, int gen, fz_obj *newobj) x = &xref->table[num]; if (x->obj) - fz_dropobj(x->obj); + fz_drop_obj(x->obj); - x->obj = fz_keepobj(newobj); + x->obj = fz_keep_obj(newobj); x->type = 'n'; x->ofs = 0; } /* - * Convenience function to open a file then call pdf_openxrefwithstream. + * Convenience function to open a file then call pdf_open_xref_with_stream. */ fz_error -pdf_openxref(pdf_xref **xrefp, char *filename, char *password) +pdf_open_xref(pdf_xref **xrefp, char *filename, char *password) { fz_error error; pdf_xref *xref; fz_stream *file; - file = fz_openfile(filename); + file = fz_open_file(filename); if (!file) return fz_throw("cannot open file '%s': %s", filename, strerror(errno)); - error = pdf_openxrefwithstream(&xref, file, password); + error = pdf_open_xref_with_stream(&xref, file, password); if (error) return fz_rethrow(error, "cannot load document '%s'", filename); diff --git a/rename.sed b/rename.sed new file mode 100644 index 00000000..2949bf92 --- /dev/null +++ b/rename.sed @@ -0,0 +1,1135 @@ +s/\/FD_ALL_CAP/g +s/\/FD_FIXED_PITCH/g +s/\/FD_FORCE_BOLD/g +s/\/FD_SMALL_CAP/g +s/\/FZ_BLEND_COLOR/g +s/\/FZ_BLEND_COLOR_BURN/g +s/\/FZ_BLEND_COLOR_DODGE/g +s/\/FZ_BLEND_DARKEN/g +s/\/FZ_BLEND_DIFFERENCE/g +s/\/FZ_BLEND_EXCLUSION/g +s/\/FZ_BLEND_HARD_LIGHT/g +s/\/FZ_BLEND_HUE/g +s/\/FZ_BLEND_LIGHTEN/g +s/\/FZ_BLEND_LUMINOSITY/g +s/\/FZ_BLEND_MULTIPLY/g +s/\/FZ_BLEND_NORMAL/g +s/\/FZ_BLEND_OVERLAY/g +s/\/FZ_BLEND_SATURATION/g +s/\/FZ_BLEND_SCREEN/g +s/\/FZ_BLEND_SOFT_LIGHT/g +s/\/FZ_CLOSE_PATH/g +s/\/FZ_CMD_BEGIN_GROUP/g +s/\/FZ_CMD_BEGIN_MASK/g +s/\/FZ_CMD_BEGIN_TILE/g +s/\/FZ_CMD_CLIP_IMAGE_MASK/g +s/\/FZ_CMD_CLIP_PATH/g +s/\/FZ_CMD_CLIP_STROKE_PATH/g +s/\/FZ_CMD_CLIP_STROKE_TEXT/g +s/\/FZ_CMD_CLIP_TEXT/g +s/\/FZ_CMD_END_GROUP/g +s/\/FZ_CMD_END_MASK/g +s/\/FZ_CMD_END_TILE/g +s/\/FZ_CMD_FILL_IMAGE/g +s/\/FZ_CMD_FILL_IMAGE_MASK/g +s/\/FZ_CMD_FILL_PATH/g +s/\/FZ_CMD_FILL_SHADE/g +s/\/FZ_CMD_FILL_TEXT/g +s/\/FZ_CMD_IGNORE_TEXT/g +s/\/FZ_CMD_POP_CLIP/g +s/\/FZ_CMD_STROKE_PATH/g +s/\/FZ_CMD_STROKE_TEXT/g +s/\/FZ_IGNORE_IMAGE/g +s/\/FZ_IGNORE_SHADE/g +s/\/FZ_MAX_COLORS/g +s/\/IS_DELIM/g +s/\/IS_HEX/g +s/\/IS_NUMBER/g +s/\/IS_WHITE/g +s/\/LINE_COUNT/g +s/\/LINE_DIST/g +s/\/LINE_LEN/g +s/\/MAX_BITS/g +s/\/MAX_CACHE_SIZE/g +s/\/MAX_DEPTH/g +s/\/MAX_FONT_SIZE/g +s/\/MAX_GLYPH_SIZE/g +s/\/MAX_KEY_LEN/g +s/\/MAX_LENGTH/g +s/\/MIN_BITS/g +s/\/NUM_CODES/g +s/\/PDF_LINK_ACTION/g +s/\/PDF_LINK_GOTO/g +s/\/PDF_LINK_LAUNCH/g +s/\/PDF_LINK_NAMED/g +s/\/PDF_LINK_URI/g +s/\/PDF_MAT_COLOR/g +s/\/PDF_FILL/g +s/\/PDF_MAT_NONE/g +s/\/PDF_MAT_PATTERN/g +s/\/PDF_MAT_SHADE/g +s/\/PDF_STROKE/g +s/\/PDF_NUM_TOKENS/g +s/\/PDF_TOK_CLOSE_ARRAY/g +s/\/PDF_TOK_CLOSE_BRACE/g +s/\/PDF_TOK_CLOSE_DICT/g +s/\/PDF_TOK_ENDOBJ/g +s/\/PDF_TOK_ENDSTREAM/g +s/\/PDF_TOK_EOF/g +s/\/PDF_TOK_ERROR/g +s/\/PDF_TOK_FALSE/g +s/\/PDF_TOK_INT/g +s/\/PDF_TOK_KEYWORD/g +s/\/PDF_TOK_NAME/g +s/\/PDF_TOK_NULL/g +s/\/PDF_TOK_OPEN_ARRAY/g +s/\/PDF_TOK_OBJ/g +s/\/PDF_TOK_OPEN_BRACE/g +s/\/PDF_TOK_OPEN_DICT/g +s/\/PDF_TOK_R/g +s/\/PDF_TOK_REAL/g +s/\/PDF_TOK_STARTXREF/g +s/\/PDF_TOK_STREAM/g +s/\/PDF_TOK_STRING/g +s/\/PDF_TOK_TRAILER/g +s/\/PDF_TOK_TRUE/g +s/\/PDF_TOK_XREF/g +s/\/PS_BLOCK/g +s/\/PS_BOOL/g +s/\/PS_INT/g +s/\/PS_OP_ABS/g +s/\/PS_OP_ADD/g +s/\/PS_OP_AND/g +s/\/PS_OP_ATAN/g +s/\/PS_OP_BITSHIFT/g +s/\/PS_OP_CEILING/g +s/\/PS_OP_COPY/g +s/\/PS_OP_COS/g +s/\/PS_OP_CVI/g +s/\/PS_OP_CVR/g +s/\/PS_OP_DIV/g +s/\/PS_OP_DUP/g +s/\/PS_OP_EQ/g +s/\/PS_OP_EXCH/g +s/\/PS_OP_EXP/g +s/\/PS_OP_FALSE/g +s/\/PS_OP_FLOOR/g +s/\/PS_OP_GE/g +s/\/PS_OP_GT/g +s/\/PS_OP_IDIV/g +s/\/PS_OP_IF/g +s/\/PS_OP_IFELSE/g +s/\/PS_OP_INDEX/g +s/\/PS_OP_LE/g +s/\/PS_OP_LN/g +s/\/PS_OP_LOG/g +s/\/PS_OP_LT/g +s/\/PS_OP_MOD/g +s/\/PS_OP_MUL/g +s/\/PS_OP_NE/g +s/\/PS_OP_NEG/g +s/\/PS_OP_NOT/g +s/\/PS_OP_OR/g +s/\/PS_OPERATOR/g +s/\/PS_OP_POP/g +s/\/PS_OP_RETURN/g +s/\/PS_OP_ROLL/g +s/\/PS_OP_ROUND/g +s/\/PS_OP_SIN/g +s/\/PS_OP_SQRT/g +s/\/PS_OP_SUB/g +s/\/PS_OP_TRUE/g +s/\/PS_OP_TRUNCATE/g +s/\/PS_OP_XOR/g +s/\/PS_REAL/g +s/\/STATE_DONE/g +s/\/STATE_EOL/g +s/\/STATE_H1/g +s/\/STATE_H2/g +s/\/STATE_MAKEUP/g +s/\/STATE_NORMAL/g +s/\/SPACE_DIST/g +s/\/STACK_SIZE/g +s/\/TOK_BEGIN_BF_CHAR/g +s/\/TOK_BEGIN_BF_RANGE/g +s/\/TOK_BEGIN_CID_CHAR/g +s/\/TOK_BEGIN_CID_RANGE/g +s/\/TOK_BEGIN_CODESPACE_RANGE/g +s/\/TOK_END_BF_CHAR/g +s/\/TOK_END_BF_RANGE/g +s/\/TOK_END_CID_CHAR/g +s/\/TOK_END_CID_RANGE/g +s/\/TOK_END_CMAP/g +s/\/TOK_END_CODESPACE_RANGE/g +s/\/TOK_USECMAP/g +s/\/add_range/g +s/\/add_span/g +s/\/add_table/g +s/\/adj_down/g +s/\/adj_up/g +s/\/advance_ael/g +s/\/agl_codes/g +s/\/agl_dup_codes/g +s/\/agl_dup_names/g +s/\/agl_no_name/g +s/\/base_font_names/g +s/\/base_fonts/g +s/\/begin_group/g +s/\/begin_mask/g +s/\/begin_tile/g +s/\/bgr_to_xyz/g +s/\/black_is_1/g +s/\/bound_expand/g +s/\/build_filter/g +s/\/build_filter_chain/g +s/\/cap_height/g +s/\/char_space/g +s/\/cid_to_gid/g +s/\/cid_to_ucs/g +s/\/clean_font_name/g +s/\/clip_depth/g +s/\/clip_even_odd/g +s/\/clip_image_mask/g +s/\/clip_lerp_x/g +s/\/clip_lerp_y/g +s/\/clip_path/g +s/\/clip_poly/g +s/\/clip_stroke_path/g +s/\/clip_stroke_text/g +s/\/clip_text/g +s/\/close_a85d/g +s/\/close_aesd/g +s/\/close_ahxd/g +s/\/close_arc4/g +s/\/close_buffer/g +s/\/close_dctd/g +s/\/close_faxd/g +s/\/close_file/g +s/\/close_flated/g +s/\/close_jbig2d/g +s/\/close_lzwd/g +s/\/close_null/g +s/\/close_predict/g +s/\/close_rld/g +s/\/cmap_name/g +s/\/cmyk_to_xyz/g +s/\/code_bits/g +s/\/color_transform/g +s/\/copy_vert/g +s/\/codespace/g +s/\/dash_len/g +s/\/dash_list/g +s/\/dash_phase/g +s/\/draw_glyph/g +s/\/draw_patch/g +s/\/draw_stripe/g +s/\/drop_func/g +s/\/early_change/g +s/\/eat_bits/g +s/\/items/g +s/\/encoded_byte_align/g +s/\/encrypt_metadata/g +s/\/end_group/g +s/\/end_mask/g +s/\/end_of_block/g +s/\/end_of_line/g +s/\/end_tile/g +s/\/error_count/g +s/\/error_message/g +s/\/eval_exponential_func/g +s/\/eval_postscript_func/g +s/\/eval_sample_func/g +s/\/eval_stitching_func/g +s/\/even_odd/g +s/\/extent_flags/g +s/\/fast_bgr_to_cmyk/g +s/\/fast_bgr_to_gray/g +s/\/fast_cmyk_to_bgr/g +s/\/fast_cmyk_to_gray/g +s/\/fast_cmyk_to_rgb/g +s/\/fast_gray_to_cmyk/g +s/\/fast_gray_to_rgb/g +s/\/fast_rgb_to_bgr/g +s/\/fast_rgb_to_cmyk/g +s/\/fast_rgb_to_gray/g +s/\/file_size/g +s/\/fill_bits/g +s/\/fill_image/g +s/\/fill_image_mask/g +s/\/fill_path/g +s/\/fill_shade/g +s/\/fill_text/g +s/\/find_changing/g +s/\/find_changing_color/g +s/\/find_next/g +s/\/first_char/g +s/\/flag_to_name/g +s/\/fmt_array/g +s/\/fmt_dict/g +s/\/fmt_hex/g +s/\/fmt_indent/g +s/\/fmt_name/g +s/\/fmt_obj/g +s/\/fmt_putc/g +s/\/fmt_puts/g +s/\/fmt_sep/g +s/\/fmt_str/g +s/\/free_data/g +s/\/free_indexed/g +s/\/free_samples/g +s/\/free_separation/g +s/\/free_user/g +s/\/from_hex/g +s/\/from_xyz/g +s/\/ft_error_string/g +s/\/ft_char_index/g +s/\/ft_cid_to_gid/g +s/\/ft_data/g +s/\/ft_face/g +s/\/ft_file/g +s/\/ft_hint/g +s/\/ft_kind/g +s/\/ft_size/g +s/\/ft_substitute/g +s/\/ft_width/g +s/\/fz_accelerate_arch/g +s/\/fz_add_arc/g +s/\/fz_add_line/g +s/\/fz_add_text/g +s/\/fz_add_text_char/g +s/\/fz_add_text_char_imp/g +s/\/fz_add_text_newline/g +s/\/fz_adjust_ft_glyph_width/g +s/\/fz_alpha_from_gray/g +s/\/fz_append_display_node/g +s/\/fz_arc4_encrypt/g +s/\/fz_arc4_init/g +s/\/fz_arc4_next/g +s/\/fz_array_drop/g +s/\/fz_array_get/g +s/\/fz_array_insert/g +s/\/fz_array_len/g +s/\/fz_array_push/g +s/\/fz_array_put/g +s/\/fz_bbox_device/g +s/\/fz_bbox_device_s/g +s/\/fz_bbox_fill_image/g +s/\/fz_bbox_fill_image_mask/g +s/\/fz_bbox_fill_path/g +s/\/fz_bbox_fill_shade/g +s/\/fz_bbox_fill_text/g +s/\/fz_bbox_free_user/g +s/\/fz_bbox_stroke_path/g +s/\/fz_bbox_stroke_text/g +s/\/fz_blendmode_names/g +s/\/fz_blend_nonseparable/g +s/\/fz_blend_pixmap/g +s/\/fz_blend_separable/g +s/\/fz_bound_gel/g +s/\/fz_bound_path/g +s/\/fz_bound_pixmap/g +s/\/fz_bound_shade/g +s/\/fz_bound_text/g +s/\/fz_calc_image_scale/g +s/\/fz_catch_imp/g +s/\/fz_catch_impx/g +s/\/fz_clear_pixmap/g +s/\/fz_clear_pixmap_with_color/g +s/\/fz_clone_path/g +s/\/fz_clone_stroke_state/g +s/\/fz_clone_text/g +s/\/fz_color_burn_byte/g +s/\/fz_color_dodge_byte/g +s/\/fz_convert_color/g +s/\/fz_convert_pixmap/g +s/\/fz_copy_array/g +s/\/fz_copy_dict/g +s/\/fz_dash_bezier/g +s/\/fz_dash_lineto/g +s/\/fz_dash_moveto/g +s/\/fz_dash_path/g +s/\/fz_debug_font/g +s/\/fz_debug_hash/g +s/\/fz_debug_obj/g +s/\/fz_debug_path/g +s/\/fz_debug_ref/g +s/\/fz_debug_shade/g +s/\/fz_debug_text/g +s/\/fz_debug_text_span/g +s/\/fz_debug_text_span_xml/g +s/\/fz_decode_indexed_tile/g +s/\/fz_decode_tile/g +s/\/fz_device_bgr/g +s/\/fz_device_cmyk/g +s/\/fz_device_gray/g +s/\/fz_device_lab/g +s/\/fz_device_rgb/g +s/\/fz_dict_del/g +s/\/fz_dict_dels/g +s/\/fz_dict_finds/g +s/\/fz_dict_get/g +s/\/fz_dict_get_key/g +s/\/fz_dict_gets/g +s/\/fz_dict_getsa/g +s/\/fz_dict_get_val/g +s/\/fz_dict_len/g +s/\/fz_dict_put/g +s/\/fz_dict_puts/g +s/\/fz_display_command/g +s/\/fz_display_command_e/g +s/\/fz_display_list/g +s/\/fz_display_list_s/g +s/\/fz_display_node/g +s/\/fz_display_node_s/g +s/\/fz_divide_text_chars/g +s/\/fz_draw_begin_group/g +s/\/fz_draw_begin_mask/g +s/\/fz_draw_begin_tile/g +s/\/fz_draw_clip_image_mask/g +s/\/fz_draw_clip_path/g +s/\/fz_draw_clip_stroke_path/g +s/\/fz_draw_clip_stroke_text/g +s/\/fz_draw_clip_text/g +s/\/fz_draw_device/g +s/\/fz_draw_device_s/g +s/\/fz_draw_end_group/g +s/\/fz_draw_end_mask/g +s/\/fz_draw_end_tile/g +s/\/fz_draw_fill_image/g +s/\/fz_draw_fill_image_mask/g +s/\/fz_draw_fill_path/g +s/\/fz_draw_fill_shade/g +s/\/fz_draw_fill_text/g +s/\/fz_draw_free_user/g +s/\/fz_draw_ignore_text/g +s/\/fz_draw_pop_clip/g +s/\/fz_draw_stroke_path/g +s/\/fz_draw_stroke_text/g +s/\/fz_drop_buffer/g +s/\/fz_drop_colorspace/g +s/\/fz_drop_font/g +s/\/fz_drop_obj/g +s/\/fz_drop_pixmap/g +s/\/fz_drop_shade/g +s/\/fz_emit_error/g +s/\/fz_empty_bbox/g +s/\/fz_empty_hash/g +s/\/fz_empty_rect/g +s/\/fz_evict_glyph_cache/g +s/\/fz_execute_display_list/g +s/\/fz_fill_buffer/g +s/\/fz_fill_path/g +s/\/fz_finalize_freetype/g +s/\/fz_flush_warnings/g +s/\/fz_fprint_obj/g +s/\/fz_free_ael/g +s/\/fz_free_array/g +s/\/fz_free_device/g +s/\/fz_free_dict/g +s/\/fz_free_display_list/g +s/\/fz_free_display_node/g +s/\/fz_free_gel/g +s/\/fz_free_glyph_cache/g +s/\/fz_free_hash/g +s/\/fz_free_path/g +s/\/fz_free_text/g +s/\/fz_free_text_span/g +s/\/fz_get_error_count/g +s/\/fz_get_error_line/g +s/\/fz_glyph_cache/g +s/\/fz_glyph_cache_s/g +s/\/fz_glyph_key/g +s/\/fz_glyph_key_s/g +s/\/fz_grow_buffer/g +s/\/fz_grow_text/g +s/\/fz_hard_light_byte/g +s/\/fz_hash_entry/g +s/\/fz_hash_entry_s/g +s/\/fz_hash_find/g +s/\/fz_hash_get_key/g +s/\/fz_hash_get_val/g +s/\/fz_hash_insert/g +s/\/fz_hash_len/g +s/\/fz_hash_remove/g +s/\/fz_hash_table/g +s/\/fz_hash_table_s/g +s/\/fz_infinite_bbox/g +s/\/fz_infinite_rect/g +s/\/fz_init_freetype/g +s/\/fz_insert_gel/g +s/\/fz_insert_gel_raw/g +s/\/fz_intersect_bbox/g +s/\/fz_invert_matrix/g +s/\/fz_is_array/g +s/\/fz_is_big_endian/g +s/\/fz_is_bool/g +s/\/fz_is_dict/g +s/\/fz_is_empty_bbox/g +s/\/fz_is_empty_rect/g +s/\/fz_is_eof/g +s/\/fz_is_eof_bits/g +s/\/fz_is_indirect/g +s/\/fz_is_infinite_bbox/g +s/\/fz_is_infinite_rect/g +s/\/fz_is_int/g +s/\/fz_is_name/g +s/\/fz_is_null/g +s/\/fz_is_real/g +s/\/fz_is_rect_gel/g +s/\/fz_is_rectilinear/g +s/\/fz_is_string/g +s/\/fz_keep_buffer/g +s/\/fz_keep_colorspace/g +s/\/fz_keep_font/g +s/\/fz_keep_obj/g +s/\/fz_keep_pixmap/g +s/\/fz_keep_shade/g +s/\/fz_keep_stream/g +s/\/fz_list_begin_group/g +s/\/fz_list_begin_mask/g +s/\/fz_list_begin_tile/g +s/\/fz_list_clip_image_mask/g +s/\/fz_list_clip_path/g +s/\/fz_list_clip_stroke_path/g +s/\/fz_list_clip_stroke_text/g +s/\/fz_list_clip_text/g +s/\/fz_list_end_group/g +s/\/fz_list_end_mask/g +s/\/fz_list_end_tile/g +s/\/fz_list_fill_image/g +s/\/fz_list_fill_image_mask/g +s/\/fz_list_fill_path/g +s/\/fz_list_fill_shade/g +s/\/fz_list_fill_text/g +s/\/fz_list_ignore_text/g +s/\/fz_list_pop_clip/g +s/\/fz_list_stroke_path/g +s/\/fz_list_stroke_text/g +s/\/fz_load_jpx_image/g +s/\/fz_matrix_expansion/g +s/\/fz_md5_final/g +s/\/fz_md5_init/g +s/\/fz_md5_update/g +s/\/fz_new_ael/g +s/\/fz_new_array/g +s/\/fz_new_bbox_device/g +s/\/fz_new_bool/g +s/\/fz_new_buffer/g +s/\/fz_new_colorspace/g +s/\/fz_new_device/g +s/\/fz_new_dict/g +s/\/fz_new_display_list/g +s/\/fz_new_display_node/g +s/\/fz_new_draw_device/g +s/\/fz_new_font/g +s/\/fz_new_font_from_memory/g +s/\/fz_new_font_from_file/g +s/\/fz_new_gel/g +s/\/fz_new_glyph_cache/g +s/\/fz_new_hash_table/g +s/\/fz_new_indirect/g +s/\/fz_new_int/g +s/\/fz_new_list_device/g +s/\/fz_new_name/g +s/\/fz_new_null/g +s/\/fz_new_path/g +s/\/fz_new_pixmap/g +s/\/fz_new_pixmap_with_data/g +s/\/fz_new_pixmap_with_rect/g +s/\/fz_new_real/g +s/\/fz_new_stream/g +s/\/fz_new_string/g +s/\/fz_new_text/g +s/\/fz_new_text_device/g +s/\/fz_new_text_span/g +s/\/fz_new_trace_device/g +s/\/fz_new_type3_font/g +s/\/fz_null_begin_group/g +s/\/fz_null_begin_mask/g +s/\/fz_null_begin_tile/g +s/\/fz_null_clip_image_mask/g +s/\/fz_null_clip_path/g +s/\/fz_null_clip_stroke_path/g +s/\/fz_null_clip_stroke_text/g +s/\/fz_null_clip_text/g +s/\/fz_null_end_group/g +s/\/fz_null_end_mask/g +s/\/fz_null_end_tile/g +s/\/fz_null_fill_image/g +s/\/fz_null_fill_image_mask/g +s/\/fz_null_fill_path/g +s/\/fz_null_fill_shade/g +s/\/fz_null_fill_text/g +s/\/fz_null_free_user/g +s/\/fz_null_ignore_text/g +s/\/fz_null_pop_clip/g +s/\/fz_null_stroke_path/g +s/\/fz_null_stroke_text/g +s/\/fz_open_a85d/g +s/\/fz_open_aesd/g +s/\/fz_open_ahxd/g +s/\/fz_open_arc4/g +s/\/fz_open_buffer/g +s/\/fz_open_copy/g +s/\/fz_open_dctd/g +s/\/fz_open_faxd/g +s/\/fz_open_fd/g +s/\/fz_open_file/g +s/\/fz_open_file_w/g +s/\/fz_open_flated/g +s/\/fz_open_jbig2d/g +s/\/fz_open_lzwd/g +s/\/fz_open_memory/g +s/\/fz_open_null/g +s/\/fz_open_predict/g +s/\/fz_open_rld/g +s/\/fz_paint_affine_N_lerp/g +s/\/fz_paint_affine_N_near/g +s/\/fz_paint_affine_alpha_N_lerp/g +s/\/fz_paint_affine_alpha_N_near/g +s/\/fz_paint_affine_color_N_lerp/g +s/\/fz_paint_affine_color_N_near/g +s/\/fz_paint_affine_color_lerp/g +s/\/fz_paint_affine_color_near/g +s/\/fz_paint_affine_lerp/g +s/\/fz_paint_affine_near/g +s/\/fz_paint_annulus/g +s/\/fz_paint_image/g +s/\/fz_paint_image_with_color/g +s/\/fz_paint_image_imp/g +s/\/fz_paint_linear/g +s/\/fz_paint_mesh/g +s/\/fz_paint_pixmap/g +s/\/fz_paint_pixmap_with_rect/g +s/\/fz_paint_pixmap_with_mask/g +s/\/fz_paint_quad/g +s/\/fz_paint_radial/g +s/\/fz_paint_shade/g +s/\/fz_paint_span/g +s/\/fz_paint_span_1/g +s/\/fz_paint_span_2/g +s/\/fz_paint_span_2_alpha/g +s/\/fz_paint_span_4/g +s/\/fz_paint_span_4_alpha/g +s/\/fz_paint_span_N/g +s/\/fz_paint_span_N_alpha/g +s/\/fz_paint_span_with_color/g +s/\/fz_paint_span_with_color_2/g +s/\/fz_paint_span_with_color_4/g +s/\/fz_paint_span_with_color_N/g +s/\/fz_paint_span_with_mask/g +s/\/fz_paint_span_with_mask_2/g +s/\/fz_paint_span_with_mask_4/g +s/\/fz_paint_span_with_mask_N/g +s/\/fz_paint_triangle/g +s/\/fz_path_item/g +s/\/fz_path_item_s/g +s/\/fz_path_item_kind/g +s/\/fz_path_item_kind_e/g +s/\/fz_peek_byte/g +s/\/fz_point_on_circle/g +s/\/fz_predict_png/g +s/\/fz_predict_tiff/g +s/\/fz_premultiply_pixmap/g +s/\/fz_read_all/g +s/\/fz_read_bits/g +s/\/fz_read_byte/g +s/\/fz_read_line/g +s/\/fz_render_ft_glyph/g +s/\/fz_render_ft_stroked_glyph/g +s/\/fz_render_glyph/g +s/\/fz_render_stroked_glyph/g +s/\/fz_render_t3_glyph/g +s/\/pdf_repair_obj/g +s/\/fz_reset_gel/g +s/\/fz_resize_buffer/g +s/\/fz_resize_hash/g +s/\/fz_resolve_indirect/g +s/\/fz_rethrow_imp/g +s/\/fz_rethrow_impx/g +s/\/fz_round_rect/g +s/\/fz_scale_filter/g +s/\/fz_scale_filter_box/g +s/\/fz_scale_filter_lanczos2/g +s/\/fz_scale_filter_lanczos3/g +s/\/fz_scale_filter_mitchell/g +s/\/fz_scale_filter_s/g +s/\/fz_scale_filter_simple/g +s/\/fz_scale_filter_triangle/g +s/\/fz_scale_pixmap/g +s/\/fz_scan_convert/g +s/\/fz_set_font_bbox/g +s/\/fz_sha256_final/g +s/\/fz_sha256_init/g +s/\/fz_sha256_update/g +s/\/fz_smooth_scale_pixmap/g +s/\/fz_smooth_transform_pixmap/g +s/\/fz_soft_light_byte/g +s/\/fz_sort_dict/g +s/\/fz_sort_gel/g +s/\/fz_split_bbox/g +s/\/fz_sprint_obj/g +s/\/fz_std_conv_color/g +s/\/fz_std_conv_pixmap/g +s/\/fz_stroke_bezier/g +s/\/fz_stroke_closepath/g +s/\/fz_stroke_flush/g +s/\/fz_stroke_lineto/g +s/\/fz_stroke_moveto/g +s/\/fz_stroke_path/g +s/\/fz_stroke_state/g +s/\/fz_stroke_state_s/g +s/\/fz_sync_bits/g +s/\/fz_text_char/g +s/\/fz_text_char_s/g +s/\/fz_text_clip_stroke_text/g +s/\/fz_text_clip_text/g +s/\/fz_text_device/g +s/\/fz_text_device_s/g +s/\/fz_text_item/g +s/\/fz_text_item_s/g +s/\/fz_text_extract_span/g +s/\/fz_text_fill_text/g +s/\/fz_text_free_user/g +s/\/fz_text_ignore_text/g +s/\/fz_text_span/g +s/\/fz_text_span_s/g +s/\/fz_text_stroke_text/g +s/\/fz_throw_imp/g +s/\/fz_throw_impx/g +s/\/fz_to_bool/g +s/\/fz_to_gen/g +s/\/fz_to_int/g +s/\/fz_to_name/g +s/\/fz_to_num/g +s/\/fz_to_real/g +s/\/fz_to_str_buf/g +s/\/fz_to_str_len/g +s/\/fz_trace_begin_group/g +s/\/fz_trace_begin_mask/g +s/\/fz_trace_begin_tile/g +s/\/fz_trace_clip_image_mask/g +s/\/fz_trace_clip_path/g +s/\/fz_trace_clip_stroke_path/g +s/\/fz_trace_clip_stroke_text/g +s/\/fz_trace_clip_text/g +s/\/fz_trace_color/g +s/\/fz_trace_end_group/g +s/\/fz_trace_end_mask/g +s/\/fz_trace_end_tile/g +s/\/fz_trace_fill_image/g +s/\/fz_trace_fill_image_mask/g +s/\/fz_trace_fill_path/g +s/\/fz_trace_fill_shade/g +s/\/fz_trace_fill_text/g +s/\/fz_trace_ignore_text/g +s/\/fz_trace_matrix/g +s/\/fz_trace_path/g +s/\/fz_trace_pop_clip/g +s/\/fz_trace_stroke_path/g +s/\/fz_trace_stroke_text/g +s/\/fz_transform_bbox/g +s/\/fz_transform_path/g +s/\/fz_transform_pixmap/g +s/\/fz_transform_point/g +s/\/fz_transform_rect/g +s/\/fz_transform_vector/g +s/\/fz_union_bbox/g +s/\/fz_unit_bbox/g +s/\/fz_unit_rect/g +s/\/fz_unpack_tile/g +s/\/fz_unread_byte/g +s/\/fz_write_pam/g +s/\/fz_write_png/g +s/\/fz_write_pnm/g +s/\/get1_tab_1/g +s/\/get1_tab_1p/g +s/\/get1_tab_255/g +s/\/get1_tab_255p/g +s/\/gray_to_xyz/g +s/\/grow_path/g +s/\/has_range/g +s/\/hmtx_cap/g +s/\/id_length/g +s/\/id_string/g +s/\/ignore_text/g +s/\/in_array/g +s/\/indexed_to_xyz/g +s/\/init_get1_tables/g +s/\/insert_ael/g +s/\/interpolate_sample/g +s/\/in_text/g +s/\/italic_angle/g +s/\/k_device_bgr/g +s/\/k_device_cmyk/g +s/\/k_device_gray/g +s/\/k_device_lab/g +s/\/k_device_rgb/g +s/\/lab_to_xyz/g +s/\/lex_comment/g +s/\/lex_hex_string/g +s/\/lex_name/g +s/\/lex_number/g +s/\/lex_string/g +s/\/lex_white/g +s/\/load_cid_font/g +s/\/load_edge/g +s/\/load_exponential_func/g +s/\/load_icc_based/g +s/\/load_indexed/g +s/\/load_postscript_func/g +s/\/load_sample_func/g +s/\/load_separation/g +s/\/load_simple_font/g +s/\/load_stitching_func/g +s/\/load_system_cid_font/g +s/\/load_tile8_arm/g +s/\/load_type0_font/g +s/\/mesh_cap/g +s/\/mesh_len/g +s/\/mesh_params/g +s/\/missing_width/g +s/\/mre_code/g +s/\/cid_to_gid_len/g +s/\/cid_to_ucs_len/g +s/\/codespace_len/g +s/\/new_weights/g +s/\/next_code/g +s/\/hmtx_len/g +s/\/NULL/g +s/\/non_zero_winding/g +s/\/null_filter/g +s/\/vmtx_len/g +s/\/old_code/g +s/\/page_cap/g +s/\/page_len/g +s/\/page_objs/g +s/\/page_refs/g +s/\/paint_scan/g +s/\/parse_code/g +s/\/pdf_add_codespace/g +s/\/pdf_add_hmtx/g +s/\/pdf_add_quad/g +s/\/pdf_add_triangle/g +s/\/pdf_add_vertex/g +s/\/pdf_add_vmtx/g +s/\/pdf_age_store/g +s/\/pdf_authenticate_owner_password/g +s/\/pdf_authenticate_password/g +s/\/pdf_authenticate_user_password/g +s/\/pdf_begin_group/g +s/\/pdf_cache_object/g +s/\/pdf_clear_stack/g +s/\/pdf_cmap_table/g +s/\/pdf_cmap_token_from_keyword/g +s/\/pdf_code_from_string/g +s/\/pdf_compute_encryption_key/g +s/\/pdf_compute_encryption_key_r5/g +s/\/pdf_compute_object_key/g +s/\/pdf_compute_tensor_interior/g +s/\/pdf_compute_user_password/g +s/\/pdf_crypt_filter/g +s/\/pdf_crypt_filter_s/g +s/\/pdf_crypt_obj/g +s/\/pdf_crypt_obj_imp/g +s/\/pdf_debug_cmap/g +s/\/pdf_debug_crypt/g +s/\/pdf_debug_font/g +s/\/pdf_debug_function/g +s/\/pdf_debug_function_imp/g +s/\/pdf_debug_indent/g +s/\/pdf_debug_outline/g +s/\/pdf_debug_ps_func_code/g +s/\/pdf_debug_ps_stack/g +s/\/pdf_debug_store/g +s/\/pdf_debug_xref/g +s/\/pdf_decode_cmap/g +s/\/pdf_doc_encoding/g +s/\/pdf_drop_cmap/g +s/\/pdf_drop_font/g +s/\/pdf_drop_function/g +s/\/pdf_drop_material/g +s/\/pdf_drop_pattern/g +s/\/pdf_drop_xobject/g +s/\/pdf_end_group/g +s/\/pdf_end_hmtx/g +s/\/pdf_end_vmtx/g +s/\/pdf_eval_function/g +s/\/pdf_expand_indexed_pixmap/g +s/\/pdf_extgstate_uses_blending/g +s/\/pdf_find_item/g +s/\/pdf_find_page_object/g +s/\/pdf_flush_text/g +s/\/pdf_font_cid_to_gid/g +s/\/pdf_font_desc/g +s/\/pdf_font_desc_s/g +s/\/pdf_free_annot/g +s/\/pdf_free_crypt/g +s/\/pdf_free_csi/g +s/\/pdf_free_link/g +s/\/pdf_free_outline/g +s/\/pdf_free_page/g +s/\/pdf_free_store/g +s/\/pdf_free_xref/g +s/\/pdf_get_hmtx/g +s/\/pdf_get_page_count/g +s/\/pdf_get_page_object/g +s/\/pdf_get_page_ref/g +s/\/pdf_get_vmtx/g +s/\/pdf_get_wmode/g +s/\/pdf_grow_mesh/g +s/\/pdf_guess_filter_length/g +s/\/pdf_init_gstate/g +s/\/pdf_is_hidden_ocg/g +s/\/pdf_is_jpx_image/g +s/\/pdf_is_stream/g +s/\/pdf_keep_cmap/g +s/\/pdf_keep_font/g +s/\/pdf_keep_function/g +s/\/pdf_keep_material/g +s/\/pdf_keep_pattern/g +s/\/pdf_keep_xobject/g +s/\/pdf_lex_cmap/g +s/\/pdf_link_kind/g +s/\/pdf_link_kind_e/g +s/\/pdf_load_annots/g +s/\/pdf_load_axial_shading/g +s/\/pdf_load_builtin_font/g +s/\/pdf_load_colorspace/g +s/\/pdf_load_colorspace_imp/g +s/\/pdf_load_embedded_cmap/g +s/\/pdf_load_embedded_font/g +s/\/pdf_load_encoding/g +s/\/pdf_load_font/g +s/\/pdf_load_font_descriptor/g +s/\/pdf_load_function/g +s/\/pdf_load_function_based_shading/g +s/\/pdf_load_image/g +s/\/pdf_load_image_imp/g +s/\/pdf_load_inline_image/g +s/\/pdf_load_jpx_image/g +s/\/pdf_load_link/g +s/\/pdf_load_links/g +s/\/pdf_load_mesh_params/g +s/\/pdf_load_name_tree/g +s/\/pdf_load_name_tree_imp/g +s/\/pdf_load_object/g +s/\/pdf_load_obj_stm/g +s/\/pdf_load_outline/g +s/\/pdf_load_outline_imp/g +s/\/pdf_load_page/g +s/\/pdf_load_page_contents/g +s/\/pdf_load_page_contents_array/g +s/\/pdf_load_page_tree/g +s/\/pdf_load_page_tree_node/g +s/\/pdf_load_pattern/g +s/\/pdf_load_radial_shading/g +s/\/pdf_load_raw_stream/g +s/\/pdf_load_shading/g +s/\/pdf_load_shading_dict/g +s/\/pdf_load_stream/g +s/\/pdf_load_system_cmap/g +s/\/pdf_load_system_font/g +s/\/pdf_load_to_unicode/g +s/\/pdf_load_type3_font/g +s/\/pdf_load_type4_shade/g +s/\/pdf_load_type5_shade/g +s/\/pdf_load_type6_shade/g +s/\/pdf_load_type7_shade/g +s/\/pdf_load_version/g +s/\/pdf_load_xobject/g +s/\/pdf_load_xref/g +s/\/pdf_log_font/g +s/\/pdf_log_image/g +s/\/pdf_log_page/g +s/\/pdf_log_rsrc/g +s/\/pdf_log_shade/g +s/\/pdf_log_xref/g +s/\/pdf_lookup_agl/g +s/\/pdf_lookup_agl_names/g +s/\/pdf_lookup_cmap/g +s/\/pdf_lookup_cmap_full/g +s/\/pdf_lookup_dest/g +s/\/pdf_lookup_name/g +s/\/pdf_lookup_name_imp/g +s/\/pdf_mac_expert/g +s/\/pdf_mac_roman/g +s/\/pdf_make_tensor_patch/g +s/\/pdf_make_width_table/g +s/\/pdf_map_one_to_many/g +s/\/pdf_map_range_to_range/g +s/\/pdf_map_range_to_table/g +s/\/pdf_mask_color_key/g +s/\/pdf_needs_password/g +s/\/pdf_new_cmap/g +s/\/pdf_new_crypt/g +s/\/pdf_new_csi/g +s/\/pdf_new_font_desc/g +s/\/pdf_new_identity_cmap/g +s/\/pdf_new_store/g +s/\/pdf_open_crypt/g +s/\/pdf_open_filter/g +s/\/pdf_open_inline_stream/g +s/\/pdf_open_raw_filter/g +s/\/pdf_open_raw_stream/g +s/\/pdf_open_stream/g +s/\/pdf_open_stream_at/g +s/\/pdf_open_xref/g +s/\/pdf_open_xref_with_stream/g +s/\/pdf_parse_array/g +s/\/pdf_parse_bf_char/g +s/\/pdf_parse_bf_range/g +s/\/pdf_parse_bf_range_array/g +s/\/pdf_parse_cid_char/g +s/\/pdf_parse_cid_range/g +s/\/pdf_parse_cmap/g +s/\/pdf_parse_cmap_name/g +s/\/pdf_parse_codespace_range/g +s/\/pdf_parse_crypt_filter/g +s/\/pdf_parse_dict/g +s/\/pdf_parse_ind_obj/g +s/\/pdf_parse_stm_obj/g +s/\/pdf_parse_wmode/g +s/\/pdf_pattern_uses_blending/g +s/\/pdf_read_new_trailer/g +s/\/pdf_read_new_xref/g +s/\/pdf_read_new_xref_section/g +s/\/pdf_read_old_trailer/g +s/\/pdf_read_old_xref/g +s/\/pdf_read_start_xref/g +s/\/pdf_read_trailer/g +s/\/pdf_read_xref/g +s/\/pdf_read_xref_sections/g +s/\/pdf_remove_item/g +s/\/pdf_repair_obj_stm/g +s/\/pdf_repair_obj_stms/g +s/\/pdf_repair_xref/g +s/\/pdf_resize_xref/g +s/\/pdf_resolve_indirect/g +s/\/pdf_resources_use_blending/g +s/\/pdf_run/g +s/\/pdf_run_csi_buffer/g +s/\/pdf_run_csi_file/g +s/\/pdf_run_extgstate/g +s/\/pdf_run_glyph/g +s/\/pdf_run_inline_image/g +s/\/pdf_run_keyword/g +s/\/pdf_run_page/g +s/\/pdf_run_page_with_usage/g +s/\/pdf_run_xobject/g +s/\/pdf_sample_component_shade_function/g +s/\/pdf_sample_composite_shade_function/g +s/\/pdf_sample_shade_function/g +s/\/pdf_set_color/g +s/\/pdf_set_colorspace/g +s/\/pdf_set_default_hmtx/g +s/\/pdf_set_default_vmtx/g +s/\/pdf_set_font_wmode/g +s/\/pdf_set_pattern/g +s/\/pdf_set_shade/g +s/\/pdf_set_usecmap/g +s/\/pdf_set_wmode/g +s/\/pdf_show_glyph/g +s/\/pdf_show_image/g +s/\/pdf_show_path/g +s/\/pdf_show_pattern/g +s/\/pdf_show_shade/g +s/\/pdf_show_space/g +s/\/pdf_show_string/g +s/\/pdf_show_text/g +s/\/pdf_sort_cmap/g +s/\/pdf_store_item/g +s/\/pdf_stream_has_crypt/g +s/\/pdf_tensor_patch/g +s/\/pdf_tensor_patch_s/g +s/\/pdf_token_from_keyword/g +s/\/pdf_to_matrix/g +s/\/pdf_to_rect/g +s/\/pdf_to_ucs2/g +s/\/pdf_to_utf8/g +s/\/pdf_to_utf8_name/g +s/\/pdf_transform_annot/g +s/\/pdf_unset_pattern/g +s/\/pdf_update_object/g +s/\/pdf_win_ansi/g +s/\/pdf_xobject_uses_blending/g +s/\/pdf_xref_entry/g +s/\/pdf_xref_entry_s/g +s/\/pop_clip/g +s/\/print_bits/g +s/\/print_line/g +s/\/ps_copy/g +s/\/ps_index/g +s/\/ps_init_stack/g +s/\/ps_is_type/g +s/\/ps_is_type2/g +s/\/ps_op_names/g +s/\/ps_overflow/g +s/\/ps_pop_bool/g +s/\/ps_pop_int/g +s/\/ps_pop_real/g +s/\/ps_push_bool/g +s/\/ps_push_int/g +s/\/ps_push_real/g +s/\/ps_roll/g +s/\/ps_run/g +s/\/ps_stack/g +s/\/ps_stack_s/g +s/\/ps_underflow/g +s/\/read_a85d/g +s/\/read_aesd/g +s/\/read_ahxd/g +s/\/read_arc4/g +s/\/read_buffer/g +s/\/read_dctd/g +s/\/read_faxd/g +s/\/read_file/g +s/\/read_flated/g +s/\/read_jbig2d/g +s/\/read_lzwd/g +s/\/read_null/g +s/\/read_predict/g +s/\/read_rld/g +s/\/read_sample/g +s/\/resize_code/g +s/\/resolve_dest/g +s/\/rgb_to_xyz/g +s/\/sample_nearest/g +s/\/seek_buffer/g +s/\/seek_file/g +s/\/separation_to_xyz/g +s/\/softmask_bc/g +s/\/softmask_ctm/g +s/\/sort_ael/g +s/\/split_curve/g +s/\/split_patch/g +s/\/split_stripe/g +s/\/step_edge/g +s/\/stm_len/g +s/\/stm_ofs/g +s/\/strcmp_ignore_space/g +s/\/string_len/g +s/\/stroke_path/g +s/\/stroke_state/g +s/\/stroke_text/g +s/\/text_mode/g +s/\/top_ctm/g +s/\/to_ttf_cmap/g +s/\/to_unicode/g +s/\/to_xyz/g +s/\/triangulate_patch/g +s/\/use_background/g +s/\/usecmap_name/g +s/\/use_function/g +s/\/vmtx_cap/g +s/\/warn_count/g +s/\/warn_message/g +s/\/width_count/g +s/\/width_table/g +s/\/word_space/g +s/\/x_height/g +s/\/xyz_to_bgr/g +s/\/xyz_to_cmyk/g +s/\/xyz_to_gray/g +s/\/xyz_to_lab/g +s/\/xyz_to_rgb/g diff --git a/win32/slimftmodules.h b/win32/slimftmodules.h index 5762018a..96e87d8d 100644 --- a/win32/slimftmodules.h +++ b/win32/slimftmodules.h @@ -18,4 +18,3 @@ FT_USE_MODULE( FT_Renderer_Class, ft_smooth_renderer_class ) // FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcd_renderer_class ) // FT_USE_MODULE( FT_Renderer_Class, ft_smooth_lcdv_renderer_class ) // FT_USE_MODULE( FT_Driver_ClassRec, bdf_driver_class ) - diff --git a/win32/slimftoptions.h b/win32/slimftoptions.h index 2289d7aa..066ee377 100644 --- a/win32/slimftoptions.h +++ b/win32/slimftoptions.h @@ -12,4 +12,3 @@ #undef T1_CONFIG_OPTION_NO_MM_SUPPORT #undef FT_CONFIG_OPTION_OLD_INTERNALS - diff --git a/xps/xps_common.c b/xps/xps_common.c index f4a0dcee..7e7f33e3 100644 --- a/xps/xps_common.c +++ b/xps/xps_common.c @@ -75,9 +75,9 @@ xps_begin_opacity(xps_context *ctx, fz_matrix ctm, fz_rect area, if (opacity_mask_tag) { - ctx->dev->beginmask(ctx->dev->user, area, 0, NULL, NULL); + ctx->dev->begin_mask(ctx->dev->user, area, 0, NULL, NULL); xps_parse_brush(ctx, ctm, area, base_uri, dict, opacity_mask_tag); - ctx->dev->endmask(ctx->dev->user); + ctx->dev->end_mask(ctx->dev->user); } } @@ -94,7 +94,7 @@ xps_end_opacity(xps_context *ctx, char *base_uri, xps_resource *dict, if (opacity_mask_tag) { if (strcmp(xml_tag(opacity_mask_tag), "SolidColorBrush")) - ctx->dev->popclip(ctx->dev->user); + ctx->dev->pop_clip(ctx->dev->user); } } @@ -184,7 +184,7 @@ xps_parse_color(xps_context *ctx, char *base_uri, char *string, char buf[1024]; char *profile; - *csp = fz_devicergb; + *csp = fz_device_rgb; samples[0] = 1; samples[1] = 0; @@ -263,10 +263,10 @@ xps_parse_color(xps_context *ctx, char *base_uri, char *string, /* TODO: load ICC profile */ switch (n) { - case 2: *csp = fz_devicegray; break; - case 4: *csp = fz_devicergb; break; - case 5: *csp = fz_devicecmyk; break; - default: *csp = fz_devicegray; break; + case 2: *csp = fz_device_gray; break; + case 4: *csp = fz_device_rgb; break; + case 5: *csp = fz_device_cmyk; break; + default: *csp = fz_device_gray; break; } } } diff --git a/xps/xps_doc.c b/xps/xps_doc.c index d600aafb..c3255261 100644 --- a/xps/xps_doc.c +++ b/xps/xps_doc.c @@ -328,7 +328,7 @@ xps_load_page(xps_context *ctx, int number) } n ++; } - return nil; + return NULL; } void diff --git a/xps/xps_glyphs.c b/xps/xps_glyphs.c index a5a98f6a..8ae9155a 100644 --- a/xps/xps_glyphs.c +++ b/xps/xps_glyphs.c @@ -21,14 +21,14 @@ static inline int unhex(int a) int xps_count_font_encodings(fz_font *font) { - FT_Face face = font->ftface; + FT_Face face = font->ft_face; return face->num_charmaps; } void xps_identify_font_encoding(fz_font *font, int idx, int *pid, int *eid) { - FT_Face face = font->ftface; + FT_Face face = font->ft_face; *pid = face->charmaps[idx]->platform_id; *eid = face->charmaps[idx]->encoding_id; } @@ -36,14 +36,14 @@ xps_identify_font_encoding(fz_font *font, int idx, int *pid, int *eid) void xps_select_font_encoding(fz_font *font, int idx) { - FT_Face face = font->ftface; + FT_Face face = font->ft_face; FT_Set_Charmap(face, face->charmaps[idx]); } int xps_encode_font_char(fz_font *font, int code) { - FT_Face face = font->ftface; + FT_Face face = font->ft_face; int gid = FT_Get_Char_Index(face, code); if (gid == 0 && face->charmap->platform_id == 3 && face->charmap->encoding_id == 0) gid = FT_Get_Char_Index(face, 0xF000 | code); @@ -54,7 +54,7 @@ void xps_measure_font_glyph(xps_context *ctx, fz_font *font, int gid, xps_glyph_metrics *mtx) { int mask = FT_LOAD_NO_BITMAP | FT_LOAD_NO_HINTING | FT_LOAD_IGNORE_TRANSFORM; - FT_Face face = font->ftface; + FT_Face face = font->ft_face; FT_Fixed hadv, vadv; FT_Set_Char_Size(face, 64, 64, 72, 72); @@ -257,7 +257,7 @@ xps_parse_glyphs_imp(xps_context *ctx, fz_matrix ctm, fz_font *font, float size, else tm = fz_scale(size, -size); - text = fz_newtext(font, tm, is_sideways); + text = fz_new_text(font, tm, is_sideways); while ((us && un > 0) || (is && *is)) { @@ -331,7 +331,7 @@ xps_parse_glyphs_imp(xps_context *ctx, fz_matrix ctm, fz_font *font, float size, f = y - v_offset; } - fz_addtext(text, glyph_index, char_code, e, f); + fz_add_text(text, glyph_index, char_code, e, f); x += advance * 0.01f * size; } @@ -472,7 +472,7 @@ xps_parse_glyphs(xps_context *ctx, fz_matrix ctm, if (strstr(part->name, ".ODTTF")) xps_deobfuscate_font_resource(ctx, part); - code = fz_newfontfrombuffer(&font, part->data, part->size, subfontid); + code = fz_new_font_from_memory(&font, part->data, part->size, subfontid); if (code) { fz_catch(code, "cannot load font resource '%s'", partname); xps_free_part(ctx, part); @@ -484,8 +484,8 @@ xps_parse_glyphs(xps_context *ctx, fz_matrix ctm, xps_hash_insert(ctx->font_table, part->name, font); /* NOTE: we keep part->name in the hashtable and part->data in the font */ - font->ftdata = part->data; - font->ftsize = part->size; + font->ft_data = part->data; + font->ft_size = part->size; fz_free(part); } @@ -512,7 +512,7 @@ xps_parse_glyphs(xps_context *ctx, fz_matrix ctm, atof(origin_x_att), atof(origin_y_att), is_sideways, bidi_level, indices_att, unicode_att); - area = fz_boundtext(text, ctm); + area = fz_bound_text(text, ctm); xps_begin_opacity(ctx, ctm, area, opacity_mask_uri, dict, opacity_att, opacity_mask_tag); @@ -537,7 +537,7 @@ xps_parse_glyphs(xps_context *ctx, fz_matrix ctm, samples[0] = atof(fill_opacity_att); xps_set_color(ctx, colorspace, samples); - ctx->dev->filltext(ctx->dev->user, text, ctm, + ctx->dev->fill_text(ctx->dev->user, text, ctm, ctx->colorspace, ctx->color, ctx->alpha); } @@ -547,15 +547,15 @@ xps_parse_glyphs(xps_context *ctx, fz_matrix ctm, if (fill_tag) { - ctx->dev->cliptext(ctx->dev->user, text, ctm, 0); + ctx->dev->clip_text(ctx->dev->user, text, ctm, 0); xps_parse_brush(ctx, ctm, area, fill_uri, dict, fill_tag); - ctx->dev->popclip(ctx->dev->user); + ctx->dev->pop_clip(ctx->dev->user); } xps_end_opacity(ctx, opacity_mask_uri, dict, opacity_att, opacity_mask_tag); - fz_freetext(text); + fz_free_text(text); if (clip_att || clip_tag) - ctx->dev->popclip(ctx->dev->user); + ctx->dev->pop_clip(ctx->dev->user); } diff --git a/xps/xps_gradient.c b/xps/xps_gradient.c index f03b8f6d..65cb4362 100644 --- a/xps/xps_gradient.c +++ b/xps/xps_gradient.c @@ -61,7 +61,7 @@ xps_parse_gradient_stops(xps_context *ctx, char *base_uri, xml_element *node, xps_parse_color(ctx, base_uri, color, &colorspace, sample); - fz_convertcolor(colorspace, sample + 1, fz_devicergb, rgb); + fz_convert_color(colorspace, sample + 1, fz_device_rgb, rgb); stops[count].r = rgb[0]; stops[count].g = rgb[1]; @@ -214,20 +214,20 @@ xps_draw_one_radial_gradient(xps_context *ctx, fz_matrix ctm, /* TODO: this (and the stuff in pdf_shade) should move to res_shade.c */ shade = fz_malloc(sizeof(fz_shade)); shade->refs = 1; - shade->colorspace = fz_devicergb; - shade->bbox = fz_infiniterect; + shade->colorspace = fz_device_rgb; + shade->bbox = fz_infinite_rect; shade->matrix = fz_identity; - shade->usebackground = 0; - shade->usefunction = 1; + shade->use_background = 0; + shade->use_function = 1; shade->type = FZ_RADIAL; shade->extend[0] = extend; shade->extend[1] = extend; xps_sample_gradient_stops(shade, stops, count); - shade->meshlen = 6; - shade->meshcap = 6; - shade->mesh = fz_calloc(shade->meshcap, sizeof(float)); + shade->mesh_len = 6; + shade->mesh_cap = 6; + shade->mesh = fz_calloc(shade->mesh_cap, sizeof(float)); shade->mesh[0] = x0; shade->mesh[1] = y0; shade->mesh[2] = r0; @@ -235,9 +235,9 @@ xps_draw_one_radial_gradient(xps_context *ctx, fz_matrix ctm, shade->mesh[4] = y1; shade->mesh[5] = r1; - ctx->dev->fillshade(ctx->dev->user, shade, ctm, 1); + ctx->dev->fill_shade(ctx->dev->user, shade, ctm, 1); - fz_dropshade(shade); + fz_drop_shade(shade); } /* @@ -255,20 +255,20 @@ xps_draw_one_linear_gradient(xps_context *ctx, fz_matrix ctm, /* TODO: this (and the stuff in pdf_shade) should move to res_shade.c */ shade = fz_malloc(sizeof(fz_shade)); shade->refs = 1; - shade->colorspace = fz_devicergb; - shade->bbox = fz_infiniterect; + shade->colorspace = fz_device_rgb; + shade->bbox = fz_infinite_rect; shade->matrix = fz_identity; - shade->usebackground = 0; - shade->usefunction = 1; + shade->use_background = 0; + shade->use_function = 1; shade->type = FZ_LINEAR; shade->extend[0] = extend; shade->extend[1] = extend; xps_sample_gradient_stops(shade, stops, count); - shade->meshlen = 6; - shade->meshcap = 6; - shade->mesh = fz_calloc(shade->meshcap, sizeof(float)); + shade->mesh_len = 6; + shade->mesh_cap = 6; + shade->mesh = fz_calloc(shade->mesh_cap, sizeof(float)); shade->mesh[0] = x0; shade->mesh[1] = y0; shade->mesh[2] = 0; @@ -276,9 +276,9 @@ xps_draw_one_linear_gradient(xps_context *ctx, fz_matrix ctm, shade->mesh[4] = y1; shade->mesh[5] = 0; - ctx->dev->fillshade(ctx->dev->user, shade, ctm, 1); + ctx->dev->fill_shade(ctx->dev->user, shade, ctm, 1); - fz_dropshade(shade); + fz_drop_shade(shade); } /* diff --git a/xps/xps_image.c b/xps/xps_image.c index bc37d2e6..468c6411 100644 --- a/xps/xps_image.c +++ b/xps/xps_image.c @@ -47,7 +47,7 @@ xps_paint_image_brush(xps_context *ctx, fz_matrix ctm, fz_rect area, char *base_ fz_matrix im = fz_scale(xs, -ys); im.f = ys; ctm = fz_concat(im, ctm); - ctx->dev->fillimage(ctx->dev->user, pixmap, ctm, ctx->opacity[ctx->opacity_top]); + ctx->dev->fill_image(ctx->dev->user, pixmap, ctm, ctx->opacity[ctx->opacity_top]); } static xps_part * @@ -123,6 +123,6 @@ xps_parse_image_brush(xps_context *ctx, fz_matrix ctm, fz_rect area, xps_parse_tiling_brush(ctx, ctm, area, base_uri, dict, root, xps_paint_image_brush, image); - fz_droppixmap(image); + fz_drop_pixmap(image); xps_free_part(ctx, part); } diff --git a/xps/xps_jpeg.c b/xps/xps_jpeg.c index c40df1ca..8cf00c20 100644 --- a/xps/xps_jpeg.c +++ b/xps/xps_jpeg.c @@ -63,7 +63,7 @@ xps_decode_jpeg(fz_pixmap **imagep, byte *rbuf, int rlen) if (setjmp(err.env)) { if (image) - fz_droppixmap(image); + fz_drop_pixmap(image); return fz_throw("jpeg error: %s", err.msg); } @@ -86,15 +86,15 @@ xps_decode_jpeg(fz_pixmap **imagep, byte *rbuf, int rlen) jpeg_start_decompress(&cinfo); if (cinfo.output_components == 1) - colorspace = fz_devicegray; + colorspace = fz_device_gray; else if (cinfo.output_components == 3) - colorspace = fz_devicergb; + colorspace = fz_device_rgb; else if (cinfo.output_components == 4) - colorspace = fz_devicecmyk; + colorspace = fz_device_cmyk; else return fz_throw("bad number of components in jpeg: %d", cinfo.output_components); - image = fz_newpixmap(colorspace, 0, 0, cinfo.output_width, cinfo.output_height); + image = fz_new_pixmap(colorspace, 0, 0, cinfo.output_width, cinfo.output_height); if (cinfo.density_unit == 1) { @@ -107,7 +107,7 @@ xps_decode_jpeg(fz_pixmap **imagep, byte *rbuf, int rlen) image->yres = cinfo.Y_density * 254 / 100; } - fz_clearpixmap(image); + fz_clear_pixmap(image); row[0] = fz_malloc(cinfo.output_components * cinfo.output_width); dp = image->samples; diff --git a/xps/xps_path.c b/xps/xps_path.c index 83059ea1..d89cd068 100644 --- a/xps/xps_path.c +++ b/xps/xps_path.c @@ -12,22 +12,22 @@ fz_currentpoint(fz_path *path) while (i < path->len) { - switch (path->els[i++].k) + switch (path->items[i++].k) { case FZ_MOVETO: - m.x = c.x = path->els[i++].v; - m.y = c.y = path->els[i++].v; + m.x = c.x = path->items[i++].v; + m.y = c.y = path->items[i++].v; break; case FZ_LINETO: - c.x = path->els[i++].v; - c.y = path->els[i++].v; + c.x = path->items[i++].v; + c.y = path->items[i++].v; break; case FZ_CURVETO: i += 4; - c.x = path->els[i++].v; - c.y = path->els[i++].v; + c.x = path->items[i++].v; + c.y = path->items[i++].v; break; - case FZ_CLOSEPATH: + case FZ_CLOSE_PATH: c = m; } } @@ -55,18 +55,18 @@ xps_draw_arc_segment(fz_path *path, fz_matrix mtx, float th0, float th1, int isc { p.x = cosf(th0); p.y = sinf(th0); - p = fz_transformpoint(mtx, p); + p = fz_transform_point(mtx, p); fz_lineto(path, p.x, p.y); for (t = th0; t < th1; t += d) { p.x = cosf(t); p.y = sinf(t); - p = fz_transformpoint(mtx, p); + p = fz_transform_point(mtx, p); fz_lineto(path, p.x, p.y); } p.x = cosf(th1); p.y = sinf(th1); - p = fz_transformpoint(mtx, p); + p = fz_transform_point(mtx, p); fz_lineto(path, p.x, p.y); } else @@ -74,18 +74,18 @@ xps_draw_arc_segment(fz_path *path, fz_matrix mtx, float th0, float th1, int isc th0 += (float)M_PI * 2; p.x = cosf(th0); p.y = sinf(th0); - p = fz_transformpoint(mtx, p); + p = fz_transform_point(mtx, p); fz_lineto(path, p.x, p.y); for (t = th0; t > th1; t -= d) { p.x = cosf(t); p.y = sinf(t); - p = fz_transformpoint(mtx, p); + p = fz_transform_point(mtx, p); fz_lineto(path, p.x, p.y); } p.x = cosf(th1); p.y = sinf(th1); - p = fz_transformpoint(mtx, p); + p = fz_transform_point(mtx, p); fz_lineto(path, p.x, p.y); } } @@ -154,7 +154,7 @@ xps_draw_arc(fz_path *path, /* F.6.5.1 */ pt.x = (x1 - x2) / 2; pt.y = (y1 - y2) / 2; - pt = fz_transformvector(revmat, pt); + pt = fz_transform_vector(revmat, pt); x1t = pt.x; y1t = pt.y; @@ -180,7 +180,7 @@ xps_draw_arc(fz_path *path, /* F.6.5.3 */ pt.x = cxt; pt.y = cyt; - pt = fz_transformvector(rotmat, pt); + pt = fz_transform_vector(rotmat, pt); cx = pt.x + (x1 + x2) / 2; cy = pt.y + (y1 + y2) / 2; @@ -232,7 +232,7 @@ xps_parse_abbreviated_geometry(xps_context *ctx, char *geom, int *fill_rule) float smooth_x, smooth_y; /* saved cubic bezier control point for smooth curves */ int reset_smooth; - path = fz_newpath(); + path = fz_new_path(); args = fz_calloc(strlen(geom) + 1, sizeof(char*)); pargs = args; @@ -716,7 +716,7 @@ xps_parse_path_geometry(xps_context *ctx, xps_resource *dict, xml_element *root, if (figures_att) path = xps_parse_abbreviated_geometry(ctx, figures_att, fill_rule); else - path = fz_newpath(); + path = fz_new_path(); if (figures_tag) xps_parse_path_figure(path, figures_tag, stroking); @@ -728,7 +728,7 @@ xps_parse_path_geometry(xps_context *ctx, xps_resource *dict, xml_element *root, } if (transform_att || transform_tag) - fz_transformpath(path, transform); + fz_transform_path(path, transform); return path; } @@ -757,9 +757,9 @@ xps_clip(xps_context *ctx, fz_matrix ctm, xps_resource *dict, char *clip_att, xm else if (clip_tag) path = xps_parse_path_geometry(ctx, dict, clip_tag, 0, &fill_rule); else - path = fz_newpath(); - ctx->dev->clippath(ctx->dev->user, path, fill_rule == 0, ctm); - fz_freepath(path); + path = fz_new_path(); + ctx->dev->clip_path(ctx->dev->user, path, fill_rule == 0, ctm); + fz_free_path(path); } /* @@ -803,7 +803,7 @@ xps_parse_path(xps_context *ctx, fz_matrix ctm, char *base_uri, xps_resource *di char *stroke_miter_limit_att; char *stroke_thickness_att; - fz_strokestate stroke; + fz_stroke_state stroke; fz_matrix transform; float samples[32]; fz_colorspace *colorspace; @@ -900,20 +900,20 @@ xps_parse_path(xps_context *ctx, fz_matrix ctm, char *base_uri, xps_resource *di if (stroke_thickness_att) stroke.linewidth = atof(stroke_thickness_att); - stroke.dashphase = 0; - stroke.dashlen = 0; + stroke.dash_phase = 0; + stroke.dash_len = 0; if (stroke_dash_array_att) { char *s = stroke_dash_array_att; if (stroke_dash_offset_att) - stroke.dashphase = atof(stroke_dash_offset_att) * stroke.linewidth; + stroke.dash_phase = atof(stroke_dash_offset_att) * stroke.linewidth; - while (*s && stroke.dashlen < nelem(stroke.dashlist)) + while (*s && stroke.dash_len < nelem(stroke.dash_list)) { while (*s == ' ') s++; - stroke.dashlist[stroke.dashlen++] = atof(s) * stroke.linewidth; + stroke.dash_list[stroke.dash_len++] = atof(s) * stroke.linewidth; while (*s && *s != ' ') s++; } @@ -936,9 +936,9 @@ xps_parse_path(xps_context *ctx, fz_matrix ctm, char *base_uri, xps_resource *di path = xps_parse_path_geometry(ctx, dict, data_tag, 0, &fill_rule); if (stroke_att || stroke_tag) - area = fz_boundpath(path, &stroke, ctm); + area = fz_bound_path(path, &stroke, ctm); else - area = fz_boundpath(path, NULL, ctm); + area = fz_bound_path(path, NULL, ctm); xps_begin_opacity(ctx, ctm, area, opacity_mask_uri, dict, opacity_att, opacity_mask_tag); @@ -949,17 +949,17 @@ xps_parse_path(xps_context *ctx, fz_matrix ctm, char *base_uri, xps_resource *di samples[0] = atof(fill_opacity_att); xps_set_color(ctx, colorspace, samples); - ctx->dev->fillpath(ctx->dev->user, path, fill_rule == 0, ctm, + ctx->dev->fill_path(ctx->dev->user, path, fill_rule == 0, ctm, ctx->colorspace, ctx->color, ctx->alpha); } if (fill_tag) { - area = fz_boundpath(path, NULL, ctm); + area = fz_bound_path(path, NULL, ctm); - ctx->dev->clippath(ctx->dev->user, path, fill_rule == 0, ctm); + ctx->dev->clip_path(ctx->dev->user, path, fill_rule == 0, ctm); xps_parse_brush(ctx, ctm, area, fill_uri, dict, fill_tag); - ctx->dev->popclip(ctx->dev->user); + ctx->dev->pop_clip(ctx->dev->user); } if (stroke_att) @@ -969,22 +969,22 @@ xps_parse_path(xps_context *ctx, fz_matrix ctm, char *base_uri, xps_resource *di samples[0] = atof(stroke_opacity_att); xps_set_color(ctx, colorspace, samples); - ctx->dev->strokepath(ctx->dev->user, path, &stroke, ctm, + ctx->dev->stroke_path(ctx->dev->user, path, &stroke, ctm, ctx->colorspace, ctx->color, ctx->alpha); } if (stroke_tag) { - ctx->dev->clipstrokepath(ctx->dev->user, path, &stroke, ctm); + ctx->dev->clip_stroke_path(ctx->dev->user, path, &stroke, ctm); xps_parse_brush(ctx, ctm, area, stroke_uri, dict, stroke_tag); - ctx->dev->popclip(ctx->dev->user); + ctx->dev->pop_clip(ctx->dev->user); } xps_end_opacity(ctx, opacity_mask_uri, dict, opacity_att, opacity_mask_tag); - fz_freepath(path); + fz_free_path(path); path = NULL; if (clip_att || clip_tag) - ctx->dev->popclip(ctx->dev->user); + ctx->dev->pop_clip(ctx->dev->user); } diff --git a/xps/xps_png.c b/xps/xps_png.c index 829bde90..38c9d473 100644 --- a/xps/xps_png.c +++ b/xps/xps_png.c @@ -484,7 +484,7 @@ png_read_image(struct info *info, unsigned char *p, int total) static fz_pixmap * png_expand_palette(struct info *info, fz_pixmap *src) { - fz_pixmap *dst = fz_newpixmap(fz_devicergb, 0, 0, src->w, src->h); + fz_pixmap *dst = fz_new_pixmap(fz_device_rgb, 0, 0, src->w, src->h); unsigned char *sp = src->samples; unsigned char *dp = dst->samples; int x, y; @@ -505,7 +505,7 @@ png_expand_palette(struct info *info, fz_pixmap *src) } } - fz_droppixmap(src); + fz_drop_pixmap(src); return dst; } @@ -547,17 +547,17 @@ xps_decode_png(fz_pixmap **imagep, byte *p, int total) return fz_rethrow(code, "cannot read png image"); if (png.n == 3 || png.n == 4) - colorspace = fz_devicergb; + colorspace = fz_device_rgb; else - colorspace = fz_devicegray; + colorspace = fz_device_gray; stride = (png.width * png.n * png.depth + 7) / 8; - image = fz_newpixmap(colorspace, 0, 0, png.width, png.height); + image = fz_new_pixmap(colorspace, 0, 0, png.width, png.height); image->xres = png.xres; image->yres = png.yres; - fz_unpacktile(image, png.samples, png.n, png.depth, stride, png.indexed); + fz_unpack_tile(image, png.samples, png.n, png.depth, stride, png.indexed); if (png.indexed) image = png_expand_palette(&png, image); @@ -565,7 +565,7 @@ xps_decode_png(fz_pixmap **imagep, byte *p, int total) png_mask_transparency(&png, image); if (png.transparency || png.n == 2 || png.n == 4) - fz_premultiplypixmap(image); + fz_premultiply_pixmap(image); fz_free(png.samples); diff --git a/xps/xps_tiff.c b/xps/xps_tiff.c index 384c4338..3d905130 100644 --- a/xps/xps_tiff.c +++ b/xps/xps_tiff.c @@ -146,7 +146,7 @@ xps_decode_tiff_uncompressed(struct tiff *tiff, fz_stream *stm, byte *wp, int wl static int xps_decode_tiff_packbits(struct tiff *tiff, fz_stream *chain, byte *wp, int wlen) { - fz_stream *stm = fz_openrld(chain); + fz_stream *stm = fz_open_rld(chain); int n = fz_read(stm, wp, wlen); fz_close(stm); if (n < 0) @@ -157,7 +157,7 @@ xps_decode_tiff_packbits(struct tiff *tiff, fz_stream *chain, byte *wp, int wlen static int xps_decode_tiff_lzw(struct tiff *tiff, fz_stream *chain, byte *wp, int wlen) { - fz_stream *stm = fz_openlzwd(chain, NULL); + fz_stream *stm = fz_open_lzwd(chain, NULL); int n = fz_read(stm, wp, wlen); fz_close(stm); if (n < 0) @@ -167,7 +167,7 @@ xps_decode_tiff_lzw(struct tiff *tiff, fz_stream *chain, byte *wp, int wlen) static int xps_decode_tiff_flate(struct tiff *tiff, fz_stream *chain, byte *wp, int wlen) { - fz_stream *stm = fz_openflated(chain); + fz_stream *stm = fz_open_flated(chain); int n = fz_read(stm, wp, wlen); fz_close(stm); if (n < 0) @@ -180,32 +180,32 @@ xps_decode_tiff_fax(struct tiff *tiff, int comp, fz_stream *chain, byte *wp, int { fz_stream *stm; fz_obj *params; - fz_obj *columns, *rows, *blackis1, *k, *encodedbytealign; + fz_obj *columns, *rows, *black_is_1, *k, *encoded_byte_align; int n; - columns = fz_newint(tiff->imagewidth); - rows = fz_newint(tiff->imagelength); - blackis1 = fz_newbool(tiff->photometric == 0); - k = fz_newint(comp == 4 ? -1 : 0); - encodedbytealign = fz_newbool(comp == 2); - - params = fz_newdict(5); - fz_dictputs(params, "Columns", columns); - fz_dictputs(params, "Rows", rows); - fz_dictputs(params, "BlackIs1", blackis1); - fz_dictputs(params, "K", k); - fz_dictputs(params, "EncodedByteAlign", encodedbytealign); - - fz_dropobj(columns); - fz_dropobj(rows); - fz_dropobj(blackis1); - fz_dropobj(k); - fz_dropobj(encodedbytealign); - - stm = fz_openfaxd(chain, params); + columns = fz_new_int(tiff->imagewidth); + rows = fz_new_int(tiff->imagelength); + black_is_1 = fz_new_bool(tiff->photometric == 0); + k = fz_new_int(comp == 4 ? -1 : 0); + encoded_byte_align = fz_new_bool(comp == 2); + + params = fz_new_dict(5); + fz_dict_puts(params, "Columns", columns); + fz_dict_puts(params, "Rows", rows); + fz_dict_puts(params, "BlackIs1", black_is_1); + fz_dict_puts(params, "K", k); + fz_dict_puts(params, "EncodedByteAlign", encoded_byte_align); + + fz_drop_obj(columns); + fz_drop_obj(rows); + fz_drop_obj(black_is_1); + fz_drop_obj(k); + fz_drop_obj(encoded_byte_align); + + stm = fz_open_faxd(chain, params); n = fz_read(stm, wp, wlen); fz_close(stm); - fz_dropobj(params); + fz_drop_obj(params); if (n < 0) return fz_rethrow(n, "cannot read fax strip"); @@ -215,7 +215,7 @@ xps_decode_tiff_fax(struct tiff *tiff, int comp, fz_stream *chain, byte *wp, int static int xps_decode_tiff_jpeg(struct tiff *tiff, fz_stream *chain, byte *wp, int wlen) { - fz_stream *stm = fz_opendctd(chain, NULL); + fz_stream *stm = fz_open_dctd(chain, NULL); int n = fz_read(stm, wp, wlen); fz_close(stm); if (n < 0) @@ -386,23 +386,23 @@ xps_decode_tiff_strips(struct tiff *tiff) switch (tiff->photometric) { case 0: /* WhiteIsZero -- inverted */ - tiff->colorspace = fz_devicegray; + tiff->colorspace = fz_device_gray; break; case 1: /* BlackIsZero */ - tiff->colorspace = fz_devicegray; + tiff->colorspace = fz_device_gray; break; case 2: /* RGB */ - tiff->colorspace = fz_devicergb; + tiff->colorspace = fz_device_rgb; break; case 3: /* RGBPal */ - tiff->colorspace = fz_devicergb; + tiff->colorspace = fz_device_rgb; break; case 5: /* CMYK */ - tiff->colorspace = fz_devicecmyk; + tiff->colorspace = fz_device_cmyk; break; case 6: /* YCbCr */ /* it's probably a jpeg ... we let jpeg convert to rgb */ - tiff->colorspace = fz_devicergb; + tiff->colorspace = fz_device_rgb; break; default: return fz_throw("unknown photometric: %d", tiff->photometric); @@ -454,7 +454,7 @@ xps_decode_tiff_strips(struct tiff *tiff) rp[i] = bitrev[rp[i]]; /* the strip decoders will close this */ - stm = fz_openmemory(rp, rlen); + stm = fz_open_memory(rp, rlen); switch (tiff->compression) { @@ -824,11 +824,11 @@ xps_decode_tiff(fz_pixmap **imagep, byte *buf, int len) /* Expand into fz_pixmap struct */ - image = fz_newpixmap(tiff.colorspace, 0, 0, tiff.imagewidth, tiff.imagelength); + image = fz_new_pixmap(tiff.colorspace, 0, 0, tiff.imagewidth, tiff.imagelength); image->xres = tiff.xresolution; image->yres = tiff.yresolution; - fz_unpacktile(image, tiff.samples, tiff.samplesperpixel, tiff.bitspersample, tiff.stride, 0); + fz_unpack_tile(image, tiff.samples, tiff.samplesperpixel, tiff.bitspersample, tiff.stride, 0); /* We should only do this on non-pre-multiplied images, but files in the wild are bad */ if (tiff.extrasamples /* == 2 */) @@ -836,14 +836,14 @@ xps_decode_tiff(fz_pixmap **imagep, byte *buf, int len) /* CMYK is a subtractive colorspace, we want additive for premul alpha */ if (image->n == 5) { - fz_pixmap *rgb = fz_newpixmap(fz_devicergb, 0, 0, image->w, image->h); - fz_convertpixmap(image, rgb); + fz_pixmap *rgb = fz_new_pixmap(fz_device_rgb, 0, 0, image->w, image->h); + fz_convert_pixmap(image, rgb); rgb->xres = image->xres; rgb->yres = image->yres; - fz_droppixmap(image); + fz_drop_pixmap(image); image = rgb; } - fz_premultiplypixmap(image); + fz_premultiply_pixmap(image); } /* Clean up scratch memory */ diff --git a/xps/xps_tile.c b/xps/xps_tile.c index 22444ef2..eb972fad 100644 --- a/xps/xps_tile.c +++ b/xps/xps_tile.c @@ -22,16 +22,16 @@ struct closure static void xps_paint_tiling_brush_clipped(xps_context *ctx, fz_matrix ctm, fz_rect viewbox, struct closure *c) { - fz_path *path = fz_newpath(); + fz_path *path = fz_new_path(); fz_moveto(path, viewbox.x0, viewbox.y0); fz_lineto(path, viewbox.x0, viewbox.y1); fz_lineto(path, viewbox.x1, viewbox.y1); fz_lineto(path, viewbox.x1, viewbox.y0); fz_closepath(path); - ctx->dev->clippath(ctx->dev->user, path, 0, ctm); - fz_freepath(path); + ctx->dev->clip_path(ctx->dev->user, path, 0, ctm); + fz_free_path(path); c->func(ctx, ctm, viewbox, c->base_uri, c->dict, c->root, c->user); - ctx->dev->popclip(ctx->dev->user); + ctx->dev->pop_clip(ctx->dev->user); } static void @@ -119,11 +119,11 @@ xps_parse_tiling_brush(xps_context *ctx, fz_matrix ctm, fz_rect area, xps_parse_matrix_transform(ctx, transform_tag, &transform); ctm = fz_concat(transform, ctm); - viewbox = fz_unitrect; + viewbox = fz_unit_rect; if (viewbox_att) xps_parse_rectangle(ctx, viewbox_att, &viewbox); - viewport = fz_unitrect; + viewport = fz_unit_rect; if (viewport_att) xps_parse_rectangle(ctx, viewport_att, &viewport); @@ -168,8 +168,8 @@ xps_parse_tiling_brush(xps_context *ctx, fz_matrix ctm, fz_rect area, if (tile_mode != TILE_NONE) { int x0, y0, x1, y1; - fz_matrix invctm = fz_invertmatrix(ctm); - area = fz_transformrect(invctm, area); + fz_matrix invctm = fz_invert_matrix(ctm); + area = fz_transform_rect(invctm, area); x0 = floorf(area.x0 / xstep); y0 = floorf(area.y0 / ystep); x1 = ceilf(area.x1 / xstep); @@ -182,11 +182,11 @@ xps_parse_tiling_brush(xps_context *ctx, fz_matrix ctm, fz_rect area, bigview.x1 = bigview.x0 + xstep; bigview.y1 = bigview.y0 + ystep; if (n > 1) - ctx->dev->begintile(ctx->dev->user, area, bigview, xstep, ystep, ctm); + ctx->dev->begin_tile(ctx->dev->user, area, bigview, xstep, ystep, ctm); if (n > 0) xps_paint_tiling_brush(ctx, ctm, viewbox, tile_mode, &c); if (n > 1) - ctx->dev->endtile(ctx->dev->user); + ctx->dev->end_tile(ctx->dev->user); } #else { @@ -316,7 +316,7 @@ xps_parse_canvas(xps_context *ctx, fz_matrix ctm, fz_rect area, char *base_uri, xps_end_opacity(ctx, opacity_mask_uri, dict, opacity_att, opacity_mask_tag); if (clip_att || clip_tag) - ctx->dev->popclip(ctx->dev->user); + ctx->dev->pop_clip(ctx->dev->user); if (new_dict) xps_free_resource_dictionary(ctx, new_dict); @@ -345,7 +345,7 @@ xps_parse_fixed_page(xps_context *ctx, fz_matrix ctm, xps_page *page) if (!page->root) return; - area = fz_transformrect(fz_scale(page->width, page->height), fz_unitrect); + area = fz_transform_rect(fz_scale(page->width, page->height), fz_unit_rect); for (node = xml_down(page->root); node; node = xml_next(node)) { diff --git a/xps/xps_zip.c b/xps/xps_zip.c index abb78832..e1019ae0 100644 --- a/xps/xps_zip.c +++ b/xps/xps_zip.c @@ -221,19 +221,19 @@ xps_read_zip_dir(xps_context *ctx, int start_offset) static int xps_find_and_read_zip_dir(xps_context *ctx) { - int filesize, back, maxback; + int file_size, back, maxback; int i, n; char buf[512]; fseek(ctx->file, 0, SEEK_END); - filesize = ftell(ctx->file); + file_size = ftell(ctx->file); - maxback = MIN(filesize, 0xFFFF + sizeof buf); + maxback = MIN(file_size, 0xFFFF + sizeof buf); back = MIN(maxback, sizeof buf); while (back < maxback) { - fseek(ctx->file, filesize - back, 0); + fseek(ctx->file, file_size - back, 0); n = fread(buf, 1, sizeof buf, ctx->file); if (n < 0) @@ -241,7 +241,7 @@ xps_find_and_read_zip_dir(xps_context *ctx) for (i = n - 4; i > 0; i--) if (!memcmp(buf + i, "PK\5\6", 4)) - return xps_read_zip_dir(ctx, filesize - back + i); + return xps_read_zip_dir(ctx, file_size - back + i); back += sizeof buf - 4; } @@ -448,12 +448,12 @@ static void xps_free_key_func(void *ptr) static void xps_free_font_func(void *ptr) { - fz_dropfont(ptr); + fz_drop_font(ptr); } static void xps_free_colorspace_func(void *ptr) { - fz_dropcolorspace(ptr); + fz_drop_colorspace(ptr); } int -- cgit v1.2.3