Check CJK punctuation in early non-CJK fonts
Added tests check that CJK punctuation marks do not appear in
non-CJK fonts that appear earlier than CJK fonts.
This should prevent bugs like those fixed by
Ic2cbc79cecf9539ace8a432f373685eeff81e106 and
Ieeb4c04ca785e07a5db94006a6da31ad040b7e7a to appear again.
Change-Id: I622dccd2a619b2366987a81d1c7f8f49334f5638
Fixes: 38182099
Bug: 19355391
Test: make -j fontchain_lint
diff --git a/tools/fonts/fontchain_lint.py b/tools/fonts/fontchain_lint.py
index c0475ee..c6ad4c2 100755
--- a/tools/fonts/fontchain_lint.py
+++ b/tools/fonts/fontchain_lint.py
@@ -3,7 +3,6 @@
import collections
import copy
import glob
-import itertools
from os import path
import sys
from xml.etree import ElementTree
@@ -574,8 +573,8 @@
all_sequences.add(sequence)
sequence_pieces.update(sequence)
if _emoji_sequences.get(sequence, None) == 'Emoji_Tag_Sequence':
- # Add reverse of all emoji ZWJ sequences, which are added to the fonts
- # as a workaround to get the sequences work in RTL text.
+ # Add reverse of all emoji ZWJ sequences, which are added to the
+ # fonts as a workaround to get the sequences work in RTL text.
# TODO: test if these are actually needed by Minikin/HarfBuzz.
reversed_seq = reverse_emoji(sequence)
all_sequences.add(reversed_seq)
@@ -630,12 +629,26 @@
if record.name in ['sans-serif', 'sans-serif-condensed']:
font = open_font(record.font)
assert font['head'].yMax == 2163 and font['head'].yMin == -555, (
- 'yMax and yMin of %s do not match expected values.' % (record.font,))
+ 'yMax and yMin of %s do not match expected values.' % (
+ record.font,))
- if record.name in ['sans-serif', 'sans-serif-condensed', 'serif', 'monospace']:
+ if record.name in ['sans-serif', 'sans-serif-condensed',
+ 'serif', 'monospace']:
font = open_font(record.font)
- assert font['hhea'].ascent == 1900 and font['hhea'].descent == -500, (
- 'ascent and descent of %s do not match expected values.' % (record.font,))
+ assert (font['hhea'].ascent == 1900 and
+ font['hhea'].descent == -500), (
+ 'ascent and descent of %s do not match expected '
+ 'values.' % (record.font,))
+
+
+def check_cjk_punctuation():
+ cjk_scripts = {'Hans', 'Hant', 'Jpan', 'Kore'}
+ cjk_punctuation = range(0x3000, 0x301F + 1)
+ for record in _fallback_chain:
+ if record.scripts.intersection(cjk_scripts):
+ # CJK font seen. Stop checking the rest of the fonts.
+ break
+ assert_font_supports_none_of_chars(record.font, cjk_punctuation)
def main():
@@ -651,6 +664,8 @@
hyphens_dir = path.join(target_out, 'usr', 'hyphen-data')
check_hyphens(hyphens_dir)
+ check_cjk_punctuation()
+
check_emoji = sys.argv[2]
if check_emoji == 'true':
ucd_path = sys.argv[3]