Created
April 5, 2024 21:07
-
-
Save moyogo/3cff7af7af9d3670ee0ec7f49d3dddb4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import glyphsets | |
from gflanguages import LoadLanguages | |
from fontTools import unicodedata | |
def get_decomposed_chars(glyphset_name, langs=None): | |
if langs is None: | |
langs = LoadLanguages() | |
allchars = set() | |
for lang_code in glyphsets.languages_per_glyphset(glyphset_name): | |
lang = langs[lang_code] | |
allchars.update(getattr(getattr(lang, "exemplar_chars", {}), "base", "").split(" ")) | |
if glyphsets.get_glyphset_definition(glyphset_name).get("use_auxiliary"): | |
allchars.update(getattr(getattr(lang, "exemplar_chars", {}), "auxiliary", "").split(" ")) | |
decomposed_chars = sorted([ | |
g[1:-1] for g in allchars | |
if any(unicodedata.combining(c) for c in g) and g.startswith("{") and g.endswith("}") | |
]) | |
return decomposed_chars | |
if __name__ == "__main__": | |
import sys | |
args = sys.argv[1:] | |
if not len(args): | |
print("Provide a glyphset name") | |
for arg in args: | |
print(arg) | |
print(" ".join(get_decomposed_chars(arg))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment