Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Lib/mutatorMath/test/ufo/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,13 @@ def test1():
# test build function -- single designspace file
>>> from mutatorMath.ufo import build
>>> import os
>>> import posixpath
>>> here = os.path.join(os.path.dirname(__file__), 'data', 'exporttest_basic.designspace')
>>> results = build(here, outputUFOFormatVersion=2)
>>> ufoFullPath = results[0]['testOutput_glyphs.ufo']
>>> ufoRelPath = os.path.relpath(ufoFullPath, os.path.dirname(__file__))
>>> ufoRelPath
>>> posixRelPath = posixpath.join(*ufoRelPath.split(os.path.sep))
>>> posixRelPath
'data/instances/A/testOutput_glyphs.ufo'

# test the axes elements
Expand Down
11 changes: 7 additions & 4 deletions Lib/mutatorMath/ufo/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from __future__ import print_function
import logging
import os
import posixpath
import xml.etree.ElementTree as ET

import defcon
Expand Down Expand Up @@ -96,6 +97,10 @@ def _makeLocationElement(self, locationObject, name=None):
locElement.append(dimElement)
return locElement

def _posixPathRelativeToDocument(self, otherPath):
relative = os.path.relpath(otherPath, os.path.dirname(self.path))
return posixpath.join(*relative.split(os.path.sep))

def addSource(self,
path,
name,
Expand Down Expand Up @@ -127,8 +132,7 @@ def addSource(self,
Note: no separate flag for mute font: the source is just not added.
"""
sourceElement = ET.Element("source")
pathRelativeToDocument = os.path.relpath(path, os.path.dirname(self.path))
sourceElement.attrib['filename'] = pathRelativeToDocument
sourceElement.attrib['filename'] = self._posixPathRelativeToDocument(path)
sourceElement.attrib['name'] = name
if copyLib:
libElement = ET.Element('lib')
Expand Down Expand Up @@ -214,8 +218,7 @@ def startInstance(self, name=None,
if styleName is not None:
instanceElement.attrib['stylename'] = styleName
if fileName is not None:
pathRelativeToDocument = os.path.relpath(fileName, os.path.dirname(self.path))
instanceElement.attrib['filename'] = pathRelativeToDocument
instanceElement.attrib['filename'] = self._posixPathRelativeToDocument(fileName)
if postScriptFontName is not None:
instanceElement.attrib['postscriptfontname'] = postScriptFontName
if styleMapFamilyName is not None:
Expand Down