def check_monospace(familydir):
    files = listdir(familydir)
    glyphwidths = []
    for f in files:
        if not unicode(f).endswith('.ttf'):
            continue
        font = fontToolsOpenFont(unicode(f))
        for table in font['cmap'].tables:
            if not (table.platformID == 3 and table.platEncID in [1, 10]):
                continue

            for glyphname in table.cmap:
                try:
                    glyphwidths.append(font['hmtx'][glyphname][0])
                except (__HOLE__, KeyError):
                    # can't read hmtx for glyphname, append value of zero
                    glyphwidths.append(0)
    # if all glyphs has the same widths then it is easy to check
    # by casting list to python sets.
    return len(set(glyphwidths)) == 1
dataset/ETHPy150Open googlefonts/fontbakery/bakery_cli/scripts/genmetadata.py/check_monospace