[poppler] poppler/Annot.cc poppler/Annot.h qt5/src

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Mar 21 23:43:50 UTC 2019


 poppler/Annot.cc              |    7 ++++---
 poppler/Annot.h               |    2 ++
 qt5/src/poppler-annotation.cc |    9 ++++++---
 3 files changed, 12 insertions(+), 6 deletions(-)

New commits:
commit 9068f1c0d2f643471a7e159f4a03dca4a20518f2
Author: Tobias Deiminger <haxtibal at posteo.de>
Date:   Thu Mar 21 23:43:48 2019 +0000

    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 00fc7be2..c75837f6 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -2620,6 +2620,8 @@ void AnnotLink::draw(Gfx *gfx, bool printing) {
 //------------------------------------------------------------------------
 // AnnotFreeText
 //------------------------------------------------------------------------
+const double AnnotFreeText::undefinedFontPtSize = 10.;
+
 AnnotFreeText::AnnotFreeText(PDFDoc *docA, PDFRectangle *rect, const DefaultAppearance &da) :
     AnnotMarkup(docA, rect) {
   type = typeFreeText;
@@ -2647,8 +2649,7 @@ void AnnotFreeText::initialize(PDFDoc *docA, Dict *dict) {
     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 @@ void AnnotFreeText::generateFreeTextAppearance()
   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 8603b754..105ed2e4 100644
--- a/poppler/Annot.h
+++ b/poppler/Annot.h
@@ -1005,6 +1005,8 @@ public:
     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 2f35425a..b372ccb3 100644
--- a/qt5/src/poppler-annotation.cc
+++ b/qt5/src/poppler-annotation.cc
@@ -2094,15 +2094,18 @@ QFont TextAnnotation::textFont() const
     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;
 }
 


More information about the poppler mailing list