예제 #1
0
 def test_compile_fromXML(self):
     mvar = newTable('MVAR')
     font = TTFont()
     for name, attrs, content in parseXML(MVAR_XML):
         mvar.fromXML(name, attrs, content, font=font)
     data = MVAR_DATA
     self.assertEqual(hexStr(mvar.compile(font)), hexStr(data))
예제 #2
0
 def test_compile_fromXML(self):
     mvar = newTable('MVAR')
     font = TTFont()
     for name, attrs, content in parseXML(MVAR_XML):
         mvar.fromXML(name, attrs, content, font=font)
     data = MVAR_DATA
     self.assertEqual(hexStr(mvar.compile(font)), hexStr(data))
예제 #3
0
 def testCompile(self):
     a = otTables.ContextualMorphAction()
     a.NewState = 0x1234
     a.SetMark, a.DontAdvance, a.ReservedFlags = True, True, 0x3117
     a.MarkIndex, a.CurrentIndex = 0xDEAD, 0xBEEF
     writer = OTTableWriter()
     a.compile(writer, self.font, actionIndex=None)
     self.assertEqual(hexStr(writer.getAllData()), "1234f117deadbeef")
예제 #4
0
 def testCompile(self):
     r = otTables.RearrangementMorphAction()
     r.NewState = 0x1234
     r.MarkFirst = r.DontAdvance = r.MarkLast = True
     r.ReservedFlags, r.Verb = 0x1FF0, 0xD
     writer = OTTableWriter()
     r.compile(writer, self.font, actionIndex=None)
     self.assertEqual(hexStr(writer.getAllData()), "1234fffd")
예제 #5
0
 def testCompile(self):
     r = otTables.RearrangementMorphAction()
     r.NewState = 0x1234
     r.MarkFirst = r.DontAdvance = r.MarkLast = True
     r.ReservedFlags, r.Verb = 0x1FF0, 0xD
     writer = OTTableWriter()
     r.compile(writer, self.font, actionIndex=None)
     self.assertEqual(hexStr(writer.getAllData()), "1234fffd")
예제 #6
0
 def testCompile(self):
     a = otTables.ContextualMorphAction()
     a.NewState = 0x1234
     a.SetMark, a.DontAdvance, a.ReservedFlags = True, True, 0x3117
     a.MarkIndex, a.CurrentIndex = 0xDEAD, 0xBEEF
     writer = OTTableWriter()
     a.compile(writer, self.font, actionIndex=None)
     self.assertEqual(hexStr(writer.getAllData()), "1234f117deadbeef")
예제 #7
0
    def testCompileFromXML(self):
        a = otTables.InsertionMorphAction()
        for name, attrs, content in parseXML(self.MORPH_ACTION_XML):
            a.fromXML(name, attrs, content, self.font)
        writer = OTTableWriter()
        a.compile(writer, self.font,
	          actionIndex={('B', 'C'): 9, ('B', 'A', 'D'): 7})
        self.assertEqual(hexStr(writer.getAllData()), "1234fc4300090007")
예제 #8
0
 def checkFlags(self, flags, textDirection, processingOrder,
                checkCompile=True):
     data = bytesjoin([
         MORX_REARRANGEMENT_DATA[:28],
         bytechr(flags << 4),
         MORX_REARRANGEMENT_DATA[29:]])
     xml = []
     for line in MORX_REARRANGEMENT_XML:
         if line.startswith('    <TextDirection '):
             line = '    <TextDirection value="%s"/>' % textDirection
         elif line.startswith('    <ProcessingOrder '):
             line = '    <ProcessingOrder value="%s"/>' % processingOrder
         xml.append(line)
     table1 = newTable('morx')
     table1.decompile(data, self.font)
     self.assertEqual(getXML(table1.toXML), xml)
     if checkCompile:
         table2 = newTable('morx')
         for name, attrs, content in parseXML(xml):
             table2.fromXML(name, attrs, content, font=self.font)
         self.assertEqual(hexStr(table2.compile(self.font)), hexStr(data))
