Exemplo n.º 1
0
    m = re.search(br"/FontName\s+/([^ \t\n\r]+)\s+def", data)
    if m:
        fontName = m.group(1)
    else:
        fontName = None
    interpreter = PSInterpreter()
    interpreter.interpret(
        b"/Helvetica 4 dict dup /Encoding StandardEncoding put definefont pop")
    interpreter.interpret(data)
    fontdir = interpreter.dictstack[0]['FontDirectory'].value
    if fontName in fontdir:
        rawfont = fontdir[fontName]
    else:
        # fall back, in case fontName wasn't found
        fontNames = list(fontdir.keys())
        if len(fontNames) > 1:
            fontNames.remove("Helvetica")
        fontNames.sort()
        rawfont = fontdir[fontNames[0]]
    interpreter.close()
    return unpack_item(rawfont)


if __name__ == "__main__":
    import EasyDialogs
    path = EasyDialogs.AskFileForOpen()
    if path:
        from fontTools import t1Lib
        data, kind = t1Lib.read(path)
        font = suckfont(data)
Exemplo n.º 2
0
	import re
	m = re.search(r"/FontName\s+/([^ \t\n\r]+)\s+def", data)
	if m:
		fontName = m.group(1)
	else:
		fontName = None
	interpreter = PSInterpreter()
	interpreter.interpret("/Helvetica 4 dict dup /Encoding StandardEncoding put definefont pop")
	interpreter.interpret(data)
	fontdir = interpreter.dictstack[0]['FontDirectory'].value
	if fontName in fontdir:
		rawfont = fontdir[fontName]
	else:
		# fall back, in case fontName wasn't found
		fontNames = list(fontdir.keys())
		if len(fontNames) > 1:
			fontNames.remove("Helvetica")
		fontNames.sort()
		rawfont = fontdir[fontNames[0]]
	interpreter.close()
	return unpack_item(rawfont)


if __name__ == "__main__":
	import macfs
	fss, ok = macfs.StandardGetFile("LWFN")
	if ok:
		from fontTools import t1Lib
		data, kind = t1Lib.read(fss.as_pathname())
		font = suckfont(data)
Exemplo n.º 3
0
	import re
	m = re.search(r"/FontName\s+/([^ \t\n\r]+)\s+def", data)
	if m:
		fontName = m.group(1)
	else:
		fontName = None
	interpreter = PSInterpreter()
	interpreter.interpret("/Helvetica 4 dict dup /Encoding StandardEncoding put definefont pop")
	interpreter.interpret(data)
	fontdir = interpreter.dictstack[0]['FontDirectory'].value
	if fontName in fontdir:
		rawfont = fontdir[fontName]
	else:
		# fall back, in case fontName wasn't found
		fontNames = list(fontdir.keys())
		if len(fontNames) > 1:
			fontNames.remove("Helvetica")
		fontNames.sort()
		rawfont = fontdir[fontNames[0]]
	interpreter.close()
	return unpack_item(rawfont)


if __name__ == "__main__":
	import EasyDialogs
	path = EasyDialogs.AskFileForOpen()
	if path:
		from fontTools import t1Lib
		data, kind = t1Lib.read(path)
		font = suckfont(data)
Exemplo n.º 4
0
    m = re.search(r"/FontName\s+/([^ \t\n\r]+)\s+def", data)
    if m:
        fontName = m.group(1)
    else:
        fontName = None
    interpreter = PSInterpreter()
    interpreter.interpret(
        "/Helvetica 4 dict dup /Encoding StandardEncoding put definefont pop")
    interpreter.interpret(data)
    fontdir = interpreter.dictstack[0]['FontDirectory'].value
    if fontdir.has_key(fontName):
        rawfont = fontdir[fontName]
    else:
        # fall back, in case fontName wasn't found
        fontNames = fontdir.keys()
        if len(fontNames) > 1:
            fontNames.remove("Helvetica")
        fontNames.sort()
        rawfont = fontdir[fontNames[0]]
    interpreter.close()
    return unpack_item(rawfont)


if __name__ == "__main__":
    import macfs
    fss, ok = macfs.StandardGetFile("LWFN")
    if ok:
        from fontTools import t1Lib
        data, kind = t1Lib.read(fss.as_pathname())
        font = suckfont(data)