diff --git a/modules/ImageText.py b/modules/ImageText.py index 2abdd53..0f73694 100644 --- a/modules/ImageText.py +++ b/modules/ImageText.py @@ -215,6 +215,10 @@ def INPUT_TYPES(cls): "default": 0, "step": 1 }), + "spacing": ("INT", { + "default": 4, + "step": 1 + }), }, } @@ -222,7 +226,7 @@ def INPUT_TYPES(cls): FUNCTION = "node" CATEGORY = "image/draw" - def node(self, text, font, align, size, red, green, blue, alpha, margin_x, margin_y): + def node(self, text, font, align, size, red, green, blue, alpha, margin_x, margin_y, spacing): outline_size = 0 outline_red = 255 outline_green = 255 @@ -242,7 +246,8 @@ def node(self, text, font, align, size, red, green, blue, alpha, margin_x, margi outline_blue, alpha, margin_x, - margin_y + margin_y, + spacing ) @@ -309,6 +314,10 @@ def INPUT_TYPES(cls): "default": 0, "step": 1 }), + "spacing": ("INT", { + "default": 4, + "step": 1 + }), }, } @@ -318,7 +327,7 @@ def INPUT_TYPES(cls): def node( self, text, font, align, size, red, green, blue, outline_size, outline_red, outline_green, outline_blue, - alpha, margin_x, margin_y + alpha, margin_x, margin_y, spacing ): font_path = folder_paths.get_full_path("fonts", font) font = ImageFont.truetype(font_path, size, encoding="unic") @@ -328,7 +337,7 @@ def node( canvas = Image.new("RGBA", (0, 0)) draw = ImageDraw.Draw(canvas) - text_size = draw.multiline_textbbox((0, 0), text, font) + text_size = draw.multiline_textbbox((0, 0), text, font, spacing=spacing) canvas = Image.new("RGBA", ( text_size[2] + (margin_x + outline_size) * 2, @@ -341,7 +350,7 @@ def node( (margin_x + outline_size, margin_y + outline_size - top), text=text, fill=(red, green, blue, int(alpha * 255)), stroke_fill=(outline_red, outline_green, outline_blue, int(alpha * 255)), - stroke_width=outline_size, font=font, align=align + stroke_width=outline_size, font=font, align=align, spacing=spacing ) return (canvas.image_to_tensor().unsqueeze(0),)