Skip to content

Commit

Permalink
featureCompiler: simplify logic for MTI_FEATURES_PREFIX and os.path.sep
Browse files Browse the repository at this point in the history
  • Loading branch information
anthrotype committed Nov 1, 2018
1 parent 924cb51 commit 44f3199
Showing 1 changed file with 3 additions and 15 deletions.
18 changes: 3 additions & 15 deletions Lib/ufo2ft/featureCompiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -271,25 +271,13 @@ class MtiFeatureCompiler(BaseFeatureCompiler):
fontTools.mtiLib.
"""

def __init__(self, ufo, ttFont=None, glyphSet=None, **kwargs):
super(MtiFeatureCompiler, self).__init__(
ufo, ttFont=ttFont, glyphSet=glyphSet, **kwargs
)
# defcon (as of 0.5.3) lists UFO data filenames using platform-specific
# path separators, whereas the new fontTools.ufoLib uses `fs` module
# internally which always requires UNIX forward slashes on all platforms
if hasattr(ufo, "reader") and hasattr(ufo.reader, "fs"):
sep = "/"
else:
sep = os.path.sep
self._mti_features_prefix = MTI_FEATURES_PREFIX + sep

def setupFeatures(self):
ufo = self.ufo
features = {}
prefixLength = len(self._mti_features_prefix)
# includes the length of the "/" separator
prefixLength = len(MTI_FEATURES_PREFIX) + 1
for fn in ufo.data.fileNames:
if fn.startswith(self._mti_features_prefix) and fn.endswith(".mti"):
if fn.startswith(MTI_FEATURES_PREFIX) and fn.endswith(".mti"):
content = tounicode(ufo.data[fn], encoding="utf-8")
features[fn[prefixLength:-4]] = content
self.mtiFeatures = features
Expand Down

0 comments on commit 44f3199

Please sign in to comment.