summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Liddell <chris.liddell@artifex.com>2022-06-09 10:56:24 +0100
committerChris Liddell <chris.liddell@artifex.com>2022-06-09 13:48:03 +0100
commit950e8b0764ccd3cf5f6f29baa831d1db7ee644b7 (patch)
tree35f5f5e1214c1dc096b6318ad39f02b3e79e2918
parent00f6bd069221701d054abc67909e80ff61561d75 (diff)
downloadghostpdl-9.56.0_ttf_fix.tar.gz
Don't require FontDescriptor/FirstChar/LastChar for TTFsghostpdl-9.56.0_ttf_fix
Previously the pdfi TTF loading code required those keys, throwing an error if they were missing. This was an oversight, meaning TTF fonts couldn't be reliably used as substitutes for the PDF "base fonts".
-rw-r--r--pdf/pdf_fontTT.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/pdf/pdf_fontTT.c b/pdf/pdf_fontTT.c
index aec3ee7b9..cb266772e 100644
--- a/pdf/pdf_fontTT.c
+++ b/pdf/pdf_fontTT.c
@@ -371,11 +371,7 @@ int pdfi_read_truetype_font(pdf_context *ctx, pdf_dict *font_dict, pdf_dict *str
*ppdffont = NULL;
- code = pdfi_dict_knownget_type(ctx, font_dict, "FontDescriptor", PDF_DICT, &fontdesc);
- if (code <= 0) {
- code = gs_note_error(gs_error_invalidfont);
- goto error;
- }
+ (void)pdfi_dict_knownget_type(ctx, font_dict, "FontDescriptor", PDF_DICT, &fontdesc);
if ((code = pdfi_alloc_tt_font(ctx, &font, false)) < 0) {
code = gs_note_error(gs_error_invalidfont);
@@ -391,13 +387,15 @@ int pdfi_read_truetype_font(pdf_context *ctx, pdf_dict *font_dict, pdf_dict *str
code = pdfi_dict_get_number(ctx, font_dict, "FirstChar", &f);
if (code < 0) {
- goto error;
+ f = 0;
+ code = 0;
}
font->FirstChar = (int)f;
code = pdfi_dict_get_number(ctx, font_dict, "LastChar", &f);
if (code < 0) {
- goto error;
+ f = 255;
+ code = 0;
}
font->LastChar = (int)f;
@@ -428,8 +426,6 @@ int pdfi_read_truetype_font(pdf_context *ctx, pdf_dict *font_dict, pdf_dict *str
pdfi_countup(font_dict);
code = pdfi_dict_knownget_type(ctx, font_dict, "Widths", PDF_ARRAY, (pdf_obj **)&obj);
- if (code < 0)
- goto error;
if (code > 0) {
if (num_chars != pdfi_array_size((pdf_array *)obj)) {
code = gs_note_error(gs_error_rangecheck);
@@ -472,9 +468,14 @@ int pdfi_read_truetype_font(pdf_context *ctx, pdf_dict *font_dict, pdf_dict *str
font->ToUnicode = tounicode;
tounicode = NULL;
- code = pdfi_dict_get_int(ctx, font->FontDescriptor, "Flags", &descflags);
- if (code < 0)
+ if (font->FontDescriptor != NULL) {
+ code = pdfi_dict_get_int(ctx, font->FontDescriptor, "Flags", &descflags);
+ if (code < 0)
+ descflags = 0;
+ }
+ else {
descflags = 0;
+ }
code = pdfi_dict_get(ctx, font_dict, "Encoding", &obj);
if (code < 0) {