1
1
mirror of https://github.com/rsms/inter.git synced 2024-10-26 12:39:40 +03:00
inter/misc/fontbuildlib/util.py

30 lines
616 B
Python
Raw Normal View History

import sys
import os
import errno
from fontTools.ttLib import TTFont
from os.path import dirname, abspath, join as pjoin
PYVER = sys.version_info[0]
BASEDIR = abspath(pjoin(dirname(__file__), os.pardir, os.pardir))
_enc_kwargs = {}
if PYVER >= 3:
_enc_kwargs = {'encoding': 'utf-8'}
def readTextFile(filename):
with open(filename, 'r', **_enc_kwargs) as f:
return f.read()
def mkdirs(path):
try:
os.makedirs(path)
except OSError as e:
if e.errno != errno.EEXIST:
raise # raises the error again
def loadTTFont(file):
return TTFont(file, recalcBBoxes=False, recalcTimestamp=False)