File: __init__.py

package info (click to toggle)
mutatormath 3.0.1-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,820 kB
  • sloc: python: 2,581; makefile: 10
file content (61 lines) | stat: -rw-r--r-- 1,682 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61

""" These are some UFO specific tools for use with Mutator.


	build() is a convenience function for reading and executing a designspace file.
		documentPath: 				filepath to the .designspace document
		outputUFOFormatVersion:		ufo format for output
		verbose:					True / False for lots or no feedback
		logPath:					filepath to a log file
		progressFunc:				an optional callback to report progress.
									see mutatorMath.ufo.tokenProgressFunc

"""


def tokenProgressFunc(state="update", action=None, text=None, tick=0):
	"""
		state: 		string, "update", "reading sources", "wrapping up"
		action:		string, "stop", "start"
		text:		string, value, additional parameter. For instance ufoname.
		tick:		a float between 0 and 1 indicating progress.
	"""
	print("tokenProgressFunc %s: %s\n%s (%s)"%(state, str(action), str(text), str(tick)))

def build(
		documentPath,
		outputUFOFormatVersion=2,
		roundGeometry=True,
		verbose=True,
		logPath=None,
		progressFunc=None,
		bendLocations=False,
		):
	"""

		Simple builder for UFO designspaces.

	"""
	from mutatorMath.ufo.document import DesignSpaceDocumentReader
	import os, glob
	if os.path.isdir(documentPath):
		# process all *.designspace documents in this folder
		todo = glob.glob(os.path.join(documentPath, "*.designspace"))
	else:
		# process the 
		todo = [documentPath]
	results = []
	for path in todo:
		reader = DesignSpaceDocumentReader(
				path,
				ufoVersion=outputUFOFormatVersion,
				roundGeometry=roundGeometry,
				verbose=verbose,
				logPath=logPath,
				progressFunc=progressFunc,
		        )
		reader.process(bendLocations=bendLocations)
		results.append(reader.results)
	reader = None
	return results