From e58ffdb9821d2d3e0f92141e4b11f2e7d09170b4 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Wed, 22 Feb 2023 10:50:28 -0700 Subject: [PATCH] [qu2cu_cli_test] Tests --- ...otoSansArabic-Regular.quadratic.subset.ttf | Bin 0 -> 2612 bytes Tests/qu2cu/qu2cu_cli_test.py | 62 ++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 Tests/qu2cu/data/NotoSansArabic-Regular.quadratic.subset.ttf create mode 100644 Tests/qu2cu/qu2cu_cli_test.py diff --git a/Tests/qu2cu/data/NotoSansArabic-Regular.quadratic.subset.ttf b/Tests/qu2cu/data/NotoSansArabic-Regular.quadratic.subset.ttf new file mode 100644 index 0000000000000000000000000000000000000000..7a3181619f6d24125b589c437359de27df5bb390 GIT binary patch literal 2612 zcmbVNT})e59RHtt+gsW~+m(K|_fqH=<9q!C3WGsMsj!t&wy?3`I_M|~P=xOD!RfL% zG)puwSu~l^H)mor*@Mvs6B8eNGxK55m}#cQWQ+Rd5|_Ev|GD=T5Sg3an{)mj=bYdF z^PUR?0BYa`U|}qo*gFJaXaG>pqP8(Pmd+*$qcbR9M%kUr9vJv3@#}Sz-$!{Zoox@U zou4`kph6Lj%`E1Yxe4w(%EwUdnOit};?sEZL*#D(D328Kx!LGf=XL^cCDcU=sBm94 ze}*!ygSW6)I^&xlEhtm`j)me(PQ6gYqdbYSV=;GT8T#3eQSL<9y_8$b*T2`DM0-~O z$hGC-YN`A-1kt|)T?Ya}`4{#>@;bQCeuF;}j>fDUXEs?Zp&)+mpFZ!~+TFam#+{cIZ`e(bGyOvwy*|1GQR-7hT@c$Ee zH?v^{;W*aFKatWI!=W8IyH4$E^sjaa?(s1pk@4_#ZkN8g?eH@#Qas84 zIRu&i7LQmufei)M)B8Wd3brb$QkV zq4E^oY8WHYGSi?1D+B;)#am##aqvcvcs3S{Zu&~THS@gL#Pe^-G_Q#dxTKUXlLx%X zBnT#4mgytF#IN`G>;%Ym-z7hbc07n_EmX z(F$~hirKGbzJPl84Y6n~HXap?AD>nzzzs4$UL|+QJ%%v7%*)INsHeLbX8#)(>aIPj z@3{vodxvhnRr>r(N^jeX<+AtTEtg7}Mv)UMiVQOe)9eo*DE8v`1jjuPSOX?|9EYqY z^piVDQNTg%D5oC^0IqP^`)AIj+TtfbH7MAFm?$fGoh?;x}xw+A%~NXOUDuZmJ0R&nPFoWgk) zckaj2B^++ZLJpR2m7ZNe{y3hT!Si`UKZ#g5)CTcH2fkepN6Tq^lgL#tDhQj;w{AhG z?0uX)>hWfa2SsmJ(U&56M{`i|pn~)?R;6x-@>M*)-Gf!eDoKwGd4jdj;7s+j2k9U< z)1ku^szE6+G&%uQ*d_ST4iVRl=%ohFH=(U=V8lJ$xs}{;l-LvVOF8J6Uz#sLbTL0W r4?Qw&n@s6Hm*O;u9Y{Iq0oBo&zJlnVjdlwdaZt-NKDv_*7F2%$W4)A) literal 0 HcmV?d00001 diff --git a/Tests/qu2cu/qu2cu_cli_test.py b/Tests/qu2cu/qu2cu_cli_test.py new file mode 100644 index 000000000..55cd27180 --- /dev/null +++ b/Tests/qu2cu/qu2cu_cli_test.py @@ -0,0 +1,62 @@ +import os + +import pytest +import py + +from fontTools.qu2cu.cli import main +from fontTools.ttLib import TTFont + + +DATADIR = os.path.join(os.path.dirname(__file__), "data") + +TEST_TTFS = [ + py.path.local(DATADIR).join("NotoSansArabic-Regular.quadratic.subset.ttf"), +] + + +@pytest.fixture +def test_paths(tmpdir): + result = [] + for path in TEST_TTFS: + new_path = tmpdir / path.basename + path.copy(new_path) + result.append(new_path) + return result + + +class MainTest(object): + @staticmethod + def run_main(*args): + main([str(p) for p in args if p]) + + def test_no_output(self, test_paths): + ttf_path = test_paths[0] + + self.run_main(ttf_path) + + output_path = str(ttf_path).replace(".ttf", ".cubic.ttf") + font = TTFont(output_path) + assert font["head"].glyphDataFormat == 1 + assert os.stat(ttf_path).st_size > os.stat(output_path).st_size + + def test_output_file(self, test_paths): + ttf_path = test_paths[0] + output_path = str(ttf_path) + ".cubic" + + self.run_main(ttf_path, "-o", output_path) + + font = TTFont(output_path) + assert font["head"].glyphDataFormat == 1 + + def test_stats(self, test_paths): + ttf_path = test_paths[0] + self.run_main(ttf_path, "--verbose") + + def test_all_cubic(self, test_paths): + ttf_path = test_paths[0] + + self.run_main(ttf_path, "-c") + + output_path = str(ttf_path).replace(".ttf", ".cubic.ttf") + font = TTFont(output_path) + assert font["head"].glyphDataFormat == 1