Skip to content

Commit

Permalink
Do not write locl table if no substitutions table needed
Browse files Browse the repository at this point in the history
  • Loading branch information
Transfusion committed Apr 1, 2021
1 parent d8d3231 commit 8861d35
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions hanazono_lite/generateFeatures.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,23 @@ def generateFeatures(
(glyphwiki_to_cid[glyphwiki_code], glyphwiki_to_cid[resolved])
)

f.write("feature locl {\n")
# is the locl table NOT going to be empty?
has_locales = False
for _locale in LOCALES:
if _locale != locale and len(substitution_rules[_locale]):
f.write(f""" script hani;\n language {LOCALES[_locale]["tla"]};\n""")
has_locales = True
break

for (_from, _to) in substitution_rules[_locale]:
f.write(f""" substitute \{_from} by \{_to};\n""")
if has_locales:
f.write("feature locl {\n")
for _locale in LOCALES:
if _locale != locale and len(substitution_rules[_locale]):
f.write(f""" script hani;\n language {LOCALES[_locale]["tla"]};\n""")

for (_from, _to) in substitution_rules[_locale]:
f.write(f""" substitute \{_from} by \{_to};\n""")

f.write("} locl;\n")

f.write("} locl;\n")
f.write(FEATURES_FOOTER_TEMPLATE())
f.close()

0 comments on commit 8861d35

Please sign in to comment.