Login
main >   printed_text >  


Build Dataset of electronic fonts.
Downloaded fonts. ttf, otf

from PIL import Image,ImageDraw,ImageFont

output_text = 'B'

font = ImageFont.truetype("AachenEF-Medium.otf", 35, encoding="unic")
#font = ImageFont.load("font.bmp")

# get the line size
text_width, text_height = font.getsize(output_text)

# create a blank canvas with extra space between lines
canvas = Image.new('RGB', (text_width, text_height), "white")

# draw the text onto the text canvas, and use black as the text color
draw = ImageDraw.Draw(canvas)
draw.text((0,0), output_text, 'black', font)

# save the blank canvas to a file
canvas.save("{}.png".format(output_text), "PNG")
hidden1

hidden2