summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Liddell <chris.liddell@artifex.com>2021-05-10 14:44:09 +0100
committerChris Liddell <chris.liddell@artifex.com>2021-05-11 11:39:16 +0100
commita1a95d63a8e47b9fb56427df3a214c6ee1695d04 (patch)
treec6f63c91adbceda661cab0c021747bf623ddb120
parent94161cdca08c925569a8d81fa60c11a4b938f706 (diff)
downloadghostpdl-a1a95d63a8e47b9fb56427df3a214c6ee1695d04.tar.gz
Ignore "name" encodings for certain fonts
There are (currently) a couple of fonts for which we have to ignore any encoding specified by a name object in the PDF /Font object. Encodings defined as a base encoding and differences array should be used. Otherwise, the font's "native" encoding should be used.
-rw-r--r--pdf/pdf_font.c33
-rw-r--r--pdf/pdf_font.h1
-rw-r--r--pdf/pdf_font1.c7
3 files changed, 40 insertions, 1 deletions
diff --git a/pdf/pdf_font.c b/pdf/pdf_font.c
index 367e0ffea..63742a94a 100644
--- a/pdf/pdf_font.c
+++ b/pdf/pdf_font.c
@@ -32,6 +32,39 @@
#include "pdf_font0.h"
#include "gscencs.h" /* For gs_c_known_encode and gs_c_glyph_name */
+/* These are fonts for which we have to ignore "named" encodings */
+typedef struct known_symbolic_font_name_s
+{
+ const char *name;
+ const int namelen;
+} known_symbolic_font_name_t;
+
+#define DEFINE_NAME_LEN(s) #s, sizeof(#s) - 1
+static const known_symbolic_font_name_t known_symbolic_font_names[] =
+{
+ {DEFINE_NAME_LEN(Wingdings2)},
+ {DEFINE_NAME_LEN(ZapfDingbats)},
+ {NULL , 0}
+};
+#undef DEFINE_NAME_LEN
+
+bool pdfi_font_ignore_named_encoding(pdf_obj *basefont)
+{
+ bool ignore = false;
+ int i;
+ pdf_name *nm = (pdf_name *)basefont;
+
+ if (basefont != NULL && basefont->type == PDF_NAME) {
+ for (i = 0; known_symbolic_font_names[i].name != NULL; i++) {
+ if (nm->length == known_symbolic_font_names[i].namelen
+ && !strncmp((char *)nm->data, known_symbolic_font_names[i].name, nm->length)) {
+ ignore = true;
+ break;
+ }
+ }
+ }
+ return ignore;
+}
int pdfi_d0(pdf_context *ctx)
{
diff --git a/pdf/pdf_font.h b/pdf/pdf_font.h
index ecc5670bc..c0dddd02f 100644
--- a/pdf/pdf_font.h
+++ b/pdf/pdf_font.h
@@ -90,6 +90,7 @@ pdfi_set_font_internal(pdf_context *ctx, pdf_obj *fontobj, double point_size);
int pdfi_font_set_internal_string(pdf_context *ctx, const char *fontname, double point_size);
int pdfi_font_set_internal_name(pdf_context *ctx, pdf_name *fontname, double point_size);
+bool pdfi_font_ignore_named_encoding(pdf_obj *basefont);
#endif
diff --git a/pdf/pdf_font1.c b/pdf/pdf_font1.c
index 2174e1f44..d827c5248 100644
--- a/pdf/pdf_font1.c
+++ b/pdf/pdf_font1.c
@@ -627,13 +627,18 @@ pdfi_read_type1_font(pdf_context * ctx, pdf_dict * font_dict,
tmp = NULL;
code = pdfi_dict_knownget(ctx, font_dict, "Encoding", &tmp);
- if (code == 1) {
+ if (code == 1 && !(tmp->type == PDF_NAME && pdfi_font_ignore_named_encoding(basefont))) {
code = pdfi_create_Encoding(ctx, tmp, (pdf_obj **) & t1f->Encoding);
if (code >= 0)
code = 1;
pdfi_countdown(tmp);
tmp = NULL;
}
+ else {
+ pdfi_countdown(tmp);
+ tmp = NULL;
+ code = 0;
+ }
if (code <= 0) {
t1f->Encoding = fpriv.u.t1.Encoding;