예제 #9
0
 def checkFlags(self, flags, textDirection, processingOrder,
                checkCompile=True):
     data = bytesjoin([
         MORX_REARRANGEMENT_DATA[:28],
         bytechr(flags << 4),
         MORX_REARRANGEMENT_DATA[29:]])
     xml = []
     for line in MORX_REARRANGEMENT_XML:
         if line.startswith('    <TextDirection '):
             line = '    <TextDirection value="%s"/>' % textDirection
         elif line.startswith('    <ProcessingOrder '):
             line = '    <ProcessingOrder value="%s"/>' % processingOrder
         xml.append(line)
     table1 = newTable('morx')
     table1.decompile(data, self.font)
     self.assertEqual(getXML(table1.toXML), xml)
     if checkCompile:
         table2 = newTable('morx')
         for name, attrs, content in parseXML(xml):
             table2.fromXML(name, attrs, content, font=self.font)
         self.assertEqual(hexStr(table2.compile(self.font)), hexStr(data))
예제 #10
0
 def testCompileFromXML(self):
     a = otTables.InsertionMorphAction()
     for name, attrs, content in parseXML(self.MORPH_ACTION_XML):
         a.fromXML(name, attrs, content, self.font)
     writer = OTTableWriter()
     a.compile(writer,
               self.font,
               actionIndex={
                   ('B', 'C'): 9,
                   ('B', 'A', 'D'): 7
               })
     self.assertEqual(hexStr(writer.getAllData()), "1234fc4300090007")
예제 #11
0
def _writeRowImageData(strikeIndex, glyphName, bitmapObject, writer, ttFont):
	metrics = bitmapObject.exportMetrics
	del bitmapObject.exportMetrics
	bitDepth = bitmapObject.exportBitDepth
	del bitmapObject.exportBitDepth

	writer.begintag('rowimagedata', bitDepth=bitDepth, width=metrics.width, height=metrics.height)
	writer.newline()
	for curRow in range(metrics.height):
		rowData = bitmapObject.getRow(curRow, bitDepth=bitDepth, metrics=metrics)
		writer.simpletag('row', value=hexStr(rowData))
		writer.newline()
	writer.endtag('rowimagedata')
	writer.newline()
예제 #12
0
def _writeRowImageData(strikeIndex, glyphName, bitmapObject, writer, ttFont):
    metrics = bitmapObject.exportMetrics
    del bitmapObject.exportMetrics
    bitDepth = bitmapObject.exportBitDepth
    del bitmapObject.exportBitDepth

    writer.begintag("rowimagedata", bitDepth=bitDepth, width=metrics.width, height=metrics.height)
    writer.newline()
    for curRow in range(metrics.height):
        rowData = bitmapObject.getRow(curRow, bitDepth=bitDepth, metrics=metrics)
        writer.simpletag("row", value=hexStr(rowData))
        writer.newline()
    writer.endtag("rowimagedata")
    writer.newline()
예제 #13
0
 def test_ReservedCoverageFlags(self):
     # 8A BC DE = TextDirection=Vertical, Reserved=0xABCDE
     # Note that the lower 4 bits of the first byte are already
     # part of the Reserved value. We test the full round-trip
     # to encoding and decoding is quite hairy.
     data = bytesjoin([
         MORX_REARRANGEMENT_DATA[:28],
         bytechr(0x8A), bytechr(0xBC), bytechr(0xDE),
         MORX_REARRANGEMENT_DATA[31:]])
     table = newTable('morx')
     table.decompile(data, self.font)
     subtable = table.table.MorphChain[0].MorphSubtable[0]
     self.assertEqual(subtable.Reserved, 0xABCDE)
     xml = getXML(table.toXML)
     self.assertIn('    <Reserved value="0xabcde"/>', xml)
     table2 = newTable('morx')
     for name, attrs, content in parseXML(xml):
         table2.fromXML(name, attrs, content, font=self.font)
     self.assertEqual(hexStr(table2.compile(self.font)[28:31]), "8abcde")
