Accept float stroke widths by radarhere · Pull Request #8369 · python-pillow/Pillow

When instructing FreeType of the stroke width, we multiply the number of pixels by 64.

So there's no reason why stroke widths couldn't be more precise than an integer number of pixels, and instead going down to 1/64th of a pixel.

To demonstrate, here's a progression from no stroke to 1px stroke width.

from PIL import Image, ImageDraw, ImageFont

im = Image.new("RGB", (360, 120))
d = ImageDraw.Draw(im)
font = ImageFont.load_default(size=100)
d.text((5, 0), "A", font=font, fill="#f00")
d.text((75, 0), "A", font=font, fill="#f00", stroke_fill="#0f0", stroke_width=0.25)
d.text((145, 0), "A", font=font, fill="#f00", stroke_fill="#0f0", stroke_width=0.5)
d.text((215, 0), "A", font=font, fill="#f00", stroke_fill="#0f0", stroke_width=0.75)
d.text((285, 0), "A", font=font, fill="#f00", stroke_fill="#0f0", stroke_width=1)

im.save("out.png")