Created
January 1, 2018 18:18
-
-
Save dag05ru/4205712cfa6e485d7f2c3f80dc95ca77 to your computer and use it in GitHub Desktop.
create bmp files from ttf file
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from PIL import Image, ImageFont, ImageDraw | |
import sys | |
from encodings import koi8_r | |
font_path = sys.argv[1] | |
char_size = int(sys.argv[2]) | |
def create_image(ch, image_name, font_path, font_size): | |
image = Image.new(mode='RGB', size=[char_size, char_size], color=(0xff, 0xff, 0xff)) | |
draw = ImageDraw.Draw(image) | |
font = ImageFont.truetype(font_path, font_size) | |
draw.text((0, 0), ch, font=font, fill=(0, 0, 0)) | |
image.save(image_name) | |
for i in range(0xff): | |
create_image(koi8_r.decoding_table[i], str(i)+".bmp", font_path, char_size) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment