def parse_font(font):
    token = []
    tokens = []
    quotechar = None
    for char in font:
        if quotechar is not None:
            if char == quotechar:
                tokens.append(''.join(token))
                token = []
                quotechar = None
            else:
                token.append(char)
        elif char == '"' or char == "'":
            quotechar = char
        elif char in ' \t':
            if token:
                tokens.append(''.join(token))
                token = []
        else:
            token.append(char)

    # Failed to close quoted string.
    if quotechar is not None:
        return

    if token:
        tokens.append(''.join(token))

    sizes = []
    families = []
    optionals = []
    for token in tokens:
        if token in _STYLES or token in _VARIANTS or token in _WEIGHTS:
            if len(sizes) > 0 or len(families) > 0:
                return None
            optionals.append(token)
        elif token in _SIZES or token[-2:] in _UNITS:
            if len(families) > 0:
                return None
            sizes.append(token)
        else:
            families.append(token)

    if len(optionals) > 3:
        return None
    if len(sizes) != 1:
        return None
    if len(families) != 1:
        return None

    style = None
    variant = None
    weight = None

    for opt in optionals:
        if opt == 'normal':
            continue
        elif opt in _STYLES:
            if style is not None:
                return None
            style = opt
        elif opt in _VARIANTS:
            if variant is not None:
                return None
            variant = opt
        elif opt in _WEIGHTS:
            if weight is not None:
                return None
            weight = opt
        else:
            return None

    size = sizes[0]
    if size in _SIZES:
        size = _SIZES[size]
    else:
        sizenum, units = size[:-2], size[-2:]
        try:
            sizenum = float(sizenum)
        except ValueError:
            return None
        size = _UNITS[units](sizenum)

    family = str(families[0])
    weight = _WEIGHTS[weight] if weight else _WEIGHTS['normal']
    style = _STYLES[style] if style else _STYLES['normal']
    variant = _VARIANTS[variant] if variant else _VARIANTS['normal']

    return Font(family, size, weight, style, variant)
Wait for all of the Windows synchronisation objects in the list to fire.
dataset/ETHPy150Open ContinuumIO/ashiba/enaml/enaml/fonts.py/parse_font--crossover with--dataset/ETHPy150Open tjguk/winsys/winsys/ipc.py/all