diff options
Diffstat (limited to 'Lib/fontTools/unicodedata/__init__.py')
-rw-r--r-- | Lib/fontTools/unicodedata/__init__.py | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/Lib/fontTools/unicodedata/__init__.py b/Lib/fontTools/unicodedata/__init__.py index 8845b829..4546ef3f 100644 --- a/Lib/fontTools/unicodedata/__init__.py +++ b/Lib/fontTools/unicodedata/__init__.py @@ -1,11 +1,11 @@ -from fontTools.misc.py23 import byteord, tostr +from fontTools.misc.textTools import byteord, tostr import re from bisect import bisect_right try: # use unicodedata backport compatible with python2: - # https://github.com/mikekap/unicodedata2 + # https://github.com/fonttools/unicodedata2 from unicodedata2 import * except ImportError: # pragma: no cover # fall back to built-in unicodedata (possibly outdated) @@ -73,7 +73,7 @@ def script_extension(char): >>> script_extension("a") == {'Latn'} True - >>> script_extension(chr(0x060C)) == {'Rohg', 'Syrc', 'Yezi', 'Arab', 'Thaa'} + >>> script_extension(chr(0x060C)) == {'Rohg', 'Syrc', 'Yezi', 'Arab', 'Thaa', 'Nkoo'} True >>> script_extension(chr(0x10FFFF)) == {'Zzzz'} True @@ -134,8 +134,10 @@ def script_code(script_name, default=KeyError): return default -# The data on script direction is taken from CLDR 37: -# https://github.com/unicode-org/cldr/blob/release-37/common/properties/scriptMetadata.txt +# The data on script direction is taken from Harfbuzz source code: +# https://github.com/harfbuzz/harfbuzz/blob/3.2.0/src/hb-common.cc#L514-L613 +# This in turn references the following "Script_Metadata" document: +# https://docs.google.com/spreadsheets/d/1Y90M0Ie3MUJ6UVCRDOypOtijlMDLNNyyLk36T6iMu0o RTL_SCRIPTS = { # Unicode-1.1 additions 'Arab', # Arabic @@ -200,6 +202,9 @@ RTL_SCRIPTS = { # Unicode-13.0 additions 'Chrs', # Chorasmian 'Yezi', # Yezidi + + # Unicode-14.0 additions + 'Ougr', # Old Uyghur } def script_horizontal_direction(script_code, default=KeyError): @@ -259,6 +264,9 @@ def ot_tag_to_script(tag): if not tag or " " in tag or len(tag) > 4: raise ValueError("invalid OpenType tag: %r" % tag) + if tag in OTTags.SCRIPT_ALIASES: + tag = OTTags.SCRIPT_ALIASES[tag] + while len(tag) != 4: tag += str(" ") # pad with spaces |