コード例 #1
0
def readGlyphsFile(filePath):
    print "Import Glyphs File"
    pool = NSAutoreleasePool.alloc().init()
    GlyphsDoc = NSDictionary.alloc().initWithContentsOfFile_(filePath)

    loadGlyphsInfo()
    from FL import fl, Font
    folder, base = os.path.split(filePath)
    base = base.replace(".glyphs", ".vfb")
    dest = os.path.join(folder, base)
    f = Font()
    fl.Add(f)
    global convertName
    try:
        convertName = GlyphsDoc["disablesNiceNames"] != None
    except:
        pass
    if not setFontInfo(f, GlyphsDoc):
        return False
    readGlyphs(f, GlyphsDoc)
    readKerning(f, GlyphsDoc)
    setLegacyNames(f)
    readFeatures(f, GlyphsDoc)

    fl.UpdateFont()
    f.modified = 0
    pool.drain()
コード例 #2
0
def readGlyphsFile(filePath):
	print "Import Glyphs File"
	pool = NSAutoreleasePool.alloc().init()
	GlyphsDoc = NSDictionary.alloc().initWithContentsOfFile_(filePath)
	if GlyphsDoc is None:
		print "Could not load .glyphs file."
		pool.drain()
		return
	loadGlyphsInfo()
	from FL import fl, Font
	folder, base = os.path.split(filePath)
	base = base.replace(".glyphs", ".vfb")
	dest = os.path.join(folder, base)
	f = Font(  )
	fl.Add(f)
	global convertName
	try:
		convertName = GlyphsDoc["disablesNiceNames"] != None
	except:
		pass
	if not setFontInfo(f, GlyphsDoc):
		return False
	readGlyphs(f, GlyphsDoc)
	readKerning(f, GlyphsDoc)
	setLegacyNames(f)
	readFeatures(f, GlyphsDoc)
	
	fl.UpdateFont()
	f.modified = 0
	pool.drain()
コード例 #3
0
def readGlyphsFile(filePath):
    print "Import Glyphs File"
    pool = None
    try:
        from Foundation import NSAutoreleasePool, NSDictionary
    except ImportError:
        # on Windows, PyObjC is not available
        with open(filePath, "rb") as f:
            data = f.read()
        if data.startswith("<?xml"):
            # use the built-in plistlib module for XML plist
            from plistlib import readPlistFromString

            GlyphsDoc = readPlistFromString(data)
        else:
            # use glyphsLib's Parser for ASCII plist.
            # Download it from: https://github.com/googlei18n/glyphsLib
            from glyphsLib.parser import Parser

            GlyphsDoc = Parser(dict_type=dict).parse(data)
    else:
        # on OS X, use NSDictionary
        pool = NSAutoreleasePool.alloc().init()
        GlyphsDoc = NSDictionary.alloc().initWithContentsOfFile_(filePath)

    if not GlyphsDoc:
        print "Could not load .glyphs file."
        if pool:
            pool.drain()
        return

    from FL import fl, Font

    folder, base = os.path.split(filePath)
    base = base.replace(".glyphs", ".vfb")
    dest = os.path.join(folder, base)
    f = Font()
    fl.Add(f)
    global convertName
    try:
        convertName = GlyphsDoc["disablesNiceNames"] != None
    except:
        pass
    if not setFontInfo(f, GlyphsDoc):
        return False
    readGlyphs(f, GlyphsDoc)
    readKerning(f, GlyphsDoc)
    setLegacyNames(f)
    readFeatures(f, GlyphsDoc)

    fl.UpdateFont()
    f.modified = 0
    if pool:
        pool.drain()
コード例 #4
0
def readGlyphsFile(filePath):
	print "Import Glyphs File"
	pool = None
	try:
		from Foundation import NSAutoreleasePool, NSDictionary
	except ImportError:
		# on Windows, PyObjC is not available
		with open(filePath, 'rb') as f:
			data = f.read()
		if data.startswith("<?xml"):
			# use the built-in plistlib module for XML plist
			from plistlib import readPlistFromString
			GlyphsDoc = readPlistFromString(data)
		else:
			# use glyphsLib's Parser for ASCII plist.
			# Download it from: https://github.com/googlei18n/glyphsLib
			from glyphsLib.parser import Parser
			GlyphsDoc = Parser(dict_type=dict).parse(data)
	else:
		# on OS X, use NSDictionary
		pool = NSAutoreleasePool.alloc().init()
		GlyphsDoc = NSDictionary.alloc().initWithContentsOfFile_(filePath)

	if not GlyphsDoc:
		print "Could not load .glyphs file."
		if pool:
			pool.drain()
		return

	from FL import fl, Font
	folder, base = os.path.split(filePath)
	base = base.replace(".glyphs", ".vfb")
	dest = os.path.join(folder, base)
	f = Font(  )
	fl.Add(f)
	global convertName
	try:
		convertName = GlyphsDoc["disablesNiceNames"] != None
	except:
		pass
	if not setFontInfo(f, GlyphsDoc):
		return False
	readGlyphs(f, GlyphsDoc)
	readKerning(f, GlyphsDoc)
	setLegacyNames(f)
	readFeatures(f, GlyphsDoc)
	
	fl.UpdateFont()
	f.modified = 0
	if pool:
		pool.drain()
コード例 #5
0
ファイル: Glyphs Import.py プロジェクト: OHG/Glyphs-Scripts
def readGlyphsFile(filePath):
	print "Import Glyphs File"
	pool = NSAutoreleasePool.alloc().init()
	GlyphsDoc = NSDictionary.alloc().initWithContentsOfFile_(filePath)
	
	loadGlyphsInfo()
	from FL import fl, Font
	f = Font(  )
	fl.Add(f)
	if not setFontInfo(f, GlyphsDoc):
		return False
	readGlyphs(f, GlyphsDoc)
	readKerning(f, GlyphsDoc)
	setLegacyNames(f)
	readFeatures(f, GlyphsDoc)
	
	fl.UpdateFont()
	f.modified = 0
	pool.drain()
コード例 #6
0
def readGlyphsFile(filePath):
	print "Import Glyphs File"
	pool = NSAutoreleasePool.alloc().init()
	GlyphsDoc = NSDictionary.alloc().initWithContentsOfFile_(filePath)
	
	loadGlyphsInfo()
	from FL import fl, Font
	folder, base = os.path.split(filePath)
	base = base.replace(".glyphs", ".vfb")
	dest = os.path.join(folder, base)
	f = Font(  )
	fl.Add(f)
	if not setFontInfo(f, GlyphsDoc):
		return False
	readGlyphs(f, GlyphsDoc)
	readKerning(f, GlyphsDoc)
	setLegacyNames(f)
	readFeatures(f, GlyphsDoc)
	
	fl.UpdateFont()
	f.modified = 0
	pool.drain()