コード例 #1
0
    def _makeTest():
        """
        The test case here recognizes the glyph sequence 25-80-26, where 25 is
        the backtrack and 26 the lookahead. The position of glyph 80 is
        adjusted.
        """

        from fontio3 import hmtx, utilities
        from fontio3.GPOS import single, value

        from fontio3.opentype import (lookup, pschainglyph_glyphtuple,
                                      pschainglyph_key, pslookupgroup,
                                      pslookuprecord)

        s1 = single.Single({80: value.Value(xPlacement=-25)})
        lk1 = lookup.Lookup([s1])
        psr1 = pslookuprecord.PSLookupRecord(0, lk1)
        psg1 = pslookupgroup.PSLookupGroup([psr1])
        backPart = pschainglyph_glyphtuple.GlyphTuple([25])
        inPart = pschainglyph_glyphtuple.GlyphTuple([80])
        lookPart = pschainglyph_glyphtuple.GlyphTuple([26])
        key1 = pschainglyph_key.Key([backPart, inPart, lookPart])
        r = ChainGlyph({key1: psg1})
        e = utilities.fakeEditor(0x10000)
        e.hmtx = hmtx.Hmtx()
        e.hmtx[25] = hmtx.MtxEntry(900, 50)
        e.hmtx[26] = hmtx.MtxEntry(970, 40)
        e.hmtx[80] = hmtx.MtxEntry(1020, 55)

        return r, e
コード例 #2
0
    def _makeTV():
        from fontio3.GSUB import single

        from fontio3.opentype import (coverageset, lookup,
                                      pschaincoverage_coveragetuple,
                                      pschaincoverage_key, pslookupgroup,
                                      pslookuprecord)

        single_obj = single.Single({2: 41, 6: 43})
        lookup_obj = lookup.Lookup([single_obj], sequence=0)
        pslookuprecord_obj = pslookuprecord.PSLookupRecord(0, lookup_obj)
        pslookupgroup_obj = pslookupgroup.PSLookupGroup([pslookuprecord_obj])

        tBack = pschaincoverage_coveragetuple.CoverageTuple([
            coverageset.CoverageSet([3, 18, 29]),
            coverageset.CoverageSet([29, 90])
        ])

        tIn = pschaincoverage_coveragetuple.CoverageTuple(
            [coverageset.CoverageSet([2, 6])])

        tLook = pschaincoverage_coveragetuple.CoverageTuple([
            coverageset.CoverageSet([52, 53]),
            coverageset.CoverageSet([53, 54, 55])
        ])

        key_obj = pschaincoverage_key.Key([tBack, tIn, tLook])
        return ChainCoverage({key_obj: pslookupgroup_obj})
コード例 #3
0
ファイル: chainclass.py プロジェクト: nickssmith/jenkinsTests
 def _makeTV():
     from fontio3.GSUB import single
     
     from fontio3.opentype import (
       classdef,
       lookup,
       pschainclass_classtuple,
       pschainclass_key,
       pslookupgroup,
       pslookuprecord)
     
     single_obj = single.Single({2: 41, 4: 42, 6: 43})
     lookup_obj = lookup.Lookup([single_obj], sequence=0)
     pslookuprecord_obj = pslookuprecord.PSLookupRecord(0, lookup_obj)
     pslookupgroup_obj = pslookupgroup.PSLookupGroup([pslookuprecord_obj])
     tBack = pschainclass_classtuple.ClassTuple([1, 2])
     tIn = pschainclass_classtuple.ClassTuple([1])
     tLook = pschainclass_classtuple.ClassTuple([1])
     key_obj = pschainclass_key.Key([tBack, tIn, tLook])
     cdBack = classdef.ClassDef({51: 1, 52: 1, 54: 2, 55: 2})
     cdIn = classdef.ClassDef({2: 1, 4: 1, 6: 1})
     cdLook = classdef.ClassDef({80: 1, 81: 1, 82: 1})
     
     return ChainClass(
       {key_obj: pslookupgroup_obj},
       classDefBacktrack = cdBack,
       classDefInput = cdIn,
       classDefLookahead = cdLook)
