Reputation: 1
I want a stroke around the text, but when I use the built-in parameters of the text function, the border has rounded edges. I want the border to have sharp, cornered edges instead.
I want sharp edges like those in the attached image:
font = ImageFont.truetype(font_family_path, font_size)
temp_image = Image.new('RGBA', (1, 1), (0, 0, 0, 0))
(https://i.sstatic.net/mLETp0ZD.png)
[In the above attached image link, you can see that currently, I have a stroke with rounded corners, but I want the border to have sharp edges.,]
draw = ImageDraw.Draw(temp_image)
bbox = draw.textbbox((0, 0), name, font=font)
text_width = bbox[2] - bbox[0]
text_height = bbox[3] - bbox[1]
image = Image.new('RGBA', (width, height), (0, 0, 0, 0))
draw = ImageDraw.Draw(image)
text_x = (width - text_width) / 2
text_y = (height - text_height) / 2 - (bbox[1] - 0)
draw.text((text_x, text_y), name, font=font, fill=(r, g, b),stroke_width=outline_width, stroke_fill=(stroke_r ,stroke_g, stroke_b))
Upvotes: 0
Views: 38