- removed support for Python 2.2 on MacOS 10.2

- worked around a bug in GetCreatorType() on intel Macs


git-svn-id: svn://svn.code.sf.net/p/fonttools/code/trunk@526 4cde692c-a291-49d1-8350-778aa11640f8
This commit is contained in:
jvr 2008-03-01 11:34:54 +00:00
parent 1bcc11dcf6
commit 45d1f3b3b5
3 changed files with 43 additions and 25 deletions

View File

@ -0,0 +1,33 @@
import sys
try:
import MacOS
except ImportError:
MacOS = None
def _reverseString(s):
s = list(s)
s.reverse()
return "".join(s)
def getMacCreatorAndType(path):
if MacOS is not None:
fileCreator, fileType = MacOS.GetCreatorAndType(path)
if sys.byteorder == "little":
# work around bug in MacOS.GetCreatorAndType() on intel:
# http://bugs.python.org/issue1594
fileCreator = _reverseString(fileCreator)
fileType = _reverseString(fileType)
return fileCreator, fileType
else:
return None, None
def setMacCreatorAndType(path, fileCreator, fileType):
if MacOS is not None:
if sys.byteorder == "little":
# work around bug in MacOS.SetCreatorAndType() on intel:
# http://bugs.python.org/issue1594
fileCreator = _reverseString(fileCreator)
fileType = _reverseString(fileType)
MacOS.SetCreatorAndType(path, fileCreator, fileType)

View File

@ -21,6 +21,7 @@ __version__ = "1.0b2"
DEBUG = 0
from fontTools.misc import eexec
from fontTools.misc.macCreatorType import getMacCreatorAndType
import string
import re
import os
@ -102,8 +103,7 @@ class T1Font:
def read(path, onlyHeader=0):
"""reads any Type 1 font file, returns raw data"""
normpath = string.lower(path)
if haveMacSupport:
creator, type = MacOS.GetCreatorAndType(path)
creator, type = getMacCreatorAndType(path)
if type == 'LWFN':
return readLWFN(path, onlyHeader), 'LWFN'
if normpath[-4:] == '.pfb':
@ -252,8 +252,6 @@ def writePFB(path, data):
f.write(chr(128) + chr(3))
finally:
f.close()
if haveMacSupport:
MacOS.SetCreatorAndType(path, 'mdos', 'BINA')
def writeOther(path, data, dohex = 0):
chunks = findEncryptedChunks(data)
@ -274,8 +272,6 @@ def writeOther(path, data, dohex = 0):
f.write(chunk)
finally:
f.close()
if haveMacSupport:
MacOS.SetCreatorAndType(path, 'R*ch', 'TEXT') # BBEdit text file
# decryption tools

View File

@ -58,6 +58,7 @@ import re
from fontTools.ttLib import TTFont
from fontTools.ttLib.tables.otBase import OTLOffsetOverflowError
from fontTools.ttLib.tables.otTables import fixLookupOverFlows, fixSubTableOverFlows
from fontTools.misc.macCreatorType import getMacCreatorAndType
from fontTools import version
def usage():
@ -65,12 +66,6 @@ def usage():
sys.exit(2)
if sys.platform == "darwin" and sys.version_info[:3] == (2, 2, 0):
# the Mac support of Jaguar's Python 2.2 is broken
have_broken_macsupport = 1
else:
have_broken_macsupport = 0
numberAddedRE = re.compile("(.*)#\d+$")
def makeOutputFileName(input, outputDir, extension):
@ -218,13 +213,7 @@ def guessFileType(fileName):
f = open(fileName, "rb")
except IOError:
return None
if not have_broken_macsupport:
try:
import MacOS
except ImportError:
pass
else:
cr, tp = MacOS.GetCreatorAndType(fileName)
cr, tp = getMacCreatorAndType(fileName)
if tp in ("sfnt", "FFIL"):
return "TTF"
if ext == ".dfont":