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

View File

@ -58,6 +58,7 @@ import re
from fontTools.ttLib import TTFont from fontTools.ttLib import TTFont
from fontTools.ttLib.tables.otBase import OTLOffsetOverflowError from fontTools.ttLib.tables.otBase import OTLOffsetOverflowError
from fontTools.ttLib.tables.otTables import fixLookupOverFlows, fixSubTableOverFlows from fontTools.ttLib.tables.otTables import fixLookupOverFlows, fixSubTableOverFlows
from fontTools.misc.macCreatorType import getMacCreatorAndType
from fontTools import version from fontTools import version
def usage(): def usage():
@ -65,12 +66,6 @@ def usage():
sys.exit(2) 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+$") numberAddedRE = re.compile("(.*)#\d+$")
def makeOutputFileName(input, outputDir, extension): def makeOutputFileName(input, outputDir, extension):
@ -218,17 +213,11 @@ def guessFileType(fileName):
f = open(fileName, "rb") f = open(fileName, "rb")
except IOError: except IOError:
return None return None
if not have_broken_macsupport: cr, tp = getMacCreatorAndType(fileName)
try: if tp in ("sfnt", "FFIL"):
import MacOS return "TTF"
except ImportError: if ext == ".dfont":
pass return "TTF"
else:
cr, tp = MacOS.GetCreatorAndType(fileName)
if tp in ("sfnt", "FFIL"):
return "TTF"
if ext == ".dfont":
return "TTF"
header = f.read(256) header = f.read(256)
head = header[:4] head = header[:4]
if head == "OTTO": if head == "OTTO":