Search code examples
cssfont-face

font-face weight


I am using a purchase font (Museo Sans) for a custom font in an app I am working on. The files given to me when I purchased it contain web font files for different weights: MuseoSans100Regular, MuseoSans300Regular, etc. Is there a way in @font-face to specify the files to use for the different weights so that I can do this:

font-family: MuseoSans;
font-weight: 300;

Rather than this:

font-family: MuseoSans300;

Solution

  • Yes, you have to specify which file is for which font-weight in two different @font-face definitions:

    @font-face {
        font-family: 'MuseoSans';
        src: url('../font/museo_sans_100.woff');
        font-weight: 100;
        font-style: normal;
    }
    @font-face {
        font-family: 'MuseoSans';
        src: url('../font/museo_sans_300.woff');
        font-weight: 300;
        font-style: normal;
    }
    
    h1, p {
        font-family: MuseoSans;
    }
    
    h1 {
        font-weight: 300; /* uses museo_sans_300.woff */
    }
    
    p {
        font-weight: 100; /* uses museo_sans_100.woff*/
    }