From c71d555320120cf5c088f6f57a64d41bd13c7511 Mon Sep 17 00:00:00 2001 From: Oliver Sander Date: Thu, 10 May 2018 06:32:16 +0200 Subject: [PATCH 4/4] Parse font name in AnnotFreeText::parseAppearanceString --- poppler/Annot.cc | 9 ++++++--- poppler/Annot.h | 4 +++- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/poppler/Annot.cc b/poppler/Annot.cc index d5a66524..83f8acd1 100644 --- a/poppler/Annot.cc +++ b/poppler/Annot.cc @@ -2820,7 +2820,7 @@ static GfxFont * createAnnotDrawFont(XRef * xref, Dict *fontResDict) return GfxFont::makeFont(xref, "AnnotDrawFont", dummyRef, fontDict); } -void AnnotFreeText::parseAppearanceString(GooString *da, double &fontsize, AnnotColor* &fontcolor) { +void AnnotFreeText::parseAppearanceString(GooString *da, double &fontsize, AnnotColor* &fontcolor, std::string& fontname) { fontsize = -1; fontcolor = nullptr; if (da) { @@ -2829,7 +2829,9 @@ void AnnotFreeText::parseAppearanceString(GooString *da, double &fontsize, Annot if (i >= 1) { fontsize = gatof(( (GooString *)daToks->get(i-1) )->getCString()); - // TODO: Font name + } + if (i >= 2) { + fontname = std::string(((GooString *)daToks->get(i-2))->getCString()); } // Scan backwards: we are looking for the last set value for (i = daToks->getLength()-1; i >= 0; --i) { @@ -2870,7 +2872,8 @@ void AnnotFreeText::generateFreeTextAppearance() // Parse some properties from the appearance string double fontsize; AnnotColor *fontcolor; - parseAppearanceString(appearanceString, fontsize, fontcolor); + std::string fontname; // TODO Not actually used yet + parseAppearanceString(appearanceString, fontsize, fontcolor, fontname); // Default values if (fontsize <= 0) fontsize = 10; diff --git a/poppler/Annot.h b/poppler/Annot.h index 83c10b39..6b432cc5 100644 --- a/poppler/Annot.h +++ b/poppler/Annot.h @@ -40,6 +40,8 @@ #pragma interface #endif +#include + #include "Object.h" class XRef; @@ -997,7 +999,7 @@ public: protected: void initialize(PDFDoc *docA, Dict *dict); - static void parseAppearanceString(GooString *da, double &fontsize, AnnotColor* &fontcolor); + static void parseAppearanceString(GooString *da, double &fontsize, AnnotColor* &fontcolor, std::string& fontname); void generateFreeTextAppearance(); // required -- 2.17.0