def genCSS(font, base):
    """Generates a CSS snippet for webfont usage based on:
    http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax"""

    style = "normal"
    if font["post"].italicAngle != 0:
        style = "oblique"
    weight = font["OS/2"].usWeightClass
    family = font["name"].getName(nameID=1, platformID=1, platEncID=0)

    css = """
@font-face {
    font-family: %(family)s;
    font-style: %(style)s;
    font-weight: %(weight)s;
    src: url('%(base)s.eot') format('eot');
    src: url('%(base)s.eot?#iefix') format('embedded-opentype'),
         url('%(base)s.woff2') format('woff2'),
         url('%(base)s.woff') format('woff'),
         url('%(base)s.ttf')  format('truetype');
}
""" %{"style":style, "weight":weight, "family":family, "base":base}

    return css