[Poppler-bugs] [Bug 107151] Add font color in Poppler Qt5 frontend

bugzilla-daemon at freedesktop.org bugzilla-daemon at freedesktop.org
Sat Jul 21 21:56:35 UTC 2018


https://bugs.freedesktop.org/show_bug.cgi?id=107151

--- Comment #8 from Tobias Deiminger <haxtibal at posteo.de> ---
Ok, here's my take. Problems with solutions (draft).

Problem 1: Qt5 shouldn't care about low-level DA creation

GooString * TextAnnotationPrivate::toAppearanceString(const QFont &font)
...
  // Qt5 shouldn't need to know how to create Tf operator
  GooString * s = GooString::format("{0:f} {1:f} {2:f} rg /Invalid_font {3:d}
Tf", r, g, b, font.pointSize());

used like

GooString * da = toAppearanceString(textFont, textColor);
pdfAnnot = new AnnotFreeText(destPage->getDoc(), &rect, da);
  ... or ...
ftextann->setAppearanceString(da);


Problem 2: Qt5 shouldn't care about low level DA parsing

QFont TextAnnotation::textFont() const    // existing code
...
  QString style = QString::fromLatin1( da->getCString() );
  // Qt5 shouldn't need to know how to parse Tf operator
  QRegExp rx(QStringLiteral("(\\d+)(\\.\\d*)? Tf")); 

and

QColor TextAnnotation::textColor() const  // new code
...
  QString style = QString::fromLatin1( da->getCString() );
  // Qt5 shouldn't need to know how to parse rg operator
  QRegExp rx(QStringLiteral("(\\d\\.\\d*) (\\d\\.\\d*) (\\d\\.\\d*) rg"));


Solution 1

Don't consume raw DA GooString in class AnnotFreeText, but take higher level
data

Instead of
  AnnotFreeText(PDFDoc *docA, PDFRectangle *rect, GooString *da);
  AnnotFreeText::setAppearanceString(GooString *new_string)

make it like

  struct AppearanceStringData {
    GooString *fontTag;
    int fontPtSize;
    AnnotColor* fontColor;
  };

  AnnotFreeText(PDFDoc *docA, PDFRectangle *rect, const AppearanceStringData&
apStr);
  AnnotFreeText::setAppearanceString(const AppearanceStringData& apStr);

and do all the low level stuff like Tf construction and invalidating appearance
in the changed AnnotFreeText methods.


Solution 2

Add a new method to class AnnotFreeText
  AnnotFreeText::getAppearanceString(AppearanceStringData& apStr) const;

Fill apStr with data from parseAppearanceString (protected function)
  static void parseAppearanceString(GooString *da, double &fontsize,
AnnotColor* &fontcolor);

How about it? Abert?

-- 
You are receiving this mail because:
You are the assignee for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/poppler-bugs/attachments/20180721/60746323/attachment.html>


More information about the Poppler-bugs mailing list