diff --git a/Lib/fontTools/ttLib/tables/__init__.py b/Lib/fontTools/ttLib/tables/__init__.py index 22f8b8d05..16d3a330c 100644 --- a/Lib/fontTools/ttLib/tables/__init__.py +++ b/Lib/fontTools/ttLib/tables/__init__.py @@ -65,6 +65,7 @@ def _moduleFinderHint(): from . import _h_h_e_a from . import _h_m_t_x from . import _k_e_r_n + from . import _l_c_a_r from . import _l_o_c_a from . import _l_t_a_g from . import _m_a_x_p diff --git a/Lib/fontTools/ttLib/tables/_l_c_a_r.py b/Lib/fontTools/ttLib/tables/_l_c_a_r.py new file mode 100644 index 000000000..4b9c85442 --- /dev/null +++ b/Lib/fontTools/ttLib/tables/_l_c_a_r.py @@ -0,0 +1,7 @@ +from __future__ import print_function, division, absolute_import +from fontTools.misc.py23 import * +from .otBase import BaseTTXConverter + + +class table__l_c_a_r(BaseTTXConverter): + pass diff --git a/README.rst b/README.rst index 2d578720e..d871561ff 100644 --- a/README.rst +++ b/README.rst @@ -102,8 +102,8 @@ The following tables are currently supported: OS/2, SING, STAT, SVG, TSI0, TSI1, TSI2, TSI3, TSI5, TSIB, TSID, TSIJ, TSIP, TSIS, TSIV, TTFA, VDMX, VORG, VVAR, avar, cmap, cvar, cvt, feat, fpgm, fvar, gasp, glyf, gvar, hdmx, head, hhea, hmtx, - kern, loca, ltag, maxp, meta, name, post, prep, sbix, trak, vhea - and vmtx + kern, lcar, loca, ltag, maxp, meta, name, post, prep, sbix, trak, + vhea and vmtx .. end table list Other tables are dumped as hexadecimal data. diff --git a/Tests/ttLib/tables/_l_c_a_r_test.py b/Tests/ttLib/tables/_l_c_a_r_test.py new file mode 100644 index 000000000..bb86f14cd --- /dev/null +++ b/Tests/ttLib/tables/_l_c_a_r_test.py @@ -0,0 +1,107 @@ +from __future__ import print_function, division, absolute_import +from fontTools.misc.py23 import * +from fontTools.misc.testTools import FakeFont, getXML, parseXML +from fontTools.misc.textTools import deHexStr, hexStr +from fontTools.ttLib import newTable +import unittest + + +# Example: Format 0 Ligature Caret Table +# https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6lcar.html +LCAR_FORMAT_0_DATA = deHexStr( + '0001 0000 0000 ' # 0: Version=1.0, Format=0 + '0006 0004 0002 ' # 6: LookupFormat=6, UnitSize=4, NUnits=2 + '0008 0001 0000 ' # 12: SearchRange=8, EntrySelector=1, RangeShift=0 + '0001 001E ' # 18: Glyph=1 (f_r), OffsetOfLigCaretEntry=30 + '0003 0022 ' # 22: Glyph=3 (f_f_l), OffsetOfLigCaretEntry=34 + 'FFFF 0000 ' # 26: Glyph=, OffsetOfLigCaretEntry=0 + '0001 00DC ' # 30: DivisionPointCount=1, DivisionPoint=[220] + '0002 00EF 01D8 ' # 34: DivisionPointCount=2, DivisionPoint=[239, 475] +) # 40: +assert(len(LCAR_FORMAT_0_DATA) == 40) + + +LCAR_FORMAT_0_XML = [ + '', + '', + '', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + '', +] + + +# Example: Format 1 Ligature Caret Table +# https://developer.apple.com/fonts/TrueType-Reference-Manual/RM06/Chap6lcar.html +LCAR_FORMAT_1_DATA = deHexStr( + '0001 0000 0001 ' # 0: Version=1.0, Format=1 + '0006 0004 0002 ' # 6: LookupFormat=6, UnitSize=4, NUnits=2 + '0008 0001 0000 ' # 12: SearchRange=8, EntrySelector=1, RangeShift=0 + '0001 001E ' # 18: Glyph=1 (f_r), OffsetOfLigCaretEntry=30 + '0003 0022 ' # 22: Glyph=3 (f_f_l), OffsetOfLigCaretEntry=34 + 'FFFF 0000 ' # 26: Glyph=, OffsetOfLigCaretEntry=0 + '0001 0032 ' # 30: DivisionPointCount=1, DivisionPoint=[50] + '0002 0037 004B ' # 34: DivisionPointCount=2, DivisionPoint=[55, 75] +) # 40: +assert(len(LCAR_FORMAT_1_DATA) == 40) + + +LCAR_FORMAT_1_XML = [ + '', + '', + '', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + ' ', + '', +] + + +class LCARTest(unittest.TestCase): + + @classmethod + def setUpClass(cls): + cls.maxDiff = None + cls.font = FakeFont(['.notdef', 'f_r', 'X', 'f_f_l']) + + def test_decompile_toXML_format0(self): + table = newTable('lcar') + table.decompile(LCAR_FORMAT_0_DATA, self.font) + self.assertEqual(getXML(table.toXML), LCAR_FORMAT_0_XML) + + 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)) + + def test_decompile_toXML_format1(self): + table = newTable('lcar') + table.decompile(LCAR_FORMAT_1_DATA, self.font) + self.assertEqual(getXML(table.toXML), LCAR_FORMAT_1_XML) + + def test_compile_fromXML_format1(self): + table = newTable('lcar') + for name, attrs, content in parseXML(LCAR_FORMAT_1_XML): + table.fromXML(name, attrs, content, font=self.font) + self.assertEqual(hexStr(table.compile(self.font)), + hexStr(LCAR_FORMAT_1_DATA)) + + +if __name__ == '__main__': + import sys + sys.exit(unittest.main())