Skip to content

Commit

Permalink
add file extention check
Browse files Browse the repository at this point in the history
---
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 <[email protected]>*
  • Loading branch information
sjang42 committed Oct 12, 2017
1 parent 1cc9d49 commit c8c4c23
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ttf-to-jpg.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)"
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit c8c4c23

Please sign in to comment.