Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use a google font and include only [A-Z] and '&'

Is there a way to use a google font and have it load only [A-Z] and the & ampersand character?

I would like to do this to reduce size and improve load time, since I will only use basic latin numbers and letters.

I can host the font myself if I must and it is legal to manipulate the font package, but am not sure if self-hosting is necessary and how to manipulate google's font package.

I have specified A-Z like this:

http://fonts.googleapis.com/css?family=Inconsolata&text=ABCDEFGHIJKLMNOPQRSTUVWXYZ

but specifying & is troublesome. Both of these don't work:

<link href='http://fonts.googleapis.com/css?family=Inconsolata&text=ABC&amp;' rel='stylesheet' type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Inconsolata&text=ABC&' rel='stylesheet' type='text/css'>
like image 865
SimplGy Avatar asked Sep 05 '13 16:09

SimplGy


People also ask

How do I use multiple Google Fonts?

You click "select this font" for each font you want to use, and google will give you a single link tag with multiple fonts. You can also include multiple link tags for each font.

Does Google Fonts have all fonts?

All the fonts and icons in our catalog are open source and available to anyone, making beautiful typography and iconography accessible to anyone for any project. This means you can share favorites and collaborate easily with friends and colleagues.


2 Answers

There is no way to specify character ranges when including google fonts. The only way to do it is to specify each character like this:

http://fonts.googleapis.com/css?family=Inconsolata&text=ABCDEFGHIJKLMNOPQRSTUVWXYZ
like image 87
SimplGy Avatar answered Sep 24 '22 07:09

SimplGy


You can include special characters by url-encoding their UTF-8 representation.

& (U+0026) is 26 in UTF-8, so your url should have:

&text=ABCDEFGHIJKLMNOPQRSTUVWXYZ%26

Here's a handy tool for this: http://www.url-encode-decode.com/

like image 34
Adam Dąbrowski Avatar answered Sep 25 '22 07:09

Adam Dąbrowski