Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix cropping of panel labels and float usage for shape labels #548

Merged
merged 1 commit into from
Apr 14, 2024

Conversation

will-moore
Copy link
Member

@will-moore will-moore commented Mar 12, 2024

Since we updated to use x, y, x2, y2 = font.getbbox(text) to get the height of text, the labels that are pasted on to the temporary canvas of that height are cropped at the bottom. We have removed the margin by using height = x2 - x but since the pasting at x = 0 actually pastes with the margin (so the canvas is not big enough).

If we set the temporary canvas to grey for each label for debugging, we can see this effect more clearly:

Screenshot 2024-03-12 at 13 09 47

In order to paste right at the top of the temp canvas (without the margin), we need to set the x coordinate to be negative margin:

This also positions the text the same as in the original figure:

Screenshot 2024-03-12 at 13 19 51

Original figure:

Screenshot 2024-03-12 at 13 21 33

NB: I also tested the export of shape labels (shown in 2nd screenshot above) which didn't need a fix to the font.getbbox() logic, but did need some casting of floats to ints. Shape labels aren't supported by vanilla OMERO.figure - I think they were added to the export script by Glencoe, so the only way to test that is to add "text": "some text" to the Shape JSON. cc @knabar

To test:

  • Add labels to a Figure (including with markdown italics and bold) and export as TIFF - check that they are not cropped in the TIFF

@will-moore will-moore requested a review from jburel March 22, 2024 13:19
@will-moore will-moore requested a review from pwalczysko April 12, 2024 12:12
@pwalczysko
Copy link
Member

compare the same figure on demo (without this pr)
Screenshot 2024-04-12 at 14 04 17

and on merge-ci (with this PR)
Screenshot 2024-04-12 at 14 04 11

lgtm

@will-moore will-moore merged commit ded0caa into ome:master Apr 14, 2024
1 check passed
@will-moore will-moore added this to the 6.2.1 milestone Apr 19, 2024
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.

2 participants