How to add Google Web Fonts directly to your stylesheet

If you're using a CMS such as Drupal or Wordpress, it's not possible to add the link tag for the css file that google provides you&ndash; i.e. <link href=',700,300' rel='stylesheet' type='text/css'>&ndash;without installing a module that would allow it (and who wants another module to maintain?).

Here's a quick workaround I discovered that makes it really easy to simply add the css code you need directly to your stylesheet. If you look closely at the link code that google provides, it's for an offsite style sheet. Simply take the URL of the href attribute, put it in your browser, and open it. Now you have the css code! What's happening behind the scenes is Google's server side processing (likely php, ruby, python, etc) is simply constructing the necessary css code according to what the the URL parameters are. 


Put that URL in your browser, you'll get this code:

  1. @font-face {
  2.   font-family: 'Oswald';
  3.   font-style: normal;
  4.   font-weight: 300;
  5.   src: local('Oswald Light'), local('Oswald-Light'), url(<a href=""></a>) format('woff');
  6. }
  7. @font-face {
  8.   font-family: 'Oswald';
  9.   font-style: normal;
  10.   font-weight: 400;
  11.   src: local('Oswald Regular'), local('Oswald-Regular'), url(<a href=""></a>) format('woff');
  12. }
  13. @font-face {
  14.   font-family: 'Oswald';
  15.   font-style: normal;
  16.   font-weight: 700;
  17.   src: local('Oswald Bold'), local('Oswald-Bold'), url(<a href=""></a>) format('woff');
  18. }