Commit 9068f1c0 authored by Tobias Deiminger's avatar Tobias Deiminger Committed by Albert Astals Cid
Browse files

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.
parent fb5d8000
Pipeline #25512 passed with stages
in 46 minutes and 18 seconds
...@@ -2620,6 +2620,8 @@ void AnnotLink::draw(Gfx *gfx, bool printing) { ...@@ -2620,6 +2620,8 @@ void AnnotLink::draw(Gfx *gfx, bool printing) {
//------------------------------------------------------------------------ //------------------------------------------------------------------------
// AnnotFreeText // AnnotFreeText
//------------------------------------------------------------------------ //------------------------------------------------------------------------
const double AnnotFreeText::undefinedFontPtSize = 10.;
AnnotFreeText::AnnotFreeText(PDFDoc *docA, PDFRectangle *rect, const DefaultAppearance &da) : AnnotFreeText::AnnotFreeText(PDFDoc *docA, PDFRectangle *rect, const DefaultAppearance &da) :
AnnotMarkup(docA, rect) { AnnotMarkup(docA, rect) {
type = typeFreeText; type = typeFreeText;
...@@ -2647,8 +2649,7 @@ void AnnotFreeText::initialize(PDFDoc *docA, Dict *dict) { ...@@ -2647,8 +2649,7 @@ void AnnotFreeText::initialize(PDFDoc *docA, Dict *dict) {
appearanceString.reset(obj1.getString()->copy()); appearanceString.reset(obj1.getString()->copy());
} else { } else {
appearanceString = std::make_unique<GooString>(); appearanceString = std::make_unique<GooString>();
error(errSyntaxError, -1, "Bad appearance for annotation"); error(errSyntaxWarning, -1, "Bad appearance for annotation");
ok = false;
} }
obj1 = dict->lookup("Q"); obj1 = dict->lookup("Q");
...@@ -2843,7 +2844,7 @@ void AnnotFreeText::generateFreeTextAppearance() ...@@ -2843,7 +2844,7 @@ void AnnotFreeText::generateFreeTextAppearance()
if (!da.getFontName().isName()) if (!da.getFontName().isName())
da.setFontName(Object(objName, "AnnotDrawFont")); da.setFontName(Object(objName, "AnnotDrawFont"));
if (da.getFontPtSize() <= 0) if (da.getFontPtSize() <= 0)
da.setFontPtSize(10); da.setFontPtSize(undefinedFontPtSize);
if (!da.getFontColor()) if (!da.getFontColor())
da.setFontColor(std::make_unique<AnnotColor>(0, 0, 0)); da.setFontColor(std::make_unique<AnnotColor>(0, 0, 0));
if (!contents) if (!contents)
......
...@@ -1005,6 +1005,8 @@ public: ...@@ -1005,6 +1005,8 @@ public:
intentFreeTextTypeWriter // FreeTextTypeWriter intentFreeTextTypeWriter // FreeTextTypeWriter
}; };
static const double undefinedFontPtSize;
AnnotFreeText(PDFDoc *docA, PDFRectangle *rect, const DefaultAppearance &da); AnnotFreeText(PDFDoc *docA, PDFRectangle *rect, const DefaultAppearance &da);
AnnotFreeText(PDFDoc *docA, Object &&dictObject, const Object *obj); AnnotFreeText(PDFDoc *docA, Object &&dictObject, const Object *obj);
~AnnotFreeText(); ~AnnotFreeText();
......
...@@ -2094,15 +2094,18 @@ QFont TextAnnotation::textFont() const ...@@ -2094,15 +2094,18 @@ QFont TextAnnotation::textFont() const
if ( !d->pdfAnnot ) if ( !d->pdfAnnot )
return d->textFont; return d->textFont;
QFont font; double fontSize { AnnotFreeText::undefinedFontPtSize };
if ( d->pdfAnnot->getType() == Annot::typeFreeText ) 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; return font;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment