diff options
-rw-r--r-- | pdf/mupdf.h | 42 | ||||
-rw-r--r-- | pdf/pdf_cmap.c | 6 | ||||
-rw-r--r-- | pdf/pdf_cmap_load.c | 16 | ||||
-rw-r--r-- | pdf/pdf_cmap_parse.c | 83 | ||||
-rw-r--r-- | pdf/pdf_cmap_table.c | 2 | ||||
-rw-r--r-- | pdf/pdf_font.c | 32 | ||||
-rw-r--r-- | pdf/pdf_image.c | 2 | ||||
-rw-r--r-- | pdf/pdf_interpret.c | 6 | ||||
-rw-r--r-- | pdf/pdf_metrics.c | 16 | ||||
-rw-r--r-- | pdf/pdf_stream.c | 4 | ||||
-rw-r--r-- | pdf/pdf_type3.c | 8 | ||||
-rw-r--r-- | pdf/pdf_unicode.c | 4 | ||||
-rw-r--r-- | pdf/pdf_xref.c | 2 | ||||
-rw-r--r-- | scripts/cmapdump.c | 2 |
14 files changed, 112 insertions, 113 deletions
diff --git a/pdf/mupdf.h b/pdf/mupdf.h index 95f44c60..39245177 100644 --- a/pdf/mupdf.h +++ b/pdf/mupdf.h @@ -30,7 +30,7 @@ int pdf_lex(fz_stream *f, char *buf, int n, int *len); fz_obj *pdf_parse_array(pdf_document *doc, fz_stream *f, char *buf, int cap); fz_obj *pdf_parse_dict(pdf_document *doc, fz_stream *f, char *buf, int cap); fz_obj *pdf_parse_stm_obj(pdf_document *doc, fz_stream *f, char *buf, int cap); -fz_obj * pdf_parse_ind_obj(pdf_document *doc, fz_stream *f, char *buf, int cap, int *num, int *gen, int *stm_ofs); +fz_obj *pdf_parse_ind_obj(pdf_document *doc, fz_stream *f, char *buf, int cap, int *num, int *gen, int *stm_ofs); fz_rect pdf_to_rect(fz_context *ctx, fz_obj *array); fz_matrix pdf_to_matrix(fz_context *ctx, fz_obj *array); @@ -99,15 +99,15 @@ struct pdf_document_s fz_obj *pdf_resolve_indirect(fz_obj *ref); void pdf_cache_object(pdf_document *doc, int num, int gen); fz_obj *pdf_load_object(pdf_document *doc, int num, int gen); -void pdf_update_object( pdf_document *doc, int num, int gen, fz_obj *newobj); +void pdf_update_object(pdf_document *doc, int num, int gen, fz_obj *newobj); int pdf_is_stream(pdf_document *doc, int num, int gen); -fz_stream *pdf_open_inline_stream(fz_stream *chain, pdf_document *doc, fz_obj *stmobj, int length); +fz_stream *pdf_open_inline_stream(pdf_document *doc, fz_obj *stmobj, int length, fz_stream *chain); fz_buffer *pdf_load_raw_stream(pdf_document *doc, int num, int gen); fz_buffer *pdf_load_stream(pdf_document *doc, int num, int gen); fz_stream *pdf_open_raw_stream(pdf_document *doc, int num, int gen); fz_stream *pdf_open_stream(pdf_document *doc, int num, int gen); -fz_stream *pdf_open_stream_at(pdf_document *doc, int num, int gen, fz_obj *dict, int stm_ofs); +fz_stream *pdf_open_stream_with_offset(pdf_document *doc, int num, int gen, fz_obj *dict, int stm_ofs); pdf_document *pdf_open_document_with_stream(fz_stream *file); pdf_document *pdf_open_document(fz_context *ctx, const char *filename); @@ -269,11 +269,11 @@ pdf_cmap *pdf_new_cmap(fz_context *ctx); pdf_cmap *pdf_keep_cmap(fz_context *ctx, pdf_cmap *cmap); void pdf_drop_cmap(fz_context *ctx, pdf_cmap *cmap); void pdf_free_cmap_imp(fz_context *ctx, fz_storable *cmap); -unsigned int pdf_cmap_size(pdf_cmap *cmap); +unsigned int pdf_cmap_size(fz_context *ctx, pdf_cmap *cmap); -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_debug_cmap(fz_context *ctx, pdf_cmap *cmap); +int pdf_get_wmode(fz_context *ctx, pdf_cmap *cmap); +void pdf_set_wmode(fz_context *ctx, pdf_cmap *cmap, int wmode); void pdf_set_usecmap(fz_context *ctx, pdf_cmap *cmap, pdf_cmap *usecmap); void pdf_add_codespace(fz_context *ctx, pdf_cmap *cmap, int low, int high, int n); @@ -287,10 +287,10 @@ int pdf_lookup_cmap_full(pdf_cmap *cmap, int cpt, int *out); int pdf_decode_cmap(pdf_cmap *cmap, unsigned char *s, int *cpt); pdf_cmap *pdf_new_identity_cmap(fz_context *ctx, int wmode, int bytes); -pdf_cmap *pdf_parse_cmap(fz_stream *file); -pdf_cmap *pdf_load_embedded_cmap(pdf_document *doc, fz_obj *ref); +pdf_cmap *pdf_load_cmap(fz_context *ctx, fz_stream *file); pdf_cmap *pdf_load_system_cmap(fz_context *ctx, char *name); -pdf_cmap *pdf_find_builtin_cmap(char *cmap_name); +pdf_cmap *pdf_load_builtin_cmap(fz_context *ctx, char *name); +pdf_cmap *pdf_load_embedded_cmap(pdf_document *doc, fz_obj *ref); /* * Font @@ -382,19 +382,19 @@ struct pdf_font_desc_s int is_embedded; }; -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_set_font_wmode(fz_context *ctx, pdf_font_desc *font, int wmode); +void pdf_set_default_hmtx(fz_context *ctx, pdf_font_desc *font, int w); +void pdf_set_default_vmtx(fz_context *ctx, pdf_font_desc *font, int y, int w); void pdf_add_hmtx(fz_context *ctx, pdf_font_desc *font, int lo, int hi, int w); void pdf_add_vmtx(fz_context *ctx, 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); +void pdf_end_hmtx(fz_context *ctx, pdf_font_desc *font); +void pdf_end_vmtx(fz_context *ctx, pdf_font_desc *font); +pdf_hmtx pdf_get_hmtx(fz_context *ctx, pdf_font_desc *font, int cid); +pdf_vmtx pdf_get_vmtx(fz_context *ctx, pdf_font_desc *font, int cid); -void pdf_load_to_unicode(pdf_font_desc *font, pdf_document *doc, char **strings, char *collection, fz_obj *cmapstm); +void pdf_load_to_unicode(pdf_document *doc, pdf_font_desc *font, char **strings, char *collection, fz_obj *cmapstm); -int pdf_font_cid_to_gid(pdf_font_desc *fontdesc, int cid); +int pdf_font_cid_to_gid(fz_context *ctx, pdf_font_desc *fontdesc, int cid); unsigned char *pdf_find_builtin_font(char *name, unsigned int *len); unsigned char *pdf_find_substitute_font(int mono, int serif, int bold, int italic, unsigned int *len); @@ -407,7 +407,7 @@ pdf_font_desc *pdf_new_font_desc(fz_context *ctx); pdf_font_desc *pdf_keep_font(fz_context *ctx, pdf_font_desc *fontdesc); void pdf_drop_font(fz_context *ctx, pdf_font_desc *font); -void pdf_debug_font(pdf_font_desc *fontdesc); +void pdf_debug_font(fz_context *ctx, pdf_font_desc *fontdesc); /* * Interactive features diff --git a/pdf/pdf_cmap.c b/pdf/pdf_cmap.c index c42317bb..987da592 100644 --- a/pdf/pdf_cmap.c +++ b/pdf/pdf_cmap.c @@ -98,19 +98,19 @@ pdf_set_usecmap(fz_context *ctx, pdf_cmap *cmap, pdf_cmap *usecmap) } int -pdf_get_wmode(pdf_cmap *cmap) +pdf_get_wmode(fz_context *ctx, pdf_cmap *cmap) { return cmap->wmode; } void -pdf_set_wmode(pdf_cmap *cmap, int wmode) +pdf_set_wmode(fz_context *ctx, pdf_cmap *cmap, int wmode) { cmap->wmode = wmode; } void -pdf_debug_cmap(pdf_cmap *cmap) +pdf_debug_cmap(fz_context *ctx, pdf_cmap *cmap) { int i, k, n; diff --git a/pdf/pdf_cmap_load.c b/pdf/pdf_cmap_load.c index 0d56bd03..fcf30ad0 100644 --- a/pdf/pdf_cmap_load.c +++ b/pdf/pdf_cmap_load.c @@ -2,14 +2,14 @@ #include "mupdf.h" unsigned int -pdf_cmap_size(pdf_cmap *cmap) +pdf_cmap_size(fz_context *ctx, pdf_cmap *cmap) { if (cmap == NULL) return 0; if (cmap->storable.refs < 0) return 0; - return cmap->rcap * sizeof(pdf_range) + cmap->tcap * sizeof(short) + pdf_cmap_size(cmap->usecmap); + return cmap->rcap * sizeof(pdf_range) + cmap->tcap * sizeof(short) + pdf_cmap_size(ctx, cmap->usecmap); } /* @@ -41,14 +41,14 @@ pdf_load_embedded_cmap(pdf_document *xref, fz_obj *stmobj) file = pdf_open_stream(xref, fz_to_num(stmobj), fz_to_gen(stmobj)); phase = 1; - cmap = pdf_parse_cmap(file); + cmap = pdf_load_cmap(ctx, file); phase = 2; fz_close(file); file = NULL; wmode = fz_dict_gets(stmobj, "WMode"); if (fz_is_int(wmode)) - pdf_set_wmode(cmap, fz_to_int(wmode)); + pdf_set_wmode(ctx, cmap, fz_to_int(wmode)); obj = fz_dict_gets(stmobj, "UseCMap"); if (fz_is_name(obj)) { @@ -64,7 +64,7 @@ pdf_load_embedded_cmap(pdf_document *xref, fz_obj *stmobj) pdf_drop_cmap(ctx, usecmap); } - fz_store_item(ctx, stmobj, cmap, pdf_cmap_size(cmap)); + fz_store_item(ctx, stmobj, cmap, pdf_cmap_size(ctx, cmap)); } fz_catch(ctx) { @@ -98,7 +98,7 @@ pdf_new_identity_cmap(fz_context *ctx, int wmode, int bytes) pdf_add_codespace(ctx, cmap, 0x0000, 0xffff, bytes); pdf_map_range_to_range(ctx, cmap, 0x0000, 0xffff, 0); pdf_sort_cmap(ctx, cmap); - pdf_set_wmode(cmap, wmode); + pdf_set_wmode(ctx, cmap, wmode); } fz_catch(ctx) { @@ -117,13 +117,13 @@ pdf_load_system_cmap(fz_context *ctx, char *cmap_name) pdf_cmap *usecmap; pdf_cmap *cmap; - cmap = pdf_find_builtin_cmap(cmap_name); + cmap = pdf_load_builtin_cmap(ctx, cmap_name); if (!cmap) fz_throw(ctx, "no builtin cmap file: %s", cmap_name); if (cmap->usecmap_name[0] && !cmap->usecmap) { - usecmap = pdf_find_builtin_cmap(cmap->usecmap_name); + usecmap = pdf_load_builtin_cmap(ctx, cmap->usecmap_name); if (!usecmap) fz_throw(ctx, "nu builtin cmap file: %s", cmap->usecmap_name); pdf_set_usecmap(ctx, cmap, usecmap); diff --git a/pdf/pdf_cmap_parse.c b/pdf/pdf_cmap_parse.c index a0967560..fb37c4a9 100644 --- a/pdf/pdf_cmap_parse.c +++ b/pdf/pdf_cmap_parse.c @@ -62,7 +62,7 @@ pdf_lex_cmap(fz_stream *file, char *buf, int n, int *sl) } static void -pdf_parse_cmap_name(pdf_cmap *cmap, fz_stream *file) +pdf_parse_cmap_name(fz_context *ctx, pdf_cmap *cmap, fz_stream *file) { char buf[256]; int tok; @@ -74,11 +74,11 @@ pdf_parse_cmap_name(pdf_cmap *cmap, fz_stream *file) if (tok == PDF_TOK_NAME) fz_strlcpy(cmap->cmap_name, buf, sizeof(cmap->cmap_name)); else - fz_warn(file->ctx, "expected name after CMapName in cmap"); + fz_warn(ctx, "expected name after CMapName in cmap"); } static void -pdf_parse_wmode(pdf_cmap *cmap, fz_stream *file) +pdf_parse_wmode(fz_context *ctx, pdf_cmap *cmap, fz_stream *file) { char buf[256]; int tok; @@ -88,13 +88,13 @@ pdf_parse_wmode(pdf_cmap *cmap, fz_stream *file) /* RJW: Lost debugging: "syntaxerror in cmap" */ if (tok == PDF_TOK_INT) - pdf_set_wmode(cmap, atoi(buf)); + pdf_set_wmode(ctx, cmap, atoi(buf)); else - fz_warn(file->ctx, "expected integer after WMode in cmap"); + fz_warn(ctx, "expected integer after WMode in cmap"); } static void -pdf_parse_codespace_range(pdf_cmap *cmap, fz_stream *file) +pdf_parse_codespace_range(fz_context *ctx, pdf_cmap *cmap, fz_stream *file) { char buf[256]; int tok; @@ -117,7 +117,7 @@ pdf_parse_codespace_range(pdf_cmap *cmap, fz_stream *file) if (tok == PDF_TOK_STRING) { hi = pdf_code_from_string(buf, len); - pdf_add_codespace(file->ctx, cmap, lo, hi, len); + pdf_add_codespace(ctx, cmap, lo, hi, len); } else break; } @@ -125,11 +125,11 @@ pdf_parse_codespace_range(pdf_cmap *cmap, fz_stream *file) else break; } - fz_throw(file->ctx, "expected string or endcodespacerange"); + fz_throw(ctx, "expected string or endcodespacerange"); } static void -pdf_parse_cid_range(pdf_cmap *cmap, fz_stream *file) +pdf_parse_cid_range(fz_context *ctx, pdf_cmap *cmap, fz_stream *file) { char buf[256]; int tok; @@ -145,30 +145,30 @@ pdf_parse_cid_range(pdf_cmap *cmap, fz_stream *file) return; else if (tok != PDF_TOK_STRING) - fz_throw(file->ctx, "expected string or endcidrange"); + fz_throw(ctx, "expected string or endcidrange"); lo = pdf_code_from_string(buf, len); tok = pdf_lex_cmap(file, buf, sizeof buf, &len); /* RJW: Lost debugging: "syntaxerror in cmap" */ if (tok != PDF_TOK_STRING) - fz_throw(file->ctx, "expected string"); + fz_throw(ctx, "expected string"); hi = pdf_code_from_string(buf, len); tok = pdf_lex_cmap(file, buf, sizeof buf, &len); /* RJW: Lost debugging: "syntaxerror in cmap" */ if (tok != PDF_TOK_INT) - fz_throw(file->ctx, "expected integer"); + fz_throw(ctx, "expected integer"); dst = atoi(buf); - pdf_map_range_to_range(file->ctx, cmap, lo, hi, dst); + pdf_map_range_to_range(ctx, cmap, lo, hi, dst); } } static void -pdf_parse_cid_char(pdf_cmap *cmap, fz_stream *file) +pdf_parse_cid_char(fz_context *ctx, pdf_cmap *cmap, fz_stream *file) { char buf[256]; int tok; @@ -184,7 +184,7 @@ pdf_parse_cid_char(pdf_cmap *cmap, fz_stream *file) return; else if (tok != PDF_TOK_STRING) - fz_throw(file->ctx, "expected string or endcidchar"); + fz_throw(ctx, "expected string or endcidchar"); src = pdf_code_from_string(buf, len); @@ -192,16 +192,16 @@ pdf_parse_cid_char(pdf_cmap *cmap, fz_stream *file) /* RJW: "syntaxerror in cmap" */ if (tok != PDF_TOK_INT) - fz_throw(file->ctx, "expected integer"); + fz_throw(ctx, "expected integer"); dst = atoi(buf); - pdf_map_range_to_range(file->ctx, cmap, src, src, dst); + pdf_map_range_to_range(ctx, cmap, src, src, dst); } } static void -pdf_parse_bf_range_array(pdf_cmap *cmap, fz_stream *file, int lo, int hi) +pdf_parse_bf_range_array(fz_context *ctx, pdf_cmap *cmap, fz_stream *file, int lo, int hi) { char buf[256]; int tok; @@ -219,14 +219,14 @@ pdf_parse_bf_range_array(pdf_cmap *cmap, fz_stream *file, int lo, int hi) /* Note: does not handle [ /Name /Name ... ] */ else if (tok != PDF_TOK_STRING) - fz_throw(file->ctx, "expected string or ]"); + fz_throw(ctx, "expected string or ]"); if (len / 2) { for (i = 0; i < len / 2; i++) dst[i] = pdf_code_from_string(buf + i * 2, 2); - pdf_map_one_to_many(file->ctx, cmap, lo, dst, len / 2); + pdf_map_one_to_many(ctx, cmap, lo, dst, len / 2); } lo ++; @@ -234,7 +234,7 @@ pdf_parse_bf_range_array(pdf_cmap *cmap, fz_stream *file, int lo, int hi) } static void -pdf_parse_bf_range(pdf_cmap *cmap, fz_stream *file) +pdf_parse_bf_range(fz_context *ctx, pdf_cmap *cmap, fz_stream *file) { char buf[256]; int tok; @@ -250,14 +250,14 @@ pdf_parse_bf_range(pdf_cmap *cmap, fz_stream *file) return; else if (tok != PDF_TOK_STRING) - fz_throw(file->ctx, "expected string or endbfrange"); + fz_throw(ctx, "expected string or endbfrange"); lo = pdf_code_from_string(buf, len); tok = pdf_lex_cmap(file, buf, sizeof buf, &len); /* RJW: "syntaxerror in cmap" */ if (tok != PDF_TOK_STRING) - fz_throw(file->ctx, "expected string"); + fz_throw(ctx, "expected string"); hi = pdf_code_from_string(buf, len); @@ -269,7 +269,7 @@ pdf_parse_bf_range(pdf_cmap *cmap, fz_stream *file) if (len == 2) { dst = pdf_code_from_string(buf, len); - pdf_map_range_to_range(file->ctx, cmap, lo, hi, dst); + pdf_map_range_to_range(ctx, cmap, lo, hi, dst); } else { @@ -284,7 +284,7 @@ pdf_parse_bf_range(pdf_cmap *cmap, fz_stream *file) while (lo <= hi) { dststr[i-1] ++; - pdf_map_one_to_many(file->ctx, cmap, lo, dststr, i); + pdf_map_one_to_many(ctx, cmap, lo, dststr, i); lo ++; } } @@ -293,19 +293,19 @@ pdf_parse_bf_range(pdf_cmap *cmap, fz_stream *file) else if (tok == PDF_TOK_OPEN_ARRAY) { - pdf_parse_bf_range_array(cmap, file, lo, hi); + pdf_parse_bf_range_array(ctx, cmap, file, lo, hi); /* RJW: "cannot map bfrange" */ } else { - fz_throw(file->ctx, "expected string or array or endbfrange"); + fz_throw(ctx, "expected string or array or endbfrange"); } } } static void -pdf_parse_bf_char(pdf_cmap *cmap, fz_stream *file) +pdf_parse_bf_char(fz_context *ctx, pdf_cmap *cmap, fz_stream *file) { char buf[256]; int tok; @@ -323,7 +323,7 @@ pdf_parse_bf_char(pdf_cmap *cmap, fz_stream *file) return; else if (tok != PDF_TOK_STRING) - fz_throw(file->ctx, "expected string or endbfchar"); + fz_throw(ctx, "expected string or endbfchar"); src = pdf_code_from_string(buf, len); @@ -331,19 +331,19 @@ pdf_parse_bf_char(pdf_cmap *cmap, fz_stream *file) /* RJW: "syntaxerror in cmap" */ /* Note: does not handle /dstName */ if (tok != PDF_TOK_STRING) - fz_throw(file->ctx, "expected string"); + fz_throw(ctx, "expected string"); if (len / 2) { for (i = 0; i < len / 2; i++) dst[i] = pdf_code_from_string(buf + i * 2, 2); - pdf_map_one_to_many(file->ctx, cmap, src, dst, i); + pdf_map_one_to_many(ctx, cmap, src, dst, i); } } } pdf_cmap * -pdf_parse_cmap(fz_stream *file) +pdf_load_cmap(fz_context *ctx, fz_stream *file) { pdf_cmap *cmap; char key[64]; @@ -351,7 +351,6 @@ pdf_parse_cmap(fz_stream *file) int tok; int len; const char *where; - fz_context *ctx = file->ctx; cmap = pdf_new_cmap(ctx); @@ -374,12 +373,12 @@ pdf_parse_cmap(fz_stream *file) if (!strcmp(buf, "CMapName")) { where = " after CMapName"; - pdf_parse_cmap_name(cmap, file); + pdf_parse_cmap_name(ctx, cmap, file); } else if (!strcmp(buf, "WMode")) { where = " after WMode"; - pdf_parse_wmode(cmap, file); + pdf_parse_wmode(ctx, cmap, file); } else fz_strlcpy(key, buf, sizeof key); @@ -393,41 +392,41 @@ pdf_parse_cmap(fz_stream *file) else if (tok == TOK_BEGIN_CODESPACE_RANGE) { where = " codespacerange"; - pdf_parse_codespace_range(cmap, file); + pdf_parse_codespace_range(ctx, cmap, file); } else if (tok == TOK_BEGIN_BF_CHAR) { where = " bfchar"; - pdf_parse_bf_char(cmap, file); + pdf_parse_bf_char(ctx, cmap, file); } else if (tok == TOK_BEGIN_CID_CHAR) { where = " cidchar"; - pdf_parse_cid_char(cmap, file); + pdf_parse_cid_char(ctx, cmap, file); } else if (tok == TOK_BEGIN_BF_RANGE) { where = " bfrange"; - pdf_parse_bf_range(cmap, file); + pdf_parse_bf_range(ctx, cmap, file); } else if (tok == TOK_BEGIN_CID_RANGE) { where = "cidrange"; - pdf_parse_cid_range(cmap, file); + pdf_parse_cid_range(ctx, cmap, file); } /* ignore everything else */ } - pdf_sort_cmap(file->ctx, cmap); + pdf_sort_cmap(ctx, cmap); } fz_catch(ctx) { - pdf_drop_cmap(file->ctx, cmap); + pdf_drop_cmap(ctx, cmap); fz_throw(ctx, "syntaxerror in cmap%s", where); } diff --git a/pdf/pdf_cmap_table.c b/pdf/pdf_cmap_table.c index daf81ed4..fbe528e0 100644 --- a/pdf/pdf_cmap_table.c +++ b/pdf/pdf_cmap_table.c @@ -165,7 +165,7 @@ static const struct { char *name; pdf_cmap *cmap; } cmap_table[] = }; pdf_cmap * -pdf_find_builtin_cmap(char *cmap_name) +pdf_load_builtin_cmap(fz_context *ctx, char *cmap_name) { int l = 0; int r = nelem(cmap_table) - 1; diff --git a/pdf/pdf_font.c b/pdf/pdf_font.c index 65309a73..d86d4e6d 100644 --- a/pdf/pdf_font.c +++ b/pdf/pdf_font.c @@ -137,7 +137,7 @@ static int ft_cid_to_gid(pdf_font_desc *fontdesc, int cid) } int -pdf_font_cid_to_gid(pdf_font_desc *fontdesc, int cid) +pdf_font_cid_to_gid(fz_context *ctx, pdf_font_desc *fontdesc, int cid) { if (fontdesc->font->ft_face) return ft_cid_to_gid(fontdesc, cid); @@ -646,18 +646,18 @@ pdf_load_simple_font(pdf_document *xref, fz_obj *dict) } fontdesc->encoding = pdf_new_identity_cmap(ctx, 0, 1); - fontdesc->size += pdf_cmap_size(fontdesc->encoding); + fontdesc->size += pdf_cmap_size(ctx, fontdesc->encoding); fontdesc->cid_to_gid_len = 256; fontdesc->cid_to_gid = etable; - pdf_load_to_unicode(fontdesc, xref, estrings, NULL, fz_dict_gets(dict, "ToUnicode")); + pdf_load_to_unicode(xref, fontdesc, estrings, NULL, fz_dict_gets(dict, "ToUnicode")); /* RJW: "cannot load to_unicode" */ skip_encoding: /* Widths */ - pdf_set_default_hmtx(fontdesc, fontdesc->missing_width); + pdf_set_default_hmtx(ctx, fontdesc, fontdesc->missing_width); widths = fz_dict_gets(dict, "Widths"); if (widths) @@ -687,7 +687,7 @@ pdf_load_simple_font(pdf_document *xref, fz_obj *dict) } } - pdf_end_hmtx(fontdesc); + pdf_end_hmtx(ctx, fontdesc); } fz_catch(ctx) { @@ -781,9 +781,9 @@ load_cid_font(pdf_document *xref, fz_obj *dict, fz_obj *encoding, fz_obj *to_uni { fz_throw(ctx, "syntaxerror: font missing encoding"); } - fontdesc->size += pdf_cmap_size(fontdesc->encoding); + fontdesc->size += pdf_cmap_size(ctx, fontdesc->encoding); - pdf_set_font_wmode(fontdesc, pdf_get_wmode(fontdesc->encoding)); + pdf_set_font_wmode(ctx, fontdesc, pdf_get_wmode(ctx, fontdesc->encoding)); if (kind == TRUETYPE) { @@ -830,7 +830,7 @@ load_cid_font(pdf_document *xref, fz_obj *dict, fz_obj *encoding, fz_obj *to_uni } } - pdf_load_to_unicode(fontdesc, xref, NULL, collection, to_unicode); + pdf_load_to_unicode(xref, fontdesc, NULL, collection, to_unicode); /* RJW: "cannot load to_unicode" */ /* Horizontal */ @@ -839,7 +839,7 @@ load_cid_font(pdf_document *xref, fz_obj *dict, fz_obj *encoding, fz_obj *to_uni obj = fz_dict_gets(dict, "DW"); if (obj) dw = fz_to_int(obj); - pdf_set_default_hmtx(fontdesc, dw); + pdf_set_default_hmtx(ctx, fontdesc, dw); widths = fz_dict_gets(dict, "W"); if (widths) @@ -871,11 +871,11 @@ load_cid_font(pdf_document *xref, fz_obj *dict, fz_obj *encoding, fz_obj *to_uni } } - pdf_end_hmtx(fontdesc); + pdf_end_hmtx(ctx, fontdesc); /* Vertical */ - if (pdf_get_wmode(fontdesc->encoding) == 1) + if (pdf_get_wmode(ctx, fontdesc->encoding) == 1) { int dw2y = 880; int dw2w = -1000; @@ -887,7 +887,7 @@ load_cid_font(pdf_document *xref, fz_obj *dict, fz_obj *encoding, fz_obj *to_uni dw2w = fz_to_int(fz_array_get(obj, 1)); } - pdf_set_default_vmtx(fontdesc, dw2y, dw2w); + pdf_set_default_vmtx(ctx, fontdesc, dw2y, dw2w); widths = fz_dict_gets(dict, "W2"); if (widths) @@ -923,7 +923,7 @@ load_cid_font(pdf_document *xref, fz_obj *dict, fz_obj *encoding, fz_obj *to_uni } } - pdf_end_vmtx(fontdesc); + pdf_end_vmtx(ctx, fontdesc); } } fz_catch(ctx) @@ -1044,7 +1044,7 @@ pdf_make_width_table(fz_context *ctx, pdf_font_desc *fontdesc) for (k = fontdesc->hmtx[i].lo; k <= fontdesc->hmtx[i].hi; k++) { cid = pdf_lookup_cmap(fontdesc->encoding, k); - gid = pdf_font_cid_to_gid(fontdesc, cid); + gid = pdf_font_cid_to_gid(ctx, fontdesc, cid); if (gid > n) n = gid; } @@ -1059,7 +1059,7 @@ pdf_make_width_table(fz_context *ctx, pdf_font_desc *fontdesc) for (k = fontdesc->hmtx[i].lo; k <= fontdesc->hmtx[i].hi; k++) { cid = pdf_lookup_cmap(fontdesc->encoding, k); - gid = pdf_font_cid_to_gid(fontdesc, cid); + gid = pdf_font_cid_to_gid(ctx, fontdesc, cid); if (gid >= 0 && gid < font->width_count) font->width_table[gid] = fontdesc->hmtx[i].w; } @@ -1121,7 +1121,7 @@ pdf_load_font(pdf_document *xref, fz_obj *rdb, fz_obj *dict) } void -pdf_debug_font(pdf_font_desc *fontdesc) +pdf_debug_font(fz_context *ctx, pdf_font_desc *fontdesc) { int i; diff --git a/pdf/pdf_image.c b/pdf/pdf_image.c index c9359508..3aa26f08 100644 --- a/pdf/pdf_image.c +++ b/pdf/pdf_image.c @@ -184,7 +184,7 @@ pdf_load_image_imp(pdf_document *xref, fz_obj *rdb, fz_obj *dict, fz_stream *cst if (cstm) { - stm = pdf_open_inline_stream(cstm, xref, dict, stride * h); + stm = pdf_open_inline_stream(xref, dict, stride * h, cstm); } else { diff --git a/pdf/pdf_interpret.c b/pdf/pdf_interpret.c index 3a32b693..b5938829 100644 --- a/pdf/pdf_interpret.c +++ b/pdf/pdf_interpret.c @@ -705,11 +705,11 @@ pdf_show_char(pdf_csi *csi, int cid) ucslen = 1; } - gid = pdf_font_cid_to_gid(fontdesc, cid); + gid = pdf_font_cid_to_gid(ctx, fontdesc, cid); if (fontdesc->wmode == 1) { - v = pdf_get_vmtx(fontdesc, cid); + v = pdf_get_vmtx(ctx, fontdesc, cid); tsm.e -= v.x * gstate->size * 0.001f; tsm.f -= v.y * gstate->size * 0.001f; } @@ -767,7 +767,7 @@ pdf_show_char(pdf_csi *csi, int cid) if (fontdesc->wmode == 0) { - h = pdf_get_hmtx(fontdesc, cid); + h = pdf_get_hmtx(ctx, fontdesc, cid); w0 = h.w * 0.001f; tx = (w0 * gstate->size + gstate->char_space) * gstate->scale; csi->tm = fz_concat(fz_translate(tx, 0), csi->tm); diff --git a/pdf/pdf_metrics.c b/pdf/pdf_metrics.c index ae6383eb..fc888257 100644 --- a/pdf/pdf_metrics.c +++ b/pdf/pdf_metrics.c @@ -2,19 +2,19 @@ #include "mupdf.h" void -pdf_set_font_wmode(pdf_font_desc *font, int wmode) +pdf_set_font_wmode(fz_context *ctx, pdf_font_desc *font, int wmode) { font->wmode = wmode; } void -pdf_set_default_hmtx(pdf_font_desc *font, int w) +pdf_set_default_hmtx(fz_context *ctx, pdf_font_desc *font, int w) { font->dhmtx.w = w; } void -pdf_set_default_vmtx(pdf_font_desc *font, int y, int w) +pdf_set_default_vmtx(fz_context *ctx, pdf_font_desc *font, int y, int w) { font->dvmtx.y = y; font->dvmtx.w = w; @@ -67,7 +67,7 @@ static int cmpv(const void *a0, const void *b0) } void -pdf_end_hmtx(pdf_font_desc *font) +pdf_end_hmtx(fz_context *ctx, pdf_font_desc *font) { if (!font->hmtx) return; @@ -76,7 +76,7 @@ pdf_end_hmtx(pdf_font_desc *font) } void -pdf_end_vmtx(pdf_font_desc *font) +pdf_end_vmtx(fz_context *ctx, pdf_font_desc *font) { if (!font->vmtx) return; @@ -85,7 +85,7 @@ pdf_end_vmtx(pdf_font_desc *font) } pdf_hmtx -pdf_get_hmtx(pdf_font_desc *font, int cid) +pdf_get_hmtx(fz_context *ctx, pdf_font_desc *font, int cid) { int l = 0; int r = font->hmtx_len - 1; @@ -110,7 +110,7 @@ notfound: } pdf_vmtx -pdf_get_vmtx(pdf_font_desc *font, int cid) +pdf_get_vmtx(fz_context *ctx, pdf_font_desc *font, int cid) { pdf_hmtx h; pdf_vmtx v; @@ -133,7 +133,7 @@ pdf_get_vmtx(pdf_font_desc *font, int cid) } notfound: - h = pdf_get_hmtx(font, cid); + h = pdf_get_hmtx(ctx, font, cid); v = font->dvmtx; v.x = h.w / 2; return v; diff --git a/pdf/pdf_stream.c b/pdf/pdf_stream.c index 322fe3b7..3db8eb1c 100644 --- a/pdf/pdf_stream.c +++ b/pdf/pdf_stream.c @@ -233,7 +233,7 @@ pdf_open_filter(fz_stream *chain, pdf_document *xref, fz_obj *stmobj, int num, i * constraining to stream length, and without decryption. */ fz_stream * -pdf_open_inline_stream(fz_stream *chain, pdf_document *xref, fz_obj *stmobj, int length) +pdf_open_inline_stream(pdf_document *xref, fz_obj *stmobj, int length, fz_stream *chain) { fz_obj *filters; fz_obj *params; @@ -308,7 +308,7 @@ pdf_open_stream(pdf_document *xref, int num, int gen) } fz_stream * -pdf_open_stream_at(pdf_document *xref, int num, int gen, fz_obj *dict, int stm_ofs) +pdf_open_stream_with_offset(pdf_document *xref, int num, int gen, fz_obj *dict, int stm_ofs) { fz_stream *stm; diff --git a/pdf/pdf_type3.c b/pdf/pdf_type3.c index 3b596cdd..777ff756 100644 --- a/pdf/pdf_type3.c +++ b/pdf/pdf_type3.c @@ -88,13 +88,13 @@ pdf_load_type3_font(pdf_document *xref, fz_obj *rdb, fz_obj *dict) } fontdesc->encoding = pdf_new_identity_cmap(ctx, 0, 1); - fontdesc->size += pdf_cmap_size(fontdesc->encoding); + fontdesc->size += pdf_cmap_size(ctx, fontdesc->encoding); - pdf_load_to_unicode(fontdesc, xref, estrings, NULL, fz_dict_gets(dict, "ToUnicode")); + pdf_load_to_unicode(xref, fontdesc, estrings, NULL, fz_dict_gets(dict, "ToUnicode")); /* Widths */ - pdf_set_default_hmtx(fontdesc, 0); + pdf_set_default_hmtx(ctx, fontdesc, 0); first = fz_to_int(fz_dict_gets(dict, "FirstChar")); last = fz_to_int(fz_dict_gets(dict, "LastChar")); @@ -113,7 +113,7 @@ pdf_load_type3_font(pdf_document *xref, fz_obj *rdb, fz_obj *dict) pdf_add_hmtx(ctx, fontdesc, i, i, w); } - pdf_end_hmtx(fontdesc); + pdf_end_hmtx(ctx, fontdesc); /* Resources -- inherit page resources if the font doesn't have its own */ diff --git a/pdf/pdf_unicode.c b/pdf/pdf_unicode.c index 1fed0f63..d2534612 100644 --- a/pdf/pdf_unicode.c +++ b/pdf/pdf_unicode.c @@ -4,7 +4,7 @@ /* Load or synthesize ToUnicode map for fonts */ void -pdf_load_to_unicode(pdf_font_desc *font, pdf_document *xref, +pdf_load_to_unicode(pdf_document *xref, pdf_font_desc *font, char **strings, char *collection, fz_obj *cmapstm) { pdf_cmap *cmap; @@ -37,7 +37,7 @@ pdf_load_to_unicode(pdf_font_desc *font, pdf_document *xref, pdf_sort_cmap(ctx, font->to_unicode); pdf_drop_cmap(ctx, cmap); - font->size += pdf_cmap_size(font->to_unicode); + font->size += pdf_cmap_size(ctx, font->to_unicode); } else if (collection) diff --git a/pdf/pdf_xref.c b/pdf/pdf_xref.c index d1badc79..210c2f44 100644 --- a/pdf/pdf_xref.c +++ b/pdf/pdf_xref.c @@ -339,7 +339,7 @@ pdf_read_new_xref(pdf_document *xref, char *buf, int cap) index = fz_dict_gets(trailer, "Index"); - stm = pdf_open_stream_at(xref, num, gen, trailer, stm_ofs); + stm = pdf_open_stream_with_offset(xref, num, gen, trailer, stm_ofs); /* RJW: Ensure pdf_open_stream does fz_throw(ctx, "cannot open compressed xref stream (%d %d R)", num, gen); */ if (!index) diff --git a/scripts/cmapdump.c b/scripts/cmapdump.c index a41533f7..137e9abb 100644 --- a/scripts/cmapdump.c +++ b/scripts/cmapdump.c @@ -85,7 +85,7 @@ main(int argc, char **argv) clean(name); fi = fz_open_file(ctx, argv[i]); - cmap = pdf_parse_cmap(fi); + cmap = pdf_load_cmap(ctx, fi); fz_close(fi); fprintf(fo, "\n/* %s */\n\n", cmap->cmap_name); |