diff options
author | Jay Berkenbilt <ejb@ql.org> | 2021-03-03 22:57:37 +0100 |
---|---|---|
committer | Jay Berkenbilt <ejb@ql.org> | 2021-03-04 21:08:36 +0100 |
commit | 887f35efaa60653dcb92ea96c5f4d17bdd859d93 (patch) | |
tree | 0a8f1c7942c6285ed212afc585fcac2ccc2bfe43 /libqpdf | |
parent | a2124f992c7a3c2695b93cf7fe9298c3a862ffc9 (diff) | |
download | qpdf-887f35efaa60653dcb92ea96c5f4d17bdd859d93.tar.zst |
When resolving font from /DR, copy it into resources
Diffstat (limited to 'libqpdf')
-rw-r--r-- | libqpdf/QPDFFormFieldObjectHelper.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/libqpdf/QPDFFormFieldObjectHelper.cc b/libqpdf/QPDFFormFieldObjectHelper.cc index c88934a8..c84e31d9 100644 --- a/libqpdf/QPDFFormFieldObjectHelper.cc +++ b/libqpdf/QPDFFormFieldObjectHelper.cc @@ -963,11 +963,28 @@ QPDFFormFieldObjectHelper::generateTextAppearance( // See if the font is encoded with something we know about. QPDFObjectHandle resources = AS.getDict().getKey("/Resources"); QPDFObjectHandle font = getFontFromResource(resources, font_name); + bool found_font_in_dr = false; if (! font.isInitialized()) { QPDFObjectHandle dr = getDefaultResources(); font = getFontFromResource(dr, font_name); + found_font_in_dr = (font.isInitialized() && font.isDictionary()); } + if (found_font_in_dr && resources.isDictionary()) + { + QTC::TC("qpdf", "QPDFFormFieldObjectHelper get font from /DR"); + if (resources.isIndirect()) + { + resources = resources.getOwningQPDF()->makeIndirectObject( + resources.shallowCopy()); + AS.getDict().replaceKey("/Resources", resources); + } + // Use mergeResources to force /Font to be local + resources.mergeResources( + QPDFObjectHandle::parse("<< /Font << >> >>")); + resources.getKey("/Font").replaceKey(font_name, font); + } + if (font.isInitialized() && font.isDictionary() && font.getKey("/Encoding").isName()) |