コード例 #1
0
ファイル: builder_test.py プロジェクト: graphicore/fonttools
 def test_buildCursivePos(self):
     pos = builder.buildCursivePos({
         "two": (self.ANCHOR1, self.ANCHOR2),
         "four": (self.ANCHOR3, self.ANCHOR1)
     }, self.GLYPHMAP)
     self.assertEqual(getXML(pos.toXML),
                      '<CursivePos Format="1">'
                      '  <Coverage>'
                      '    <Glyph value="two"/>'
                      '    <Glyph value="four"/>'
                      '  </Coverage>'
                      '  <!-- EntryExitCount=2 -->'
                      '  <EntryExitRecord index="0">'
                      '    <EntryAnchor Format="1">'
                      '      <XCoordinate value="11"/>'
                      '      <YCoordinate value="-11"/>'
                      '    </EntryAnchor>'
                      '    <ExitAnchor Format="1">'
                      '      <XCoordinate value="22"/>'
                      '      <YCoordinate value="-22"/>'
                      '    </ExitAnchor>'
                      '  </EntryExitRecord>'
                      '  <EntryExitRecord index="1">'
                      '    <EntryAnchor Format="1">'
                      '      <XCoordinate value="33"/>'
                      '      <YCoordinate value="-33"/>'
                      '    </EntryAnchor>'
                      '    <ExitAnchor Format="1">'
                      '      <XCoordinate value="11"/>'
                      '      <YCoordinate value="-11"/>'
                      '    </ExitAnchor>'
                      '  </EntryExitRecord>'
                      '</CursivePos>')
コード例 #2
0
ファイル: __init__.py プロジェクト: graphicore/fonttools
def parseCursive(lines, font, _lookupMap=None):
    records = {}
    for line in lines:
        assert len(line) in [3, 4], line
        idx, klass = {"entry": (0, ot.EntryAnchor), "exit": (1, ot.ExitAnchor)}[line[0]]
        glyph = makeGlyph(line[1])
        if glyph not in records:
            records[glyph] = [None, None]
        assert records[glyph][idx] is None, (glyph, idx)
        records[glyph][idx] = makeAnchor(line[2:], klass)
    return builder.buildCursivePos(records, font.getReverseGlyphMap())