Example #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
Example #2
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
Example #3
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
Example #4
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
Example #5
0
    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
Example #6
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