diff options
author | Seigo Nonaka <nona@google.com> | 2017-01-06 16:54:52 +0900 |
---|---|---|
committer | Seigo Nonaka <nona@google.com> | 2017-01-11 17:46:52 +0900 |
commit | 9092dc2fa8457858a8e9eab10d91e36225359f5a (patch) | |
tree | f2ac11185210459e311106ee1941f7ab3d94d750 | |
parent | 3b6bcfb65d3a869ac36f5fea9a78820e1268470a (diff) |
Check the count of the families in a default collection.
After I9e01d237c9adcb05e200932401cb1a4780049f86, Minikin can
accept up to 254 font families. To make sure we don't exeed this limit,
introduce an assertion to fontchain_lint.py
Bug: 33562608
Test: m fontchain_lint
Change-Id: I35fc104fd4763f77145bef0e7c5facf30fa99644
-rwxr-xr-x | tools/fonts/fontchain_lint.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/fonts/fontchain_lint.py b/tools/fonts/fontchain_lint.py index 219fa2de7e50..f193ea41dff9 100755 --- a/tools/fonts/fontchain_lint.py +++ b/tools/fonts/fontchain_lint.py @@ -204,7 +204,13 @@ def parse_fonts_xml(fonts_xml_path): _script_to_font_map = collections.defaultdict(set) _fallback_chain = [] tree = ElementTree.parse(fonts_xml_path) - for family in tree.findall('family'): + families = tree.findall('family') + # Minikin supports up to 254 but users can place their own font at the first + # place. Thus, 253 is the maximum allowed number of font families in the + # default collection. + assert len(families) < 254, ( + 'System font collection can contains up to 253 font families.') + for family in families: name = family.get('name') variant = family.get('variant') langs = family.get('lang') |