def guessFont(fname):
    """Given a font name like "Tahoma-BoldOblique", "Bitstream Charter Italic"
    or "Perpetua Bold Italic" guess what it means.

    Returns (family, x) where x is
        0: regular
        1: bold
        2: italic
        3: bolditalic

    """
    italic = 0
    bold = 0
    if '-' not in fname:
        sfx = {'Bold': 1, 'Bold Italic': 3, 'Bold Oblique': 3, 'Italic': 2,
            'Oblique': 2}
        for key in sfx:
            if fname.endswith(' ' + key):
                return fname.rpartition(key)[0], sfx[key]
        return fname, 0
    else:
        family, mod = fname.rsplit('-', 1)
    mod = mod.lower()
    if 'oblique' in mod or 'italic' in mod:
        italic = 1
    if 'bold' in mod:
        bold = 1
    if bold + italic == 0:
        return fname, 0
    return family, bold + 2 * italic
