#!/usr/bin/env python
# coding: utf-8

from __future__ import print_function

import argparse
import os
import sys
sys.path.append(os.path.dirname(os.path.abspath(os.path.dirname(sys.argv[0]))))

from scripts import font2ttf

parser = argparse.ArgumentParser()
parser.add_argument('--with-otf', action="store_true",
                    help='Generate otf file')
parser.add_argument('source', nargs='+', type=str)

args = parser.parse_args()

for src in args.source:
    if not os.path.exists(src):
        print('\nError: {} does not exists\n'.format(src), file=sys.stderr)
        continue

    basename, _ = os.path.splitext(src)

    otffile = None
    if args.with_otf:
        otffile = '{}.otf'.format(basename)

    font2ttf.convert(src, '{}.ttf'.format(basename), otffile)
