summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Liddell <chris.liddell@artifex.com>2022-08-31 09:03:02 +0100
committerChris Liddell <chris.liddell@artifex.com>2022-09-02 15:59:07 +0100
commit1e08e6ccb121271c88ed5be1f4db1b2f3b05a38f (patch)
tree6b1f718c8ce36de9834b3cd70b15b26f3a217f51
parent1d6d912050f7a3c0dcdea1da3951e78fd71137bd (diff)
downloadghostpdl-1e08e6ccb121271c88ed5be1f4db1b2f3b05a38f.tar.gz
Fix FONTPATH fontmap functionality
Firstly, pdfi is strict in enforcing that dictionary keys must be names, so when the mapping is a path/file we need to convert that string to a name so we can store it in the substitute fonts dictionary. Secondly, an error storing the mapping in the substitute fonts dictionary should not be propagated - we should continue to use the mapping even if we can't store it for later reuse. Stems from (but not fixes) Bug 705831
-rw-r--r--pdf/pdf_font.c21
1 files changed, 19 insertions, 2 deletions
diff --git a/pdf/pdf_font.c b/pdf/pdf_font.c
index e7ac67fed..28ebe96e0 100644
--- a/pdf/pdf_font.c
+++ b/pdf/pdf_font.c
@@ -784,7 +784,7 @@ static int pdfi_load_font_file(pdf_context *ctx, int fftype, pdf_name *Subtype,
}
else {
pdffont->filename = NULL;
- code = pdfi_object_alloc(ctx, PDF_STRING,strlen(fontfname) , (pdf_obj **)&pdffont->filename);
+ code = pdfi_object_alloc(ctx, PDF_STRING, strlen(fontfname) , (pdf_obj **)&pdffont->filename);
if (code >= 0) {
pdfi_countup(pdffont->filename);
memcpy(pdffont->filename->data, fontfname, strlen(fontfname));
@@ -797,7 +797,24 @@ static int pdfi_load_font_file(pdf_context *ctx, int fftype, pdf_name *Subtype,
pdfi_countup(ctx->pdf_substitute_fonts);
}
if (ctx->pdf_substitute_fonts != NULL) {
- code = pdfi_dict_put_obj(ctx, ctx->pdf_substitute_fonts, mapname, (pdf_obj *)pdffont, true);
+ if (pdfi_type_of(mapname) == PDF_STRING) {
+ pdf_name *n = NULL;
+ pdf_string *mn = (pdf_string *)mapname;
+
+ code = pdfi_name_alloc(ctx, mn->data, mn->length, (pdf_obj **)&n);
+ if (code >= 0) {
+ pdfi_countdown(mapname);
+ mapname = (pdf_obj *)n;
+ pdfi_countup(mapname);
+ code = 0;
+ }
+ }
+ else
+ code = 0;
+
+ if (code == 0)
+ (void)pdfi_dict_put_obj(ctx, ctx->pdf_substitute_fonts, mapname, (pdf_obj *)pdffont, true);
+ code = 0;
}
}
}