<html>
<head>
<base href="https://bugs.freedesktop.org/">
</head>
<body>
<p>
<div>
<b><a class="bz_bug_link
bz_status_NEW "
title="NEW - Add font color in Poppler"
href="https://bugs.freedesktop.org/show_bug.cgi?id=107151#c31">Comment # 31</a>
on <a class="bz_bug_link
bz_status_NEW "
title="NEW - Add font color in Poppler"
href="https://bugs.freedesktop.org/show_bug.cgi?id=107151">bug 107151</a>
from <span class="vcard"><a class="email" href="mailto:haxtibal@posteo.de" title="Tobias Deiminger <haxtibal@posteo.de>"> <span class="fn">Tobias Deiminger</span></a>
</span></b>
<pre>Comment on <span class=""><a href="attachment.cgi?id=141142" name="attach_141142" title="new version of the patch">attachment 141142</a> <a href="attachment.cgi?id=141142&action=edit" title="new version of the patch">[details]</a></span> <a href='page.cgi?id=splinter.html&bug=107151&attachment=141142'>[review]</a>
new version of the patch
Review of <span class=""><a href="attachment.cgi?id=141142" name="attach_141142" title="new version of the patch">attachment 141142</a> <a href="attachment.cgi?id=141142&action=edit" title="new version of the patch">[details]</a></span> <a href='page.cgi?id=splinter.html&bug=107151&attachment=141142'>[review]</a>:
-----------------------------------------------------------------
::: poppler/Annot.cc
@@ +2820,5 @@
<span class="quote">> +DefaultAppearance *AnnotFreeText::getDefaultAppearance() const {
> + double fontSize;
> + AnnotColor *fontColor;
> + GooString *fontTag;
> + parseAppearanceString(appearanceString, fontSize, fontColor, fontTag);</span >
parseAppearanceString(..., GooString** fontTag) would be nice, IMO. Then we can
call it as
parseAppearanceString(appearanceString, fontSize, fontColor, nullptr);
and avoid the superfluous new/delete of fontTag
@@ +2844,5 @@
<span class="quote">> return GfxFont::makeFont(xref, "AnnotDrawFont", dummyRef, fontDict);
> }
>
> +GooString *AnnotFreeText::constructAppearanceString(const GooString &fontTag, double fontSize, const AnnotColor *fontColor) {
> + const double *colorData = fontColor->getValues();</span >
As Albert noted, fontColor may be null here (see call from
AnnotFreeText::AnnotFreeText). That's still a potential segfault. We can either
check for fontColor == nullptr and make writing color optional. Or enforce a
fontColor value by changing the signature to const AnnotColor &fontColor, and
adapt all calling locations.
@@ +2861,5 @@
<span class="quote">> + case AnnotColor::AnnotColorSpace::colorCMYK: //=4
> + cstr = GooString::format("{0:.2f} {1:.2f} {2:.2f} {3:.2f} k ", colorData[0], colorData[1], colorData[2], colorData[3]);
> + break;
> + }
> + const GooString * str = GooString::format("/{0:s} {1:.2f} Tf", &fontTag, fontSize);</span >
That's where I meant we could use AnnotAppearanceBuilder instead of raw
GooString::format.
::: poppler/Annot.h
@@ +358,5 @@
<span class="quote">> + const GooString &getFontTag() const { return *fontTag; }
> + int getFontPtSize() const { return fontPtSize; }
> + const AnnotColor *getFontColor() const { return fontColor; }
> + ~DefaultAppearance();
> + DefaultAppearance(DefaultAppearance &ger) = delete;</span >
As Albert suggested, also delete the copy assignment operator here:
DefaultAppearance& operator=(const DefaultAppearance&) = delete;
The "ger" in copy Ctor is superfluous, type alone is enough. But that's
probably a matter of taste.
@@ +997,4 @@
<span class="quote">> Object getAppearanceResDict() override;
> void setContents(GooString *new_content) override;
>
> + void setAppearanceString(const DefaultAppearance &da);</span >
Rename to setDefaultAppearance (as we seem to agree about name now)</pre>
</div>
</p>
<hr>
<span>You are receiving this mail because:</span>
<ul>
<li>You are the assignee for the bug.</li>
</ul>
</body>
</html>