10The fonts collected by this script are used by SkParagraphTests.cpp which uses measurements
11that are very particular to the specific font being used. Thus, we try to get the fonts from
12a repeatable, documented source.
32ARABIC_URL =
'https://fonts.gstatic.com/s/notonaskharabic/v33/RrQ5bpV-9Dd1b1OAGA6M9PkyDuVBePeKNaxcsss0Y7bwvc5krK0z9_Mnuw.ttf'
33ARABIC_SHA256 =
'b957e8c71a24e50c1aad4df775c46282bbe5e62e2b2b2ca72b153d75b6a15edd'
36 """Copy the fonts from two different git repos into one folder."""
37 os.makedirs(target_dir, exist_ok=
True)
38 with tempfile.TemporaryDirectory()
as tmp:
40 subprocess.call([
'git',
'clone',
'https://github.com/Rusino/textlayout'])
41 subprocess.call([
'git',
'clone',
'https://skia.googlesource.com/skia/'])
43 os.chdir(os.path.join(tmp,
"textlayout"))
44 subprocess.call([
'git',
'checkout',
'9c1868e84da1db358807ebff5cf52327e53560a0'])
45 shutil.copytree(
"fonts", target_dir, dirs_exist_ok=
True)
47 os.chdir(os.path.join(tmp,
"skia"))
48 subprocess.call([
'git',
'checkout',
'2f82ef6e77774dc4e8e382b2fb6159c58c0f8725'])
49 shutil.copytree(os.path.join(
"resources",
"fonts"), target_dir, dirs_exist_ok=
True)
51 shutil.rmtree(os.path.join(target_dir,
"abc"))
52 shutil.rmtree(os.path.join(target_dir,
"svg"))
53 os.remove(os.path.join(target_dir,
"fonts.xml"))
55 target_file = os.path.join(target_dir,
'NotoNaskhArabic-Regular.ttf')
56 subprocess.call([
'wget',
'--quiet',
'--output-document', target_file, ARABIC_URL])
57 output = subprocess.check_output([
'sha256sum', target_file], encoding=
'utf-8')
58 actual_hash = output.split(
' ')[0]
59 if actual_hash != ARABIC_SHA256:
60 raise Exception(
'SHA256 does not match (%s != %s)' % (actual_hash, ARABIC_SHA256))
64 parser = argparse.ArgumentParser()
65 parser.add_argument(
'--target_dir',
'-t', required=
True)
66 args = parser.parse_args()
70if __name__ ==
'__main__':
def create_asset(target_dir)