From 55e470404372fbf922840bf696bd4fab0d20eac0 Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Tue, 23 Jun 2015 11:51:30 +0100 Subject: [PATCH] [E_B_D_T_] make extfile 'bitmaps' directory in same location as output file --- Lib/fontTools/ttLib/tables/E_B_D_T_.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Lib/fontTools/ttLib/tables/E_B_D_T_.py b/Lib/fontTools/ttLib/tables/E_B_D_T_.py index 2e42fc06c..2e0f6b25c 100644 --- a/Lib/fontTools/ttLib/tables/E_B_D_T_.py +++ b/Lib/fontTools/ttLib/tables/E_B_D_T_.py @@ -338,15 +338,20 @@ def _readBitwiseImageData(bitmapObject, name, attrs, content, ttFont): bitmapObject.setRows(dataRows, bitDepth=bitDepth, metrics=metrics, reverseBytes=True) def _writeExtFileImageData(strikeIndex, glyphName, bitmapObject, writer, ttFont): - folder = 'bitmaps/' + try: + folder = os.path.dirname(writer.file.name) + except AttributeError: + # fall back to current directory if output file's directory isn't found + folder = '.' + folder = os.path.join(folder, 'bitmaps') filename = glyphName + bitmapObject.fileExtension if not os.path.isdir(folder): os.makedirs(folder) - folder += 'strike%d/' % strikeIndex + folder = os.path.join(folder, 'strike%d' % strikeIndex) if not os.path.isdir(folder): os.makedirs(folder) - fullPath = folder + filename + fullPath = os.path.join(folder, filename) writer.simpletag('extfileimagedata', value=fullPath) writer.newline()