Search code examples
cssfontsofflinegoogle-fonts

Downloading a Google font and setting up an offline site that uses it


I have a template and it has a reference to a Google font like this:

<link href='http://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,400,600,300' rel='stylesheet' type='text/css'>

How can I download it and set it up to use in my pages which are running offline all the time?


Solution

  • Just go to Google Fonts - http://www.google.com/fonts/ , add the font you like to your collection, and press the download button. And then just use the @fontface to connect this font to your web page. Btw, if you open the link you are using, you'll see an example of using @fontface

    http://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,400,600,300
    

    For an example

    @font-face {
      font-family: 'Open Sans';
      font-style: normal;
      font-weight: 300;
      src: local('Open Sans Light'), local('OpenSans-Light'), url(http://themes.googleusercontent.com/static/fonts/opensans/v6/DXI1ORHCpsQm3Vp6mXoaTaRDOzjiPcYnFooOUGCOsRk.woff) format('woff');
    }
    

    Just change the url address to the local link on the font file, you've downloaded.

    You can do it even easier.

    Just download the file, you've linked:

    http://fonts.googleapis.com/css?family=Open+Sans:400italic,600italic,400,600,300
    

    Name it opensans.css or so.

    Then just change the links in url() to your path to font files.

    And then replace your example string with:

    <link href='opensans.css' rel='stylesheet' type='text/css'>