diff options
Diffstat (limited to 'source/pdf')
-rw-r--r-- | source/pdf/pdf-font.c | 6 | ||||
-rw-r--r-- | source/pdf/pdf-resources.c | 15 |
2 files changed, 7 insertions, 14 deletions
diff --git a/source/pdf/pdf-font.c b/source/pdf/pdf-font.c index 72e2a971..f600fc1b 100644 --- a/source/pdf/pdf-font.c +++ b/source/pdf/pdf-font.c @@ -2010,7 +2010,7 @@ pdf_add_cid_font(fz_context *ctx, pdf_document *doc, fz_font *font) pdf_obj *dfonts = NULL; unsigned char digest[16]; - fref = pdf_find_font_resource(ctx, doc, PDF_CID_FONT_RESOURCE, 0, font->buffer, digest); + fref = pdf_find_font_resource(ctx, doc, PDF_CID_FONT_RESOURCE, 0, font, digest); if (fref) return fref; @@ -2087,7 +2087,7 @@ pdf_add_simple_font(fz_context *ctx, pdf_document *doc, fz_font *font, int encod const char **enc; unsigned char digest[16]; - fref = pdf_find_font_resource(ctx, doc, PDF_SIMPLE_FONT_RESOURCE, encoding, font->buffer, digest); + fref = pdf_find_font_resource(ctx, doc, PDF_SIMPLE_FONT_RESOURCE, encoding, font, digest); if (fref) return fref; @@ -2199,7 +2199,7 @@ pdf_add_cjk_font(fz_context *ctx, pdf_document *doc, fz_font *fzfont, int script if (serif) flags |= PDF_FD_SERIF; - fref = pdf_find_font_resource(ctx, doc, PDF_CJK_FONT_RESOURCE, script, fzfont->buffer, digest); + fref = pdf_find_font_resource(ctx, doc, PDF_CJK_FONT_RESOURCE, script, fzfont, digest); if (fref) return fref; diff --git a/source/pdf/pdf-resources.c b/source/pdf/pdf-resources.c index 55d6603e..82991f6e 100644 --- a/source/pdf/pdf-resources.c +++ b/source/pdf/pdf-resources.c @@ -109,24 +109,17 @@ 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, int type, int encoding, fz_buffer *item, unsigned char digest[16]) +pdf_find_font_resource(fz_context *ctx, pdf_document *doc, int type, int encoding, fz_font *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); + fz_font_digest(ctx, item, digest); - /* Create md5 and see if we have the item in our table */ - fz_md5_init(&state); - fz_md5_update(&state, (unsigned char*)&type, sizeof type); - fz_md5_update(&state, (unsigned char*)&encoding, sizeof encoding); - fz_md5_update(&state, data, size); - fz_md5_final(&state, digest); + digest[0] += type; + digest[1] += encoding; res = fz_hash_find(ctx, doc->resources.fonts, digest); if (res) |