def getAngledAttrIfNecessary(font, attr):
    """
    Coerce "leftMargin" or "rightMargin" to
    "angledLeftMargin" or "angledRightMargin"
    if the font is italic.
    """
    useAngledMargins = font.info.italicAngle != 0
    if useAngledMargins:
        if attr == "leftMargin":
            attr = "angledLeftMargin"
        elif attr == "rightMargin":
            attr = "angledRightMargin"
    return attr