From c8c4c231c3b0425574e7fc70e2049197f07c2898 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E1=84=8C=E1=85=A1=E1=86=BC=E1=84=89=E1=85=A1=E1=86=BC?= =?UTF-8?q?=E1=84=92=E1=85=A7=E1=86=AB?= Date: Fri, 13 Oct 2017 02:40:51 +0900 Subject: [PATCH] add file extention check --- Redmine Issue Progress / ID / Time : 100% #44 @1h --- What : 1. add font extention list .ttf, .otf, .ttc 2. add code checking if file is in the font extention list Why : to ignore not font file --- *Signed-off-by: sjang42 * --- ttf-to-jpg.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ttf-to-jpg.py b/ttf-to-jpg.py index 2c0565c..ce25e93 100644 --- a/ttf-to-jpg.py +++ b/ttf-to-jpg.py @@ -5,6 +5,7 @@ from PIL import ImageDraw from PIL import ImageFont +FONT_EXTENTION = ['.ttf', '.otf', '.ttc'] def parse_args(): desc = "ttf/otf fonts to jpg images set (JUST KOREAN)" @@ -44,6 +45,11 @@ def main(): for _, _, ttfs in os.walk(ttf_dir): for ttf in ttfs: + # check extention type of file and continue if it is not font file + ext = os.path.splitext(ttf)[-1] + if ext not in FONT_EXTENTION: + continue + font = ImageFont.truetype(ttf_dir + '/' + ttf, size=char_size) count = 0 for c in charset: