
#ARIAL BLACK OUTLINE FONT HOW TO#
The problem that I found with that solution is about how to create a smooth border on larger border size. In that case, I create this proposal method based on Alec Bennett solution.

I was looking for that on the internet and I saw that PIL doesn't have native support to add text border. W, h = font.getsize(text, stroke_width=stroke_width) Xy(tuple): absolute top left location of subtitleįont = uetype(str(font), font_size) #!/usr/bin/env pythonįrom PIL import Image, ImageDraw, ImageFont Bellow is an example to add subtitle to image. For shadow effect, you can draw with a small offset. TxtWidth, txtHeight = draw.textsize(text, font=font)ĭraw.text((x-adj, y), text, font=font, fill=shadowColor)ĭraw.text((x+adj, y), text, font=font, fill=shadowColor)ĭraw.text((x, y+adj), text, font=font, fill=shadowColor)ĭraw.text((x, y-adj), text, font=font, fill=shadowColor)ĭraw.text((x-adj, y+adj), text, font=font, fill=shadowColor)ĭraw.text((x+adj, y+adj), text, font=font, fill=shadowColor)ĭraw.text((x-adj, y-adj), text, font=font, fill=shadowColor)ĭraw.text((x+adj, y-adj), text, font=font, fill=shadowColor)ĭraw.text((x,y), text, font=font, fill=textColor)Ĭheck the stroke_width option, which implements stroke/border/outline effect. from PIL import Image,ImageDraw,ImageFontįont = uetype("arial.ttf", 30) Just a heads up if you start to push this too far for the thickness, then you will need more draws to cover your areas you're missing. This is how I handled the problem when I needed to do it for frame counters. If font.getsize(meme_text) <= width_image: Writeimg = Image.open("frameinstance" + str(i) + ".png")įont = uetype("impact.ttf", font_size)
#ARIAL BLACK OUTLINE FONT CODE#
The section of code that deals with drawing on the images: for i in range(0,max_frame_int + 1):

Is there a way to accomplish this with PIL? If not, I am open to hearing other suggestions, but no promises because I've already begun a large project in python using PIL. This is what I have: as you can see, if the background is white it is difficult to read. I was able to get the font I wanted, but I'd like to now outline the text in black. I'm using python/PIL to write text on a set of PNG images.
