ome / omero-figure

An OMERO.web app for creating Figures from images in OMERO
http://figure.openmicroscopy.org
GNU Affero General Public License v3.0
15 stars 30 forks source link

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

Closed will-moore closed 2 months ago

will-moore commented 3 months ago

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:

pwalczysko commented 2 months ago

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