예제 #14
0
 def test_ReservedCoverageFlags(self):
     # 8A BC DE = TextDirection=Vertical, Reserved=0xABCDE
     # Note that the lower 4 bits of the first byte are already
     # part of the Reserved value. We test the full round-trip
     # to encoding and decoding is quite hairy.
     data = bytesjoin([
         MORX_REARRANGEMENT_DATA[:28],
         bytechr(0x8A), bytechr(0xBC), bytechr(0xDE),
         MORX_REARRANGEMENT_DATA[31:]])
     table = newTable('morx')
     table.decompile(data, self.font)
     subtable = table.table.MorphChain[0].MorphSubtable[0]
     self.assertEqual(subtable.Reserved, 0xABCDE)
     xml = getXML(table.toXML)
     self.assertIn('    <Reserved value="0xabcde"/>', xml)
     table2 = newTable('morx')
     for name, attrs, content in parseXML(xml):
         table2.fromXML(name, attrs, content, font=self.font)
     self.assertEqual(hexStr(table2.compile(self.font)[28:31]), "8abcde")
예제 #15
0
	def test_compile(self):
		font, gvar = self.makeFont(GVAR_VARIATIONS)
		self.assertEqual(hexStr(gvar.compile(font)), hexStr(GVAR_DATA))
예제 #16
0
 def test_compile_fromXML(self):
     table = newTable('morx')
     for name, attrs, content in parseXML(MORX_INSERTION_XML):
         table.fromXML(name, attrs, content, font=self.font)
     self.assertEqual(hexStr(table.compile(self.font)),
                      hexStr(MORX_INSERTION_DATA))
예제 #17
0
 def test_compile_shared_points(self):
     font, cvar = self.makeFont()
     cvar.variations = CVAR_VARIATIONS
     self.assertEqual(hexStr(cvar.compile(font, useSharedPoints=True)),
                      hexStr(CVAR_DATA))
예제 #18
0
 def test_compile(self):
     font, cvar = self.makeFont()
     cvar.variations = CVAR_VARIATIONS
     self.assertEqual(hexStr(cvar.compile(font)),
                      hexStr(CVAR_PRIVATE_POINT_DATA))
예제 #19
0
 def test_compile_fromXML_format1(self):
     table = newTable('opbd')
     for name, attrs, content in parseXML(OPBD_FORMAT_1_XML):
         table.fromXML(name, attrs, content, font=self.font)
     self.assertEqual(hexStr(table.compile(self.font)),
                      hexStr(OPBD_FORMAT_1_DATA))
예제 #20
0
 def test_compile_fromXML(self):
     table = newTable('morx')
     for name, attrs, content in parseXML(MORX_NONCONTEXTUAL_XML):
         table.fromXML(name, attrs, content, font=self.font)
     self.assertEqual(hexStr(table.compile(self.font)),
                      hexStr(MORX_NONCONTEXTUAL_DATA))
예제 #21
0
 def test_compile_fromXML_format0(self):
     table = newTable('opbd')
     for name, attrs, content in parseXML(OPBD_FORMAT_0_XML):
         table.fromXML(name, attrs, content, font=self.font)
     self.assertEqual(hexStr(table.compile(self.font)),
                      hexStr(OPBD_FORMAT_0_DATA))
예제 #22
0
 def test_compile_fromXML(self):
     table = newTable('mort')
     for name, attrs, content in parseXML(MORT_NONCONTEXTUAL_XML):
         table.fromXML(name, attrs, content, font=self.font)
     self.assertEqual(hexStr(table.compile(self.font)),
                      hexStr(MORT_NONCONTEXTUAL_DATA))
