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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions omero_figure/scripts/omero/figure_scripts/Figure_To_Pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,7 @@ def draw_shape_label(self, shape, bounds):
return
r, g, b, a = self.get_rgba_int(shape['strokeColor'])
# bump up alpha a bit to make text more readable
rgba = (r, g, b, 128 + a / 2)
rgba = (r, g, b, int(128 + a / 2))
font_name = "FreeSans.ttf"
from omero.gateway import THISPATH
path_to_font = os.path.join(THISPATH, "pilfonts", font_name)
Expand All @@ -576,7 +576,7 @@ def draw_shape_label(self, shape, bounds):
box = font.getbbox(text)
width = box[2] - box[0]
height = box[3] - box[1]
xy = (center[0] - width / 2.0, center[1] - height / 2.0)
xy = (int(center[0] - width / 2.0), int(center[1] - height / 2.0))
self.draw.text(xy, text, fill=rgba, font=font)

def draw_arrow(self, shape):
Expand Down Expand Up @@ -2275,7 +2275,7 @@ def draw_temp_label(self, text, fontsize, rgb):
box = font.getbbox(t['text'])
txt_w = box[2] - box[0]
txt_h = box[3] - box[1]
textdraw.text((w, 0), t['text'], font=font, fill=rgb)
textdraw.text((w, -box[1]), t['text'], font=font, fill=rgb)
w += txt_w
return temp_label

Expand Down