コード例 #4
0
ファイル: kerx.py プロジェクト: nickssmith/jenkinsTests
    def _makeGPOS():
        from fontio3.GPOS import (GPOS, pairglyphs, pairglyphs_key, pairvalues,
                                  value)

        from fontio3.opentype import (featuredict, featuretable, langsys,
                                      langsys_optfeatset, langsysdict, lookup,
                                      scriptdict)

        # Return a GPOS with (15, 32) kerned -18, and (20, 30) kerned +14
        v1 = value.Value(xPlacement=-18)
        v2 = value.Value(xPlacement=14)
        pv1 = pairvalues.PairValues(second=v1)
        pv2 = pairvalues.PairValues(second=v2)
        k1 = pairglyphs_key.Key((15, 32))
        k2 = pairglyphs_key.Key((20, 30))
        pairObj = pairglyphs.PairGlyphs({k1: pv1, k2: pv2})
        lkObj = lookup.Lookup([pairObj])
        ftObj = featuretable.FeatureTable([lkObj])
        featObj = featuredict.FeatureDict({b'kern0001': ftObj})

        optSetObj = langsys_optfeatset.OptFeatSet({b'kern0001'})
        lsObj = langsys.LangSys(optionalFeatures=optSetObj)
        lsdObj = langsysdict.LangSysDict({}, defaultLangSys=lsObj)
        scptObj = scriptdict.ScriptDict({b'latn': lsdObj})
        return GPOS.GPOS(features=featObj, scripts=scptObj)
コード例 #5
0
ファイル: lookuplist.py プロジェクト: nickssmith/jenkinsTests
    def _forceAllExtensions(self):
        """
        Creates and returns a new LookupList whose elements are Extension
        objects of the originals.
        """

        v = [None] * len(self)

        for i, lkup in enumerate(self):
            if len(lkup):
                k = lkup[0].kind

                if k == ('GPOS', 9) or k == ('GSUB', 7):
                    v[i] = lkup

                elif k[0] == 'GPOS':
                    from fontio3.GPOS import extension

                    v2 = [extension.Extension(original=obj) for obj in lkup]

                    v[i] = lookup.Lookup(
                        v2,
                        flags=lkup.flags,
                        markFilteringSet=lkup.markFilteringSet,
                        sequence=lkup.sequence)

                elif k[0] == 'GSUB':
                    from fontio3.GSUB import extension

                    v2 = [extension.Extension(original=obj) for obj in lkup]

                    v[i] = lookup.Lookup(
                        v2,
                        flags=lkup.flags,
                        markFilteringSet=lkup.markFilteringSet,
                        sequence=lkup.sequence)

                else:
                    assert False, "Unknown 'kind' in Lookup!"

            else:
                assert False, "Empty Lookup!"

        return type(self)(v)
コード例 #6
0
    def _makeTest():
        """
        The test case here recognizes the glyph sequence 25-80-26, and adjusts
        the positioning of glyphs 25 and 26.
        """

        from fontio3 import hmtx
        from fontio3.GPOS import single, value

        from fontio3.opentype import (lookup, pscontextglyph_key,
                                      pslookupgroup, pslookuprecord)

        s1 = single.Single({25: value.Value(xPlacement=-25)})
        s2 = single.Single({26: value.Value(xPlacement=25)})
        s3 = single.Single({12: value.Value(xPlacement=-15)})
        s4 = single.Single({12: value.Value(xPlacement=15)})

        lk1 = lookup.Lookup([s1])
        lk2 = lookup.Lookup([s2])
        lk3 = lookup.Lookup([s3])
        lk4 = lookup.Lookup([s4])

        psr1 = pslookuprecord.PSLookupRecord(0, lk1)
        psr2 = pslookuprecord.PSLookupRecord(2, lk2)
        psr3 = pslookuprecord.PSLookupRecord(0, lk3)
        psr4 = pslookuprecord.PSLookupRecord(2, lk4)

        psg1 = pslookupgroup.PSLookupGroup([psr1, psr2])
        psg2 = pslookupgroup.PSLookupGroup([psr3, psr4])
        key1 = pscontextglyph_key.Key([25, 80, 26], ruleOrder=0)
        key2 = pscontextglyph_key.Key([12, 15, 12], ruleOrder=1)

        r = ContextGlyph({key1: psg1, key2: psg2})
        e = utilities.fakeEditor(0x10000)
        e.hmtx = hmtx.Hmtx()
        e.hmtx[12] = hmtx.MtxEntry(700, 50)
        e.hmtx[15] = hmtx.MtxEntry(690, 50)
        e.hmtx[25] = hmtx.MtxEntry(900, 50)
        e.hmtx[26] = hmtx.MtxEntry(970, 40)
        e.hmtx[80] = hmtx.MtxEntry(1020, 55)

        return r, e
