Draw bold/italic text with PIL? Draw bold/italic text with PIL? python python

Draw bold/italic text with PIL?


A rather hacky solution to make a font bold if (for whatever reason) you don't have a separate bold version of the font is to print the same text several times with a slight offset.

andaleMono = ImageFont.truetype(ANDALE_MONO_PATH,16)text = "hello world"mainOffset = (50,50)xoff, yoff = mainOffsetdraw.text(mainOffset,text,font=andaleMono,fill='black')draw.text((xoff+1,yoff+1),text,font=andaleMono,fill='black')draw.text((xoff-1,yoff-1),text,font=andaleMono,fill='black')


Many fonts use different TTF files for their bold/italic versions, so I'd imagine if you just specify that file it would work.