Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku and Google Fonts

Tags:

heroku

fonts

Why doesn't embedding google fonts work on Heroku?

For example:

<link href='http://fonts.googleapis.com/css?family=<some_kinda_font>' rel='stylesheet' type='text/css'>

EDIT: turns out it works, one of my chrome extensions was blocking it as an "insecure script"

like image 731
nlsun Avatar asked Jun 05 '13 20:06

nlsun


People also ask

Can you self host Google Fonts?

To self-host, you need to download the fonts and write the appropriate @font-face CSS rules. Instead of doing this myself, I came across an excellent tool to streamline this process: google-fonts-helper. It holds the entire Google Fonts catalog.

How do I get TTF files from Google Fonts?

Step 1: Download the Google Fonts TTF Files Google makes all the TTF files for its fonts fairly accessible. I recommend that you go to the GitHub project “Google Font Directory” and download the zip file or the tarball, and select the fonts you want. The page also has instructions for updating the fonts.

How do I download WOFF from Google Fonts?

While there is not a mainstream CDN for all the formats, you can use http://google-webfonts-helper.herokuapp.com to download the font files and host them yourselves.

Are Google Fonts free for commercial use?

No, all Google Fonts are open source and are without cost.


2 Answers

I discovered that heroku sets security parameters for using the google fonts url. It wants to use the https instead of plain http. Here's what worked for me.

Instead of:

@import url('http://fonts.googleapis.com/css?family=Oswald:400,700,300');

I used

@import url('//fonts.googleapis.com/css?family=Oswald:400,700,300');

If you notice the second line leaves out the http, allowing heroku to use https. I'm assuming you could probably use https in the link if you wanted to.

like image 166
AfDev Avatar answered Sep 21 '22 18:09

AfDev


Simply use HTTPS instead of HTTP:

<%= stylesheet_link_tag "application", 'https://fonts.googleapis.com/css?family=<font_name>', :media => "all" %>
like image 23
Yosep Kim Avatar answered Sep 20 '22 18:09

Yosep Kim