Using Google Web Fonts with SASS/Compass -- how?

Doug Smith picture Doug Smith · Jul 17, 2013 · Viewed 12.2k times · Source

Say I have this font: Open Sans

If I want to use this with a SASS/Compass project, is there a better way to do it then linking to an additional stylesheet hosted by Google in order to be able to use the font?

Answer

steveax picture steveax · Jul 17, 2013

Use the @import option:

@import url(http://fonts.googleapis.com/css?family=Open+Sans);

Or the JavaScript Option:

<script type="text/javascript">
  WebFontConfig = {
    google: { families: [ 'Open+Sans::latin' ] }
  };
  (function() {
    var wf = document.createElement('script');
    wf.src = ('https:' == document.location.protocol ? 'https' : 'http') +
      '://ajax.googleapis.com/ajax/libs/webfont/1/webfont.js';
    wf.type = 'text/javascript';
    wf.async = 'true';
    var s = document.getElementsByTagName('script')[0];
    s.parentNode.insertBefore(wf, s);
  })(); </script>