Commit 2a33db917fad7e8769ae00319d7ece83eec42d27

Authored by m-holger
1 parent 8aab6838

Refactor `FormNode`: remove unused `getFontFromResource` method and simplify fon…

…t resource handling in `generateTextAppearance`.
libqpdf/QPDFFormFieldObjectHelper.cc
... ... @@ -877,16 +877,6 @@ namespace
877 877 };
878 878 } // namespace
879 879  
880   -QPDFObjectHandle
881   -FormNode::getFontFromResource(QPDFObjectHandle resources, std::string const& name)
882   -{
883   - QPDFObjectHandle result;
884   - if (resources.isDictionary() && resources.getKey("/Font").isDictionary() &&
885   - resources.getKey("/Font").hasKey(name)) {
886   - result = resources.getKey("/Font").getKey(name);
887   - }
888   - return result;
889   -}
890 880  
891 881 void
892 882 FormNode::generateTextAppearance(QPDFAnnotationObjectHelper& aoh)
... ... @@ -961,9 +951,9 @@ FormNode::generateTextAppearance(QPDFAnnotationObjectHelper& aoh)
961 951 if (!font_name.empty()) {
962 952 // See if the font is encoded with something we know about.
963 953 Dictionary resources = AS.getDict()["/Resources"];
964   - Dictionary font = getFontFromResource(resources, font_name);
  954 + Dictionary font = resources["/Font"][font_name];
965 955 if (!font) {
966   - font = getFontFromResource(getDefaultResources(), font_name);
  956 + font = getDefaultResources()["/Font"][font_name];
967 957 if (resources) {
968 958 if (resources.indirect()) {
969 959 resources = resources.qpdf()->makeIndirectObject(resources.copy());
... ... @@ -972,7 +962,7 @@ FormNode::generateTextAppearance(QPDFAnnotationObjectHelper& aoh)
972 962 // Use mergeResources to force /Font to be local
973 963 QPDFObjectHandle res = resources;
974 964 res.mergeResources(Dictionary({{"/Font", Dictionary::empty()}}));
975   - res.getKey("/Font").replaceKey(font_name, font);
  965 + res.getKey("/Font").replace(font_name, font);
976 966 }
977 967 }
978 968  
... ...
libqpdf/qpdf/AcroForm.hh
... ... @@ -769,8 +769,6 @@ namespace qpdf::impl
769 769 void setRadioButtonValue(QPDFObjectHandle name);
770 770 void setCheckBoxValue(bool value);
771 771 void generateTextAppearance(QPDFAnnotationObjectHelper&);
772   - QPDFObjectHandle
773   - getFontFromResource(QPDFObjectHandle resources, std::string const& font_name);
774 772  
775 773 static const QPDFObjectHandle null_oh;
776 774 }; // class FormNode
... ...