Fix cropping of panel labels and float usage for shape labels #548
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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: