mirror of
https://github.com/rsms/inter.git
synced 2024-11-23 20:55:33 +03:00
30 lines
616 B
Python
30 lines
616 B
Python
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)
|