| 1 |
"""ttLib.Substitution: Converting Substitution rules to TrueType.""" |
| 2 |
|
| 3 |
|
| 4 |
def lookup_type(self, forFea=False): |
| 5 |
"""Mixin to determine the GSUB lookup type of a fontFeatures.Substitution object |
| 6 |
|
| 7 |
Returns: integer GSUB lookup type.""" |
| 8 |
if self.reverse: |
| 9 |
return 8 |
| 10 |
if not self.replacement: |
| 11 |
return 2 # Deletion but treat as mult sub |
| 12 |
if ( |
| 13 |
(self.has_context and not forFea) |
| 14 |
or len(self.lookups) > 0 |
| 15 |
and any([x is not None for x in self.lookups]) |
| 16 |
): |
| 17 |
return 6 # Chaining |
| 18 |
# if self.input == self.replacement: # It's an ignore |
| 19 |
# return 6 |
| 20 |
if len(self.input) == 1 and len(self.replacement) == 1: |
| 21 |
if self.force_alt or (len(self.input[0]) == 1 and len(self.replacement[0]) > 1): |
| 22 |
return 3 # Alternate |
| 23 |
else: |
| 24 |
return 1 # Single |
| 25 |
if len(self.input) > 1 and len(self.replacement) == 1: |
| 26 |
return 4 # Ligature |
| 27 |
|
| 28 |
if len(self.input) > 1 and len(self.replacement) > 1: |
| 29 |
return 9 # Not directly expressible! |
| 30 |
|
| 31 |
if len(self.replacement) > 1: |
| 32 |
return 2 |