Skip to content

Extract the font features in one method? #2873

Answered by ftCLI
JaavierR asked this question in Q&A
Discussion options

You must be logged in to vote

This is the function I use to get a list feature tags:

def get_font_feature_tags(font: TTFont) -> list:

    feature_tags = []

    for table in ("GSUB", "GPOS"):
        if table in font.keys():
            try:
                feature_tags += [tag.FeatureTag for tag in font[table].table.FeatureList.FeatureRecord]
            except KeyError:
                pass

    return sorted(list(set(feature_tags)))

Replies: 2 comments 3 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@justvanrossum
Comment options

@JaavierR
Comment options

@jsbien
Comment options

Answer selected by JaavierR
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants