diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2018-02-27 19:48:01 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2018-03-07 12:19:15 +0100 |
commit | 4839427ab02dcebcc4c7703d7a04c4bdea6fac18 (patch) | |
tree | b055da40312bac611520303bf833647bd0febaf0 /source/pdf | |
parent | 4614c7472c7eb43bde8ffbbcf37e207e4c83a143 (diff) | |
download | mupdf-4839427ab02dcebcc4c7703d7a04c4bdea6fac18.tar.xz |
Distinguish between simple and CID font resources in cache.
Diffstat (limited to 'source/pdf')
-rw-r--r-- | source/pdf/pdf-font.c | 4 | ||||
-rw-r--r-- | source/pdf/pdf-resources.c | 13 |
2 files changed, 13 insertions, 4 deletions
diff --git a/source/pdf/pdf-font.c b/source/pdf/pdf-font.c index 8ca89e93..9e8a50dc 100644 --- a/source/pdf/pdf-font.c +++ b/source/pdf/pdf-font.c @@ -2099,7 +2099,7 @@ pdf_add_cid_font(fz_context *ctx, pdf_document *doc, fz_font *font) /* Before we add this font as a resource check if the same font * already exists in our resources for this doc. If yes, then * hand back that reference */ - fref = pdf_find_font_resource(ctx, doc, font->buffer, digest); + fref = pdf_find_font_resource(ctx, doc, PDF_CID_FONT_RESOURCE, font->buffer, digest); if (fref == NULL) { /* Set up desc, width, and font file */ @@ -2174,7 +2174,7 @@ pdf_add_simple_font(fz_context *ctx, pdf_document *doc, fz_font *font) /* Before we add this font as a resource check if the same font * already exists in our resources for this doc. If yes, then * hand back that reference */ - fref = pdf_find_font_resource(ctx, doc, font->buffer, digest); + fref = pdf_find_font_resource(ctx, doc, PDF_SIMPLE_FONT_RESOURCE, font->buffer, digest); if (fref == NULL) { fobj = pdf_new_dict(ctx, doc, 10); diff --git a/source/pdf/pdf-resources.c b/source/pdf/pdf-resources.c index 3a0ddbce..72adf081 100644 --- a/source/pdf/pdf-resources.c +++ b/source/pdf/pdf-resources.c @@ -109,15 +109,24 @@ pdf_insert_image_resource(fz_context *ctx, pdf_document *doc, unsigned char dige * it may be more problematic. */ pdf_obj * -pdf_find_font_resource(fz_context *ctx, pdf_document *doc, fz_buffer *item, unsigned char digest[16]) +pdf_find_font_resource(fz_context *ctx, pdf_document *doc, int type, fz_buffer *item, unsigned char digest[16]) { + fz_md5 state; + unsigned char *data; + size_t size; pdf_obj *res; if (!doc->resources.fonts) doc->resources.fonts = fz_new_hash_table(ctx, 4096, 16, -1, pdf_drop_obj_as_void); + size = fz_buffer_storage(ctx, item, &data); + /* Create md5 and see if we have the item in our table */ - fz_md5_buffer(ctx, item, digest); + fz_md5_init(&state); + fz_md5_update(&state, (unsigned char*)&type, sizeof type); + fz_md5_update(&state, data, size); + fz_md5_final(&state, digest); + res = fz_hash_find(ctx, doc->resources.fonts, digest); if (res) pdf_keep_obj(ctx, res); |