예제 #23
0
 def testCompileFromXML(self):
     table = newTable('cidg')
     for name, attrs, content in parseXML(CIDG_XML):
         table.fromXML(name, attrs, content, font=self.font)
     self.assertEqual(hexStr(table.compile(self.font)),
                      hexStr(CIDG_DATA))
예제 #24
0
 def compileFromXML(self, xml, data):
     table = newTable('ankr')
     for name, attrs, content in parseXML(xml):
         table.fromXML(name, attrs, content, font=self.font)
     self.assertEqual(hexStr(table.compile(self.font)), hexStr(data))
예제 #25
0
 def test_compile_emptyVariations(self):
     font, gvar = self.makeFont({".notdef": [], "space": [], "I": []})
     self.assertEqual(hexStr(gvar.compile(font)), hexStr(GVAR_DATA_EMPTY_VARIATIONS))
예제 #26
0
 def test_compile_noVariations(self):
     font, gvar = self.makeFont({})
     self.assertEqual(hexStr(gvar.compile(font)), hexStr(GVAR_DATA_EMPTY_VARIATIONS))
예제 #27
0
 def test_compile(self):
     font, gvar = self.makeFont(GVAR_VARIATIONS)
     self.assertEqual(hexStr(gvar.compile(font)), hexStr(GVAR_DATA))
예제 #28
0
	def test_compile_emptyVariations(self):
		font, gvar = self.makeFont({".notdef": [], "space": [], "I": []})
		self.assertEqual(hexStr(gvar.compile(font)),
		                 hexStr(GVAR_DATA_EMPTY_VARIATIONS))
예제 #29
0
 def test_compile_fromXML_format1(self):
     table = newTable('prop')
     for name, attrs, content in parseXML(PROP_FORMAT_1_XML):
         table.fromXML(name, attrs, content, font=self.font)
     self.assertEqual(hexStr(table.compile(self.font)),
                      hexStr(PROP_FORMAT_1_DATA))
예제 #30
0
def hexencode(s):
	h = hexStr(s).upper()
	return ' '.join([h[i:i+2] for i in range(0, len(h), 2)])
예제 #31
0
 def test_compile_shared_points(self):
     font, cvar = self.makeFont()
     cvar.variations = CVAR_VARIATIONS
     self.assertEqual(hexStr(cvar.compile(font, useSharedPoints=True)), hexStr(CVAR_DATA))
예제 #32
0
	def test_compile_noVariations(self):
		font, gvar = self.makeFont({})
		self.assertEqual(hexStr(gvar.compile(font)),
		                 hexStr(GVAR_DATA_EMPTY_VARIATIONS))
예제 #33
0
 def compileFromXML(self, xml, data):
     table = newTable('bsln')
     for name, attrs, content in parseXML(xml):
         table.fromXML(name, attrs, content, font=self.font)
     self.assertEqual(hexStr(table.compile(self.font)), hexStr(data))
예제 #34
0
 def test_compile(self):
     font, cvar = self.makeFont()
     cvar.variations = CVAR_VARIATIONS
     self.assertEqual(hexStr(cvar.compile(font)), hexStr(CVAR_DATA))
예제 #35
0
 def testCompileFromXML(self):
     table = newTable('gcid')
     for name, attrs, content in parseXML(GCID_XML):
         table.fromXML(name, attrs, content, font=self.font)
     self.assertEqual(hexStr(table.compile(self.font)), hexStr(GCID_DATA))
예제 #36
0
def hexencode(s):
	h = hexStr(s).upper()
	return ' '.join([h[i:i+2] for i in range(0, len(h), 2)])
예제 #37
0
 def test_compile_fromXML_format0(self):
     table = newTable('lcar')
     for name, attrs, content in parseXML(LCAR_FORMAT_0_XML):
         table.fromXML(name, attrs, content, font=self.font)
     self.assertEqual(hexStr(table.compile(self.font)),
                      hexStr(LCAR_FORMAT_0_DATA))