MCPcopy
hub / github.com/belluzj/fantasque-sans / permutations

Function permutations

Scripts/fontbuilder.py:63–77  ·  view source on GitHub ↗

Yields all possible permutations from the options list

()

Source from the content-addressed store, hash-verified

61 return expanded
62
63def permutations():
64 """Yields all possible permutations from the options list"""
65 count = len(option.abrvs)
66
67 # Each option is a binary choice, so we use an int as a quick bitmap.
68 # To iterate over every possible permutation, all we have to do is increment
69 # up to the maximum value 2^(#options)
70 bitmap_max = 1 << count
71
72 # Iterate over all possible permutations
73 for i in xrange(bitmap_max):
74 # Map the iteration's permutations using a bitmap
75 bitmap = [i >> n & 1 for n in xrange(count)]
76 for opts in _expand_options(bitmap):
77 yield(int(float(i)/bitmap_max*100), opts)
78
79def _build(dstdir, font, permutations):
80 for prcnt, opts in permutations:

Callers 2

buildFunction · 0.85
build_batchFunction · 0.85

Calls 1

_expand_optionsFunction · 0.85

Tested by

no test coverage detected