Make poppler scale text annotation icons to respect size in /Rect

Make poppler scale text annotation icons to respect size in /Rect

diff --git a/poppler/Annot.cc b/poppler/Annot.cc
index 7f249d5a..f5c080fe 100644
--- a/poppler/Annot.cc
+++ b/poppler/Annot.cc
@@ -2466,11 +2466,8 @@ void AnnotText::draw(Gfx *gfx, GBool printing) {
appearBuf->append (ANNOT_TEXT_AP_CIRCLE);
appearBuf->append ("Q\n");
- // Force 24x24 rectangle
- PDFRectangle fixedRect(rect->x1, rect->y2 - 24, rect->x1 + 24, rect->y2);
- appearBBox = new AnnotAppearanceBBox(&fixedRect);
- double bbox[4];
- appearBBox->getBBoxRect(bbox);
+ // AP_* are originally drawn in a rectangle of 24 x 24 units
+ double bbox[4] = {0, 0, 24., 24.};
if (ca == 1) {
appearance = createForm(bbox, gFalse, nullptr);
} else {
@@ -2485,16 +2482,11 @@ void AnnotText::draw(Gfx *gfx, GBool printing) {
}
// draw the appearance stream
+ // 1 x units in AP_* will be scaled with sx = rect->x2 - rect->x1
+ // 1 y units in AP_* will be scaled with sy = rect->y2 - rect->y1
Object obj = appearance.fetch(gfx->getXRef());
- if (appearBBox) {
- gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color,
- appearBBox->getPageXMin(), appearBBox->getPageYMin(),
- appearBBox->getPageXMax(), appearBBox->getPageYMax(),
- getRotation());
- } else {
- gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color,
- rect->x1, rect->y1, rect->x2, rect->y2, getRotation());
- }
+ gfx->drawAnnot(&obj, (AnnotBorder *)NULL, color,
+ rect->x1, rect->y1, rect->x2, rect->y2, getRotation());
}
//------------------------------------------------------------------------

This is a demonstration how BUG 387639, BUG 388458 and D9615 can be solved by poppler. If applied, poppler draws text annotation icons according to what was set in Poppler::Annotation::setBoundary, or what's defined in /Rect (in the case of an external PDF writer). It works because the transformation matrix in Gfx::drawAnnot gets prepared so that 24 x units from the appearance stream will become width = x2 - x1 units from the /Rect. The patch should apply to current poppler master.

The comments in the patch should be as follows. How can I edit the attached file?

// 1 x units in AP_* will be scaled with sx = (rect->x2 - rect->x1) / 24
// 1 y units in AP_* will be scaled with sy = (rect->y2 - rect->y1) / 24
rkflx added a subscriber: rkflx.EditedJan 5 2018, 7:52 PM

In Phabricator's side bar there is Edit File, you could try if this (possibly?) works for you.

One can only change Name, Visible To, Subscribers in Edit File. But no file content. And I guess that's ok, I should not try to abuse the file app as a code review tool for external projects code.

Another thing just noted: When trying to edit my comment (with Firefox 57.0.3) and pressing Save Changes, nothing happens at all. If I open the the comment dialogue in a new tab and press Save Changes, an unhandled exception is shown: "Attempting to apply a transaction (of class "PhabricatorFileTransaction", with type "core:edge") which has not been constructed correctly: Transaction has type "core:edge", but that transaction type is not supported by this editor (PhabricatorFileEditor)."

rkflx added a comment.Jan 5 2018, 11:02 PM

One can only change Name, Visible To, Subscribers in Edit File. But no file content. And I guess that's ok, I should not try to abuse the file app as a code review tool for external projects code.

Oops, you are right – sorry. Then the only thing you can do is to upload a new file (drop it in your browser or via arc upload) and change the reference.

When trying to edit my comment (with Firefox 57.0.3) and pressing Save Changes, nothing happens at all.

Just tried it in Firefox and Chromium: Works fine in both, meaning the problem was either a temporary glitch or is an configuration/addon issue on your side (cookies, referer etc. – for me in some "special" browser profiles certain features of Phab do not work, e.g. DifferentialEdit QuerySearch throws an exception. Try it with a fresh profile, or debug the network queries via F12.)

For general problems with Phab you could also open a sysadmin ticket.

rkflx added a comment.Jan 7 2018, 9:44 PM
In F5620896#78, @rkflx wrote:

In Phabricator's side bar there is Edit File, you could try if this (possibly?) works for you.

(Meta)

Here's how you can make this work: Use arc paste or https://phabricator.kde.org/paste/, then you'll get editing capabilities, a Nom Nom Nom Nom Nom button and even syntax highlighting.

I knew there was a way ;)