Skip to content

Turn the ink a quarter turn on a landscape page - #483

Open
giovi321 wants to merge 1 commit into
ddvk:masterfrom
giovi321:fix-landscape-rotation
Open

giovi321 wants to merge 1 commit into
ddvk:masterfrom
giovi321:fix-landscape-rotation

Conversation

@giovi321

Copy link
Copy Markdown

Fixes #286, which has been open since January 2024.

A landscape page does not fit a portrait screen the right way up, so the device turns it a quarter turn: the page's width then runs along the long side of the screen, and the ink is written turned with it. The renderer draws that ink straight, so annotations on any landscape document come out sideways and mostly off the page.

The thread on #286 stalled on whether the firmware supported landscape at all. It does, and this is a renderer bug, not a device one.

How it was worked out

Plotting the raw stroke coordinates of a page into the screen's own 1404x1872 frame shows the handwriting reading sideways, which is the whole diagnosis. Turning it gives one uniform scale, the page width over the screen's long side: 0.5143 points per pixel across and 0.5146 down on a 960x540 page. Two axes agreeing to three decimal places is what says the model is right rather than fitted.

Checked against the same page exported by the tablet itself:

ink, in page points
tablet's own export x 302.0..895.3, y 116.7 from the top
this change x 302.7..894.0, y 117.3 from the top

The tablet grows the sheet to take in writing past the page edge, which is why its ink carries on past where this clips.

The change

pageTransform carries how a page is laid out rather than a bare scale, so the turned and unturned cases sit next to each other instead of inside a ratio test. Portrait pages keep exactly the scale they had, so nothing changes for them. The highlighter, which is drawn as one straight swipe, is flattened along whichever way the page runs.

Something to know when you test this

Verifying it is harder than it should be because of #228: the exporter pairs the nth annotated page with background page n, rather than with the page the ink belongs to. On the 28 page document I used, page 8's ink is drawn over background page 3. So a landscape document will still look wrong after this change, for that separate reason. I measured the ink position rather than trusting the rendered page, which is why the numbers above are ink bounding boxes and not screenshots.

That second bug is not addressed here.

A landscape page does not fit a portrait screen the right way up, so the
device turns it: the page's width runs along the long side of the screen
and the ink is written turned with it. The renderer draws that ink
straight, which puts annotations sideways on every landscape document.
Reported in ddvk#286.

Worked out by plotting the raw stroke coordinates of a page into the
screen's own 1404x1872 frame, where the handwriting reads sideways, and
checked against the same page exported by the tablet itself. Turning it
gives one uniform scale, the page width over the screen's long side:
0.5143 points per pixel across and 0.5146 down on a 960x540 page.

On that page the tablet puts the ink at x 302.0..895.3, y 116.7 down from
the top. With this it lands at x 302.7..894.0, y 117.3. The tablet grows
the sheet to take in writing past the page edge, which is why its ink
carries on past where this clips.

pageTransform carries how a page is laid out rather than a bare scale, so
the turned and unturned cases sit side by side instead of inside a ratio
test. Portrait pages keep the scale they had.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PDF rendering is rendering landscape PDFs wrong direction

1 participant