コード例 #7
0
    def _makeTV():
        from fontio3.GSUB import single

        from fontio3.opentype import (lookup, pscontextglyph_key,
                                      pslookupgroup, pslookuprecord)

        single_obj = single.Single({2: 41})
        lookup_obj = lookup.Lookup([single_obj], sequence=0)
        pslookuprecord_obj = pslookuprecord.PSLookupRecord(1, lookup_obj)
        pslookupgroup_obj = pslookupgroup.PSLookupGroup([pslookuprecord_obj])
        key_obj = pscontextglyph_key.Key([1, 2, 3, 4, 5])
        return ContextGlyph({key_obj: pslookupgroup_obj})
コード例 #8
0
 def _makeTest():
     from fontio3 import hmtx, utilities
     from fontio3.GPOS import single, value
     
     from fontio3.opentype import (
       coverageset,
       lookup,
       pscontextcoverage_key,
       pslookupgroup,
       pslookuprecord)
     
     v1 = value.Value(xPlacement=-25)
     v2 = value.Value(xPlacement=-29)
     s1 = single.Single({20: v1, 25: v2})
     lk1 = lookup.Lookup([s1])
     psr1 = pslookuprecord.PSLookupRecord(0, lk1)
     v1 = value.Value(xPlacement=-31)
     v2 = value.Value(xPlacement=-19)
     s2 = single.Single({25: v1, 26: v2})
     lk2 = lookup.Lookup([s2])
     psr2 = pslookuprecord.PSLookupRecord(2, lk2)
     psg = pslookupgroup.PSLookupGroup([psr1, psr2])
     
     key = pscontextcoverage_key.Key([
       coverageset.CoverageSet([20, 25]),
       coverageset.CoverageSet([81, 82]),
       coverageset.CoverageSet([25, 26])])
     
     r = ContextCoverage({key: psg})
     e = utilities.fakeEditor(0x10000)
     e.hmtx = hmtx.Hmtx()
     e.hmtx[20] = hmtx.MtxEntry(910, 42)
     e.hmtx[25] = hmtx.MtxEntry(900, 50)
     e.hmtx[26] = hmtx.MtxEntry(970, 40)
     e.hmtx[80] = hmtx.MtxEntry(1020, 55)
     e.hmtx[81] = hmtx.MtxEntry(1090, 85)
     
     return r, e
コード例 #9
0
 def _makeTest():
     """
     The test case here recognizes the glyph sequence 1-2-3, and adjusts the
     positioning of classes 1 and 3.
     """
     
     from fontio3 import hmtx, utilities
     from fontio3.GPOS import single, value
     
     from fontio3.opentype import (
       classdef,
       lookup,
       pscontextclass_key,
       pslookupgroup,
       pslookuprecord)
     
     v1 = value.Value(xPlacement=-25)
     v2 = value.Value(xPlacement=-29)
     s1 = single.Single({20: v1, 25: v2})
     lk1 = lookup.Lookup([s1])
     psr1 = pslookuprecord.PSLookupRecord(0, lk1)
     s2 = single.Single({26: value.Value(xPlacement=25)})
     lk2 = lookup.Lookup([s2])
     psr2 = pslookuprecord.PSLookupRecord(2, lk2)
     psg = pslookupgroup.PSLookupGroup([psr1, psr2])
     key = pscontextclass_key.Key([1, 2, 3])
     cd = classdef.ClassDef({20: 1, 25: 1, 80: 2, 81: 2, 26: 3})
     r = ContextClass({key: psg}, classDef=cd)
     e = utilities.fakeEditor(0x10000)
     e.hmtx = hmtx.Hmtx()
     e.hmtx[20] = hmtx.MtxEntry(910, 42)
     e.hmtx[25] = hmtx.MtxEntry(900, 50)
     e.hmtx[26] = hmtx.MtxEntry(970, 40)
     e.hmtx[80] = hmtx.MtxEntry(1020, 55)
     e.hmtx[81] = hmtx.MtxEntry(1090, 85)
     
     return r, e
