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:
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:
Original figure:
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
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 usingheight = x2 - x
but since the pasting atx = 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:
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:
Original figure:
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 @knabarTo test: