summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoozbeh Pournader <roozbeh@google.com>2017-05-18 18:38:36 -0700
committerRoozbeh Pournader <roozbeh@google.com>2017-05-18 18:38:36 -0700
commit63d4d0d3580fc0e4d6ae1543b8ae1b186b8119de (patch)
tree24c91b9d44e6b6920d38cb0d45b84cfb20a48b3c
parent7ed8a5796465bb87d03bf81e5882d31cfb16d21d (diff)
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
-rwxr-xr-xtools/fonts/fontchain_lint.py29
1 files changed, 22 insertions, 7 deletions
diff --git a/tools/fonts/fontchain_lint.py b/tools/fonts/fontchain_lint.py
index c0475eeb0c7e..c6ad4c2aa396 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 @@ def compute_expected_emoji():
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 @@ def check_vertical_metrics():
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 @@ def main():
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]