コード例 #10
0
    def _makeTV():
        from fontio3.GSUB import single

        from fontio3.opentype import (classdef, lookup, pscontextclass_key,
                                      pslookupgroup, pslookuprecord)

        single_obj = single.Single({2: 41, 8: 42})
        lookup_obj = lookup.Lookup([single_obj], sequence=0)
        pslookuprecord_obj = pslookuprecord.PSLookupRecord(1, lookup_obj)
        pslookupgroup_obj = pslookupgroup.PSLookupGroup([pslookuprecord_obj])
        key_obj = pscontextclass_key.Key([1, 2, 1, 3])
        classdef_obj = classdef.ClassDef({19: 1, 2: 2, 8: 2, 12: 3})

        return ContextClass({key_obj: pslookupgroup_obj},
                            classDef=classdef_obj)
コード例 #11
0
ファイル: chainglyph.py プロジェクト: nickssmith/jenkinsTests
    def _makeTV():
        from fontio3.GSUB import single

        from fontio3.opentype import (lookup, pschainglyph_glyphtuple,
                                      pschainglyph_key, pslookupgroup,
                                      pslookuprecord)

        single_obj = single.Single({2: 41})
        lookup_obj = lookup.Lookup([single_obj], sequence=0)
        pslookuprecord_obj = pslookuprecord.PSLookupRecord(0, lookup_obj)
        pslookupgroup_obj = pslookupgroup.PSLookupGroup([pslookuprecord_obj])
        tBack = pschainglyph_glyphtuple.GlyphTuple([12, 8])
        tIn = pschainglyph_glyphtuple.GlyphTuple([2])
        tLook = pschainglyph_glyphtuple.GlyphTuple([5, 8, 9, 30])
        key_obj = pschainglyph_key.Key([tBack, tIn, tLook])
        return ChainGlyph({key_obj: pslookupgroup_obj})
コード例 #12
0
    def _makeTV():
        from fontio3.GSUB import single

        from fontio3.opentype import (coverageset, lookup,
                                      pscontextcoverage_key, pslookupgroup,
                                      pslookuprecord)

        single_obj = single.Single({2: 41, 5: 42})
        lookup_obj = lookup.Lookup([single_obj], sequence=0)
        pslookuprecord_obj = pslookuprecord.PSLookupRecord(1, lookup_obj)
        pslookupgroup_obj = pslookupgroup.PSLookupGroup([pslookuprecord_obj])
        coverageset_obj_1 = coverageset.CoverageSet([2, 9, 10])
        coverageset_obj_2 = coverageset.CoverageSet([2, 5])

        key_obj = pscontextcoverage_key.Key(
            [coverageset_obj_1, coverageset_obj_2])

        return ContextCoverage({key_obj: pslookupgroup_obj})
コード例 #13
0
ファイル: morx.py プロジェクト: nickssmith/jenkinsTests
    def _makeGSUB():
        from fontio3.GSUB import GSUB, ligature, ligature_glyphtuple

        from fontio3.opentype import (featuredict, featuretable, langsys,
                                      langsys_optfeatset, langsysdict, lookup,
                                      scriptdict)

        # Return a GSUB with a b'liga' feature (20, 30) -> 40
        ligGTObj = ligature_glyphtuple.Ligature_GlyphTuple((20, 30))
        ligObj = ligature.Ligature({ligGTObj: 40}, keyOrder=[ligGTObj])
        lkObj = lookup.Lookup([ligObj])
        ftObj = featuretable.FeatureTable([lkObj])
        featObj = featuredict.FeatureDict({b'liga0001': ftObj})

        optSetObj = langsys_optfeatset.OptFeatSet({b'liga0001'})
        lsObj = langsys.LangSys(optionalFeatures=optSetObj)
        lsdObj = langsysdict.LangSysDict({}, defaultLangSys=lsObj)
        scptObj = scriptdict.ScriptDict({b'latn': lsdObj})
        return GSUB.GSUB(features=featObj, scripts=scptObj)
