diff options
author | Chris Liddell <chris.liddell@artifex.com> | 2022-05-19 15:16:32 +0100 |
---|---|---|
committer | Chris Liddell <chris.liddell@artifex.com> | 2022-06-01 09:47:34 +0100 |
commit | 54370871796cfdc5be5c424c87c0b1135ce3a044 (patch) | |
tree | 164165b69057a9f2c578f3b5dd3cf11e2854ed2e /pdf/pdf_fmap.c | |
parent | 7359f75059bad3216b0a9a886b4c211011a68e05 (diff) | |
download | ghostpdl-54370871796cfdc5be5c424c87c0b1135ce3a044.tar.gz |
Bug 705298: Change priority of font maps
The pdfi fontmap code prioritized explicit mappings from the Fontmap file, over
mappings generated automatically from the FONTPATH option. Turns out, it
should be the other way around.
Secondly, the pdfi code would "sanitize" the font name to look for before
consulting either font map, where we should check the name as read from the
PDF before trying the sanitized version.
Diffstat (limited to 'pdf/pdf_fmap.c')
-rw-r--r-- | pdf/pdf_fmap.c | 37 |
1 files changed, 21 insertions, 16 deletions
diff --git a/pdf/pdf_fmap.c b/pdf/pdf_fmap.c index d863d58c5..595ead7b9 100644 --- a/pdf/pdf_fmap.c +++ b/pdf/pdf_fmap.c @@ -814,22 +814,7 @@ pdf_fontmap_lookup_font(pdf_context *ctx, pdf_name *fname, pdf_obj **mapname, in return code; } - code = pdfi_dict_get_by_key(ctx, ctx->pdffontmap, fname, &mname); - if (code >= 0) { - /* Fontmap can map in multiple "jump" i.e. - name -> substitute name - subsitute name -> file name - So we want to loop until we no more hits. - */ - while(1) { - pdf_obj *mname2; - code = pdfi_dict_get_by_key(ctx, ctx->pdffontmap, (pdf_name *)mname, &mname2); - if (code < 0) break; - pdfi_countdown(mname); - mname = mname2; - } - } - else if (ctx->pdfnativefontmap != NULL) { + if (ctx->pdfnativefontmap != NULL) { pdf_obj *record; code = pdfi_dict_get_by_key(ctx, ctx->pdfnativefontmap, fname, &record); if (code < 0) @@ -849,7 +834,27 @@ pdf_fontmap_lookup_font(pdf_context *ctx, pdf_name *fname, pdf_obj **mapname, in *findex = (int)i64; /* Rangecheck? */ } } + else { + code = gs_error_undefined; + } + if (code < 0) { + code = pdfi_dict_get_by_key(ctx, ctx->pdffontmap, fname, &mname); + if (code >= 0) { + /* Fontmap can map in multiple "jump" i.e. + name -> substitute name + subsitute name -> file name + So we want to loop until we no more hits. + */ + while(1) { + pdf_obj *mname2; + code = pdfi_dict_get_by_key(ctx, ctx->pdffontmap, (pdf_name *)mname, &mname2); + if (code < 0) break; + pdfi_countdown(mname); + mname = mname2; + } + } + } if (mname != NULL && pdfi_type_of(mname) == PDF_STRING && pdfi_fmap_file_exists(ctx, (pdf_string *)mname)) { *mapname = mname; code = 0; |