예제 #1
0
 def _registerDistLookups(self, feature, lookups):
     scripts = self.context.scriptGroups["dist"]
     ltrLookups = lookups.get("LTR")
     if ltrLookups:
         for script, langs in scripts.get("LTR", []):
             ast.addLookupReferences(feature, ltrLookups, script, langs)
     rtlLookups = lookups.get("RTL")
     if rtlLookups:
         for script, langs in scripts.get("RTL", []):
             ast.addLookupReferences(feature, rtlLookups, script, langs)
예제 #2
0
    def _registerKernLookups(self, feature, lookups):
        if "DFLT" in lookups:
            ast.addLookupReferences(feature, lookups["DFLT"])

        scriptGroups = self.context.scriptGroups
        if "dist" in self.context.todo:
            distScripts = scriptGroups["dist"]
        else:
            distScripts = {}
        kernScripts = scriptGroups.get("kern", {})
        ltrScripts = kernScripts.get("LTR", [])
        rtlScripts = kernScripts.get("RTL", [])

        ltrLookups = lookups.get("LTR")
        rtlLookups = lookups.get("RTL")
        if ltrLookups and rtlLookups:
            if ltrScripts and rtlScripts:
                for script, langs in ltrScripts:
                    ast.addLookupReferences(feature, ltrLookups, script, langs)
                for script, langs in rtlScripts:
                    ast.addLookupReferences(feature, rtlLookups, script, langs)
            elif ltrScripts:
                ast.addLookupReferences(feature, rtlLookups, script="DFLT")
                for script, langs in ltrScripts:
                    ast.addLookupReferences(feature, ltrLookups, script, langs)
            elif rtlScripts:
                ast.addLookupReferences(feature, ltrLookups, script="DFLT")
                for script, langs in rtlScripts:
                    ast.addLookupReferences(feature, rtlLookups, script, langs)
            else:
                if not (distScripts.get("LTR") and distScripts.get("RTL")):
                    raise ValueError(
                        "cannot use DFLT script for both LTR and RTL kern "
                        "lookups; add 'languagesystems' to features for at "
                        "least one LTR or RTL script using the kern feature")
        elif ltrLookups:
            if not (rtlScripts or distScripts):
                ast.addLookupReferences(feature, ltrLookups)
            else:
                ast.addLookupReferences(feature, ltrLookups, script="DFLT")
                for script, langs in ltrScripts:
                    ast.addLookupReferences(feature, ltrLookups, script, langs)
        elif rtlLookups:
            if not (ltrScripts or distScripts):
                ast.addLookupReferences(feature, rtlLookups)
            else:
                ast.addLookupReferences(feature, rtlLookups, script="DFLT")
                for script, langs in rtlScripts:
                    ast.addLookupReferences(feature, rtlLookups, script, langs)