コード例 #14
0
ファイル: chainclass.py プロジェクト: nickssmith/jenkinsTests
    def _makeTest():
        """
        The test case here recognizes the glyph sequence 1-2-3, and adjusts the
        positioning of class 2.
        """

        from fontio3 import hmtx, utilities
        from fontio3.GPOS import single, value

        from fontio3.opentype import (classdef, lookup,
                                      pschainclass_classtuple,
                                      pschainclass_key, pslookupgroup,
                                      pslookuprecord)

        v1 = value.Value(xPlacement=-25)
        v2 = value.Value(xPlacement=-29)
        s1 = single.Single({80: v1, 81: v2, 82: v1})
        lk1 = lookup.Lookup([s1])
        psr1 = pslookuprecord.PSLookupRecord(0, lk1)
        psg = pslookupgroup.PSLookupGroup([psr1])
        backPart = pschainclass_classtuple.ClassTuple([1])
        inPart = pschainclass_classtuple.ClassTuple([1])
        lookPart = pschainclass_classtuple.ClassTuple([1])
        key = pschainclass_key.Key([backPart, inPart, lookPart])
        cdBack = classdef.ClassDef({25: 1})
        cdIn = classdef.ClassDef({80: 1, 81: 1, 82: 1})
        cdLook = classdef.ClassDef({26: 1})

        r = ChainClass({key: psg},
                       classDefBacktrack=cdBack,
                       classDefInput=cdIn,
                       classDefLookahead=cdLook)

        e = utilities.fakeEditor(0x10000)
        e.hmtx = hmtx.Hmtx()
        e.hmtx[25] = hmtx.MtxEntry(900, 50)
        e.hmtx[26] = hmtx.MtxEntry(970, 40)
        e.hmtx[80] = hmtx.MtxEntry(1020, 55)
        e.hmtx[81] = hmtx.MtxEntry(1090, 85)
        e.hmtx[82] = hmtx.MtxEntry(1050, 70)

        return r, e
コード例 #15
0
    def _makeTV():
        from fontio3.GSUB import single

        cdBack = classdef.ClassDef({10: 1, 11: 1})
        cdIn = classdef.ClassDef({20: 1, 21: 1, 22: 2, 40: 3, 41: 3})
        cdLook = classdef.ClassDef({30: 1})
        back1 = pschainclass_classtuple.ClassTuple([1])
        in1 = pschainclass_classtuple.ClassTuple([1, 2])
        look1 = pschainclass_classtuple.ClassTuple([1])
        key1 = pschainclass_key.Key([back1, in1, look1], ruleOrder=0)
        sgl1 = single.Single({20: 40, 21: 41})
        lkup1 = lookup.Lookup([sgl1], sequence=22)
        rec1 = pslookuprecord.PSLookupRecord(sequenceIndex=0, lookup=lkup1)
        grp1 = pslookupgroup.PSLookupGroup([rec1])

        obj = PSChainClass({key1: grp1},
                           classDefBacktrack=cdBack,
                           classDefInput=cdIn,
                           classDefLookahead=cdLook)

        return obj
コード例 #16
0
    def _makeTest():
        from fontio3 import hmtx, utilities
        from fontio3.GPOS import single, value

        from fontio3.opentype import (coverageset, lookup,
                                      pschaincoverage_coveragetuple,
                                      pschaincoverage_key, pslookupgroup,
                                      pslookuprecord)

        v1 = value.Value(xPlacement=-25)
        v2 = value.Value(xPlacement=-29)
        s1 = single.Single({80: v1, 81: v2, 82: v1})
        lk1 = lookup.Lookup([s1])
        psr1 = pslookuprecord.PSLookupRecord(0, lk1)
        psg = pslookupgroup.PSLookupGroup([psr1])

        cs1 = coverageset.CoverageSet([20, 22])
        cs2 = coverageset.CoverageSet([23])
        cs3 = coverageset.CoverageSet([80, 81, 82])
        cs4 = coverageset.CoverageSet([22])
        cs5 = coverageset.CoverageSet([20, 40])
        ct1 = pschaincoverage_coveragetuple.CoverageTuple([cs1, cs2])
        ct2 = pschaincoverage_coveragetuple.CoverageTuple([cs3])
        ct3 = pschaincoverage_coveragetuple.CoverageTuple([cs4, cs5])
        key = pschaincoverage_key.Key([ct1, ct2, ct3])

        r = ChainCoverage({key: psg})
        e = utilities.fakeEditor(0x10000)
        e.hmtx = hmtx.Hmtx()
        e.hmtx[20] = hmtx.MtxEntry(910, 42)
        e.hmtx[22] = hmtx.MtxEntry(900, 50)
        e.hmtx[23] = hmtx.MtxEntry(970, 40)
        e.hmtx[40] = hmtx.MtxEntry(890, 8)
        e.hmtx[80] = hmtx.MtxEntry(1020, 55)
        e.hmtx[81] = hmtx.MtxEntry(1090, 85)
        e.hmtx[82] = hmtx.MtxEntry(1020, 55)

        return r, e