Debian Codegraph @

Lib/fontFeatures/feaLib/Positioning.py

raw
1 import fontTools.feaLib.ast as feaast
2 from fontFeatures.ttLib.Positioning import lookup_type
3
4
5 def glyphref(g):
6 if len(g) == 1:
7 return feaast.GlyphName(g[0])
8 return feaast.GlyphClass([feaast.GlyphName(x) for x in sorted(g)])
9
10
11 def asFeaAST(self):
12 lut = lookup_type(self)
13 glyphs = [glyphref(x) for x in self.glyphs]
14 positionings = list(zip(glyphs, self.valuerecords))
15 if len(self.glyphs) == 1 or lut == 8:
16 return feaast.SinglePosStatement(
17 positionings,
18 [glyphref(x) for x in self.precontext],
19 [glyphref(x) for x in self.postcontext],
20 (lut == 8),
21 )
22 if lut == 2:
23 return feaast.PairPosStatement(
24 glyphs[0], self.valuerecords[0], glyphs[1], self.valuerecords[1]
25 )
26 raise ValueError()