summaryrefslogtreecommitdiff
path: root/source/pdf/pdf-appearance.c
diff options
context:
space:
mode:
authorTor Andersson <tor.andersson@artifex.com>2018-03-15 16:21:28 +0100
committerTor Andersson <tor.andersson@artifex.com>2018-03-16 14:51:41 +0100
commitbe498ab76551419f39fe5e56a14968d604877840 (patch)
tree36d751921125b829365c1646aa26fe40a986157e /source/pdf/pdf-appearance.c
parentc0d8ee91b91da01f248221b52de7c1628b4c34e8 (diff)
downloadmupdf-be498ab76551419f39fe5e56a14968d604877840.tar.xz
Fix 699026: Create missing font resource.
If a widget DR is missing the font name given in the DA, create a new simple font for it.
Diffstat (limited to 'source/pdf/pdf-appearance.c')
-rw-r--r--source/pdf/pdf-appearance.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/source/pdf/pdf-appearance.c b/source/pdf/pdf-appearance.c
index 49e932c3..51064f0d 100644
--- a/source/pdf/pdf-appearance.c
+++ b/source/pdf/pdf-appearance.c
@@ -168,12 +168,22 @@ void pdf_parse_da(fz_context *ctx, char *da, pdf_da_info *di)
static void get_font_info(fz_context *ctx, pdf_document *doc, pdf_obj *dr, char *da, font_info *font_rec)
{
pdf_font_desc *font;
+ pdf_obj *fontobj;
pdf_parse_da(ctx, da, &font_rec->da_rec);
if (font_rec->da_rec.font_name == NULL)
fz_throw(ctx, FZ_ERROR_GENERIC, "No font name in default appearance");
- font_rec->font = font = pdf_load_font(ctx, doc, dr, pdf_dict_gets(ctx, pdf_dict_get(ctx, dr, PDF_NAME_Font), font_rec->da_rec.font_name), 0);
+ fontobj = pdf_dict_gets(ctx, pdf_dict_get(ctx, dr, PDF_NAME_Font), font_rec->da_rec.font_name);
+ if (!fontobj)
+ {
+ fz_font *helv = fz_new_base14_font(ctx, "Helvetica");
+ fz_warn(ctx, "form resource dictionary is missing the default appearance font");
+ fontobj = pdf_add_simple_font(ctx, doc, helv, PDF_SIMPLE_ENCODING_LATIN);
+ pdf_dict_puts_drop(ctx, pdf_dict_get(ctx, dr, PDF_NAME_Font), font_rec->da_rec.font_name, fontobj);
+ fz_drop_font(ctx, helv);
+ }
+ font_rec->font = font = pdf_load_font(ctx, doc, dr, fontobj, 0);
font_rec->lineheight = 1.0f;
if (font && font->ascent != 0.0f && font->descent != 0.0f)
font_rec->lineheight = (font->ascent - font->descent) / 1000.0f;