Debian Codegraph @

Lib/fontFeatures/shaperLib/Chaining.py

raw
1 def shaper_inputs(self):
2 return self.input
3
4
5 def __find_masked_ix(buf, ix):
6 # This probably could be done better...
7 for i in range(len(buf.items)):
8 if buf.mask[i] == ix:
9 return i
10 return -1
11
12
13 def _do_apply(self, buf, ix, namedclasses={}):
14 from fontFeatures import RoutineReference
15
16 # Save buffer mask
17 flags = buf.flags
18 markFilteringSet = buf.markFilteringSet
19 markAttachmentSet = buf.markAttachmentSet
20
21 if ix + len(self.lookups) - 1 > len(buf.mask):
22 return
23
24 old_unmasked_indexes = [buf.mask[ix + i] for i in range(len(self.lookups))]
25 for i, lookups in enumerate(self.lookups):
26 if not lookups:
27 continue
28 for routine in lookups:
29 assert isinstance(routine, RoutineReference)
30 routine = routine.routine
31 # Adjust mask and recompute index?
32 unmasked_ix = old_unmasked_indexes[i]
33 for rule in routine.rules:
34 buf.set_mask(
35 rule.flags, routine.markFilteringSet, routine.markAttachmentSet
36 )
37 newix = __find_masked_ix(buf, unmasked_ix)
38 if rule.would_apply_at_position(
39 buf, newix, namedclasses
40 ) and rule._do_apply(buf, newix):
41 break
42
43 buf.set_mask(flags, markFilteringSet, markAttachmentSet)
44 return len(self.input) - 1