Don't error out if there's no DA in FreeText annotation
We can proceed anyway, hardcoded default values will be used in
AnnotFreeText::generateFreeTextAppearance.
diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 00fc7be..c75837f 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -2620,6 +2620,8 @@
//------------------------------------------------------------------------
// AnnotFreeText
//------------------------------------------------------------------------
+const double AnnotFreeText::undefinedFontPtSize = 10.;
+
AnnotFreeText::AnnotFreeText(PDFDoc *docA, PDFRectangle *rect, const DefaultAppearance &da) :
AnnotMarkup(docA, rect) {
type = typeFreeText;
@@ -2647,8 +2649,7 @@
appearanceString.reset(obj1.getString()->copy());
} else {
appearanceString = std::make_unique<GooString>();
- error(errSyntaxError, -1, "Bad appearance for annotation");
- ok = false;
+ error(errSyntaxWarning, -1, "Bad appearance for annotation");
}
obj1 = dict->lookup("Q");
@@ -2843,7 +2844,7 @@
if (!da.getFontName().isName())
da.setFontName(Object(objName, "AnnotDrawFont"));
if (da.getFontPtSize() <= 0)
- da.setFontPtSize(10);
+ da.setFontPtSize(undefinedFontPtSize);
if (!da.getFontColor())
da.setFontColor(std::make_unique<AnnotColor>(0, 0, 0));
if (!contents)
diff --git a/poppler/Annot.h b/poppler/Annot.h
index 8603b75..105ed2e 100644
--- a/poppler/Annot.h
+++ b/poppler/Annot.h
@@ -1005,6 +1005,8 @@
intentFreeTextTypeWriter // FreeTextTypeWriter
};
+ static const double undefinedFontPtSize;
+
AnnotFreeText(PDFDoc *docA, PDFRectangle *rect, const DefaultAppearance &da);
AnnotFreeText(PDFDoc *docA, Object &&dictObject, const Object *obj);
~AnnotFreeText();
diff --git a/qt5/src/poppler-annotation.cc b/qt5/src/poppler-annotation.cc
index 2f35425..b372ccb 100644
--- a/qt5/src/poppler-annotation.cc
+++ b/qt5/src/poppler-annotation.cc
@@ -2094,15 +2094,18 @@
if ( !d->pdfAnnot )
return d->textFont;
- QFont font;
+ double fontSize { AnnotFreeText::undefinedFontPtSize };
if ( d->pdfAnnot->getType() == Annot::typeFreeText )
{
- if ( std::unique_ptr<DefaultAppearance> da{ d->getDefaultAppearanceFromNative() } )
+ std::unique_ptr<DefaultAppearance> da{ d->getDefaultAppearanceFromNative() };
+ if ( da && da->getFontPtSize() > 0 )
{
- font.setPointSize( da->getFontPtSize() );
+ fontSize = da->getFontPtSize();
}
}
+ QFont font;
+ font.setPointSizeF( fontSize );
return font;
}