diff options
author | Haibo Huang <hhb@google.com> | 2019-05-31 16:12:23 -0700 |
---|---|---|
committer | Haibo Huang <hhb@google.com> | 2019-05-31 16:12:23 -0700 |
commit | 4c8220a6a278f97eb1b758cd0909ca26122725d6 (patch) | |
tree | bf49f60791568d4b7b626c1f45960f35e53ed78e /Tests/subset | |
parent | d648c2a4868c62db146c13f62b38d749db674ab2 (diff) | |
download | fonttools-4c8220a6a278f97eb1b758cd0909ca26122725d6.tar.gz |
Upgrade fonttools to 3.42.0android-o-mr1-iot-release-1.0.13
Test: None
Change-Id: I64e8371d40855b1edb739c8e4ed63f98b92ed7d3
Diffstat (limited to 'Tests/subset')
-rw-r--r-- | Tests/subset/data/expect_HVVAR_retain_gids.ttx | 5 | ||||
-rw-r--r-- | Tests/subset/subset_test.py | 79 |
2 files changed, 61 insertions, 23 deletions
diff --git a/Tests/subset/data/expect_HVVAR_retain_gids.ttx b/Tests/subset/data/expect_HVVAR_retain_gids.ttx index da2eaf4f..8e51ca7f 100644 --- a/Tests/subset/data/expect_HVVAR_retain_gids.ttx +++ b/Tests/subset/data/expect_HVVAR_retain_gids.ttx @@ -8,7 +8,6 @@ <GlyphID id="2" name="B"/> <GlyphID id="3" name="glyph00003"/> <GlyphID id="4" name="D"/> - <GlyphID id="5" name="glyph00005"/> </GlyphOrder> <HVAR> @@ -63,7 +62,6 @@ <Map glyph="D" outer="0" inner="3"/> <Map glyph="glyph00001" outer="0" inner="0"/> <Map glyph="glyph00003" outer="0" inner="0"/> - <Map glyph="glyph00005" outer="0" inner="3"/> </LsbMap> <RsbMap> <Map glyph=".notdef" outer="0" inner="1"/> @@ -71,7 +69,6 @@ <Map glyph="D" outer="1" inner="1"/> <Map glyph="glyph00001" outer="0" inner="0"/> <Map glyph="glyph00003" outer="0" inner="0"/> - <Map glyph="glyph00005" outer="1" inner="1"/> </RsbMap> </HVAR> @@ -132,7 +129,6 @@ <Map glyph="D" outer="1" inner="1"/> <Map glyph="glyph00001" outer="0" inner="0"/> <Map glyph="glyph00003" outer="0" inner="0"/> - <Map glyph="glyph00005" outer="1" inner="1"/> </AdvHeightMap> <VOrgMap> <Map glyph=".notdef" outer="1" inner="2"/> @@ -140,7 +136,6 @@ <Map glyph="D" outer="1" inner="3"/> <Map glyph="glyph00001" outer="0" inner="0"/> <Map glyph="glyph00003" outer="0" inner="0"/> - <Map glyph="glyph00005" outer="1" inner="3"/> </VOrgMap> </VVAR> diff --git a/Tests/subset/subset_test.py b/Tests/subset/subset_test.py index eb632dc0..956197a3 100644 --- a/Tests/subset/subset_test.py +++ b/Tests/subset/subset_test.py @@ -465,6 +465,46 @@ class SubsetTest(unittest.TestCase): subsetfont = TTFont(subsetpath) self.expect_ttx(subsetfont, self.getpath("expect_notdef_width_cid.ttx"), ["CFF "]) + def test_recalc_bounds_ttf(self): + ttxpath = self.getpath("TestTTF-Regular.ttx") + font = TTFont() + font.importXML(ttxpath) + head = font['head'] + bounds = [head.xMin, head.yMin, head.xMax, head.yMax] + + _, fontpath = self.compile_font(ttxpath, ".ttf") + subsetpath = self.temp_path(".ttf") + + # by default, the subsetter does not recalculate the bounding box + subset.main([fontpath, "--output-file=%s" % subsetpath, "*"]) + head = TTFont(subsetpath)['head'] + self.assertEqual(bounds, [head.xMin, head.yMin, head.xMax, head.yMax]) + + subset.main([fontpath, "--recalc-bounds", "--output-file=%s" % subsetpath, "*"]) + head = TTFont(subsetpath)['head'] + bounds = [132, 304, 365, 567] + self.assertEqual(bounds, [head.xMin, head.yMin, head.xMax, head.yMax]) + + def test_recalc_bounds_otf(self): + ttxpath = self.getpath("TestOTF-Regular.ttx") + font = TTFont() + font.importXML(ttxpath) + head = font['head'] + bounds = [head.xMin, head.yMin, head.xMax, head.yMax] + + _, fontpath = self.compile_font(ttxpath, ".otf") + subsetpath = self.temp_path(".otf") + + # by default, the subsetter does not recalculate the bounding box + subset.main([fontpath, "--output-file=%s" % subsetpath, "*"]) + head = TTFont(subsetpath)['head'] + self.assertEqual(bounds, [head.xMin, head.yMin, head.xMax, head.yMax]) + + subset.main([fontpath, "--recalc-bounds", "--output-file=%s" % subsetpath, "*"]) + head = TTFont(subsetpath)['head'] + bounds = [132, 304, 365, 567] + self.assertEqual(bounds, [head.xMin, head.yMin, head.xMax, head.yMax]) + def test_recalc_timestamp_ttf(self): ttxpath = self.getpath("TestTTF-Regular.ttx") font = TTFont() @@ -530,20 +570,20 @@ class SubsetTest(unittest.TestCase): "--retain-gids", "--output-file=%s" % subsetpath, "--glyph-names", - "A", + "B", ] ) subsetfont = TTFont(subsetpath) - self.assertEqual(subsetfont.getGlyphOrder(), font.getGlyphOrder()) + self.assertEqual(subsetfont.getGlyphOrder(), font.getGlyphOrder()[0:3]) hmtx = subsetfont["hmtx"] - self.assertEqual(hmtx["A"], (500, 132)) - self.assertEqual(hmtx["B"], (0, 0)) + self.assertEqual(hmtx["A"], ( 0, 0)) + self.assertEqual(hmtx["B"], (400, 132)) glyf = subsetfont["glyf"] - self.assertGreater(glyf["A"].numberOfContours, 0) - self.assertEqual(glyf["B"].numberOfContours, 0) + self.assertEqual(glyf["A"].numberOfContours, 0) + self.assertGreater(glyf["B"].numberOfContours, 0) def test_retain_gids_cff(self): _, fontpath = self.compile_font(self.getpath("TestOTF-Regular.ttx"), ".otf") @@ -551,11 +591,13 @@ class SubsetTest(unittest.TestCase): self.assertEqual(font["hmtx"]["A"], (500, 132)) self.assertEqual(font["hmtx"]["B"], (400, 132)) + self.assertEqual(font["hmtx"]["C"], (500, 0)) font["CFF "].cff[0].decompileAllCharStrings() cs = font["CFF "].cff[0].CharStrings self.assertGreater(len(cs["A"].program), 0) self.assertGreater(len(cs["B"].program), 0) + self.assertGreater(len(cs["C"].program), 0) subsetpath = self.temp_path(".otf") subset.main( @@ -564,21 +606,22 @@ class SubsetTest(unittest.TestCase): "--retain-gids", "--output-file=%s" % subsetpath, "--glyph-names", - "A", + "B", ] ) subsetfont = TTFont(subsetpath) - self.assertEqual(subsetfont.getGlyphOrder(), font.getGlyphOrder()) + self.assertEqual(subsetfont.getGlyphOrder(), font.getGlyphOrder()[0:3]) hmtx = subsetfont["hmtx"] - self.assertEqual(hmtx["A"], (500, 132)) - self.assertEqual(hmtx["B"], (0, 0)) + self.assertEqual(hmtx["A"], (0, 0)) + self.assertEqual(hmtx["B"], (400, 132)) subsetfont["CFF "].cff[0].decompileAllCharStrings() cs = subsetfont["CFF "].cff[0].CharStrings - self.assertGreater(len(cs["A"].program), 0) - self.assertEqual(cs["B"].program, ["endchar"]) + + self.assertEqual(cs["A"].program, ["endchar"]) + self.assertGreater(len(cs["B"].program), 0) def test_retain_gids_cff2(self): ttx_path = self.getpath("../../varLib/data/master_ttx_varfont_otf/TestCFF2VF.ttx") @@ -598,21 +641,21 @@ class SubsetTest(unittest.TestCase): fontpath, "--retain-gids", "--output-file=%s" % subsetpath, - "A", + "T", ] ) subsetfont = TTFont(subsetpath) - self.assertEqual(len(subsetfont.getGlyphOrder()), len(font.getGlyphOrder())) + self.assertEqual(len(subsetfont.getGlyphOrder()), len(font.getGlyphOrder()[0:3])) hmtx = subsetfont["hmtx"] - self.assertEqual(hmtx["A"], (600, 31)) - self.assertEqual(hmtx["glyph00002"], (0, 0)) + self.assertEqual(hmtx["glyph00001"], ( 0, 0)) + self.assertEqual(hmtx["T"], (600, 41)) subsetfont["CFF2"].cff[0].decompileAllCharStrings() cs = subsetfont["CFF2"].cff[0].CharStrings - self.assertGreater(len(cs["A"].program), 0) - self.assertEqual(cs["glyph00002"].program, []) + self.assertEqual(cs["glyph00001"].program, []) + self.assertGreater(len(cs["T"].program), 0) def test_HVAR_VVAR(self): _, fontpath = self.compile_font(self.getpath("TestHVVAR.ttx"), ".ttf") |