How can I use Google's Roboto font on a website?

how to search on google effectively
google search tips pdf
google search tricks list
google search tips for students
"web search tips" and tricks
google search help
google search operators
how to google joke

I want to use Google's Roboto font on my website and I am following this tutorial:

http://www.maketecheasier.com/use-google-roboto-font-everywhere/2012/03/15

I have downloaded the file which has a folder structure like this:

Now I have three questions:

  1. I have css in my media/css/main.css url. So where do I need to put that folder?
  2. Do I need to extract all eot,svg etc from all sub folder and put in fonts folder?
  3. Do I need to create css file fonts.css and include in my base template file?

The example he uses this

@font-face {
    font-family: 'Roboto';
    src: url('Roboto-ThinItalic-webfont.eot');
    src: url('Roboto-ThinItalic-webfont.eot?#iefix') format('embedded-opentype'),
         url('Roboto-ThinItalic-webfont.woff') format('woff'),
         url('Roboto-ThinItalic-webfont.ttf') format('truetype'),
         url('Roboto-ThinItalic-webfont.svg#RobotoThinItalic') format('svg'); (under the Apache Software License). 
    font-weight: 200;
    font-style: italic;
}

What should my url look like, if I want to have the dir structure like:

/media/fonts/roboto

How to search on Google - Google Search Help, Below, tips on how to search on Google. Step 1: Go To Google (But Which Google?) Step 2: Go To Google Via A Toolbar. Step 3: Enter Your Search Terms. Step 4: Review Your Search Results. Step 5: Preview Your Answers. Step 6: Refine Your Google Search. Step 7: Congratulate Yourself! Using your mouse, click and drag the blue Google icon below to the home icon located in the upper right corner of your browser. Then click yes in the pop-up box. Option 2: Edit your preferences

There are TWO approaches that you can take to use licensed web-fonts on your pages:

  1. Font Hosting Services like Typekit, Fonts.com, Fontdeck, etc., provide an easy interface for designers to manage fonts purchased, and generate a link to a dynamic CSS or JavaScript file that serves up the font. Google even provides this service for free (here is an example for the Roboto font you requested). Typekit is the only service to provide additional font hinting to ensure fonts occupy the same pixels across browsers.

    JS font loaders like the one used by Google and Typekit (i.e. WebFont loader) provide CSS classes and callbacks to help manage the FOUT that may occur, or response timeouts when downloading the font.

    <head>
      <!-- get the required files from 3rd party sources -->
      <link href='http://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
    
      <!-- use the font -->
      <style>
        body {
          font-family: 'Roboto', sans-serif;
          font-size: 48px;
        }
      </style>
    </head>
    
  2. The DIY approach involves getting a font licensed for web use, and (optionally) using a tool like FontSquirrel's generator (or some software) to optimize its file size. Then, a cross-browser implementation of the standard @font-face CSS property is used to enable the font(s).

    This approach can provides better load performance since you have a more granular control over the characters to include and hence the file-size.

    /* get the required local files */
    @font-face {
      font-family: 'Roboto';
      src: url('roboto.eot'); /* IE9 Compat Modes */
      src: url('roboto.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
      url('roboto.woff') format('woff'), /* Modern Browsers */
      url('roboto.ttf')  format('truetype'), /* Safari, Android, iOS */
      url('roboto.svg#svgFontName') format('svg'); /* Legacy iOS */
    }
    
    /* use the font */
    body {
      font-family: 'Roboto', sans-serif;
      font-size: 48px;
    }
    
Long story short:

Using font hosting services along with @font-face declaration gives best output with respect to overall performance, compatibility and availability.

Source: https://www.artzstudio.com/2012/02/web-font-performance-weighing-fontface-options-and-alternatives/


UPDATE

Roboto: Google’s signature font is now open source

You can now manually generate the Roboto fonts using instructions that can be found here.

How To Use Google To Search, How to Use Google. Google may be synonymous with searching the Internet, but the services they offer are far broader than simple searching. From email to  Search the world's information, including webpages, images, videos and more. Google has many special features to help you find exactly what you're looking for.

Old post, I know.

This is also possible using CSS @import url:

@import url(http://fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300ita‌​lic,400italic,500,500italic,700,700italic,900italic,900);
html, body, html * {
  font-family: 'Roboto', sans-serif;
}

How to Use Google (with Pictures), uses a trademarked algorithm called PageRank, which assigns each Web page a relevancy score. In order to make Cortana use Google, you need an add-on or extension to redirect the search. For Chrome, you need an extension called Chrometana. It redirects all Bing searches to Google, and flawlessly so.

The src refers directly to the font files, therefore if you place all of them on /media/fonts/roboto you should refer to them in your main.css like this: src: url('../fonts/roboto/Roboto-ThinItalic-webfont.eot');

The .. goes one folder up, which means you're referring to the media folder if the main.css is in the /media/css folder.

You have to use ../fonts/roboto/ in all url references in the CSS (and be sure that the files are in this folder and not in subdirectories, such as roboto_black_macroman).

Basically (answering to your questions):

I have css in my media/css/main.css url. So where do i need to put that folder

You can leave it there, but be sure to use src: url('../fonts/roboto/

Do i need to extract all eot,svg etc from all sub folder and put in fonts folder

If you want to refer to those files directly (without placing the subdirectories in your CSS code), then yes.

Do i need to create css file fonts.css and include in my base template file

Not necessarily, you can just include that code in your main.css. But it's a good practice to separate fonts from your customized CSS.

Here's an example of a fonts LESS/CSS file I use:

@ttf: format('truetype');

@font-face {
  font-family: 'msb';
  src: url('../font/msb.ttf') @ttf;
}
.msb {font-family: 'msb';}

@font-face {
  font-family: 'Roboto';
  src: url('../font/Roboto-Regular.ttf') @ttf;
}
.rb {font-family: 'Roboto';}
@font-face {
  font-family: 'Roboto Black';
  src: url('../font/Roboto-Black.ttf') @ttf;
}
.rbB {font-family: 'Roboto Black';}
@font-face {
  font-family: 'Roboto Light';
  src: url('../font/Roboto-Light.ttf') @ttf;
}
.rbL {font-family: 'Roboto Light';}

(In this example I'm only using the ttf) Then I use @import "fonts"; in my main.less file (less is a CSS preprocessor, it makes things like this a little bit easier)

The Google Search Engine, Use quotes. When searching for something specific, try using quotes to minimize the guesswork for Google search. When you put your search parameters in  Use your Google Account for YouTube. You sign into YouTube with your Google Account . To sign in to YouTube, enter your Google Account email and password. After signing up for YouTube Deleting your Google Account will delete your YouTube data , including all videos, comments, and subscriptions.

Try this

<style>
@font-face {
        font-family: Roboto Bold Condensed;
        src: url(fonts/Roboto_Condensed/RobotoCondensed-Bold.ttf);
}
@font-face {
         font-family:Roboto Condensed;
        src: url(fonts/Roboto_Condensed/RobotoCondensed-Regular.tff);
}

div1{
    font-family:Roboto Bold Condensed;
}
div2{
    font-family:Roboto Condensed;
}
</style>
<div id='div1' >This is Sample text</div>
<div id='div2' >This is Sample text</div>

20 Google Search Tips to Use Google More Efficiently, Learn about what Google Pay is and how to use it. See how to add cards, pay in stores, pay in apps, pay on sites, and verify your payment information. Google Drive is a user-friendly option thanks to its simple interface and integration with Google Docs. If you’re new to using Google Drive, take a look at the following guide to find out how to

Learn What Google Pay Is & How To Use It, Use Google Pay wherever you see these symbols. See how to pay in stores. dunkin donuts; McDonalds; trader joe's; walgreens; whole foods market; acme  When you do a Google Search, you can filter your results to find images, videos, or text that you have permission to use. To do this, use an Advanced Search filter called "usage rights" that lets you know when you can use, share, or modify something you find online.

See Who Accepts Google Pay, Many websites and apps use Google services to improve their content and keep it free. When they integrate our services, these sites and apps share information  6 Best Practices for Legally Using Google Images 1. Always Assume the Image is Protected by Copyright. 2. Linking. 3. Use Your Own Photos and Images. 4. Use Creative Commons-Licensed Images. 5. Use Images From Stock Photo Agencies. 6. Confirm Who Owns the Copyright in the Image.

How Google uses information from sites or apps that use our services, We've collected answers to some of the most frequently asked questions about Family Link. If you're already using the app and have a question of your own, you​  Get more done with the new Google Chrome. A more simple, secure, and faster web browser than ever, with Google’s smarts built-in. Download now.

Comments
  • Thanks for that, that was perfect. Do u know which setting google use for their playlist foonts in google play store. i want to have style exactly like that. Also i did not find the link or code snippet in the link. i do see the fonts there but no code
  • Can't help on the Google Play styles, I'm afraid. The <link> and 'font-family' items appear at the bottom of the page with the font-weight selections on. You might need to scroll to see it.
  • Cool thing, they provide an @import for LESS files too! However, testing w/o internet connection OR Google connection issues (e.g.: China) = NO Fonts... I also noticed that there is no Roboto Black (Roboto Bk) font-family: they actually only use 3 font families (Roboto, Roboto Condensed and Roboto Slab) all other Roboto variants are made through font-style and font-weight CSS changes. So ideally, after placing the Google <link> check if the fonts are really there. If not, use your own (btw loading all files from one font family normally does not exceed 0.5MB).
  • @user26 <link href='http://fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300italic,400italic,500,500italic,700,700italic,900italic,900' rel='stylesheet' type='text/css'> This loads all styles from one font-family only: Roboto. However, if you need a font family not in Google Fonts (such as Roboto Black) you need the files on your folders and copy the example code you have shown us in your question to your main.css (like this @font-face{font-family: 'Roboto Black';src:url('/media/fonts/roboto/roboto_black_macroman/blablabla.eot; ...etc. or like I suggested in my answer).
  • -1 for Using Google's fonts this way guaranties availability. Nothing "guaranties availability," much less Google fonts. I happen to be one of billion+ people for whom using Google's CDN means tons of websites fail to load properly, or at all. I'm not telling anyone what to do, but don't think Google's CDN is a perfect solution.
  • Your solution is a performance anti-pattern. Using a link tag in your markup results in sooner download of Google's CSS file compared to @import; the browser just discovers the resource reference earlier in general and in particular due to the pre-loader (while parsing the HTML vs. first parse the HTML, then discover your CSS file, then download it, then parse and discover the @import, then download the imported stylesheet).
  • Not necessarily. Using Webpack and plugins, this will all be embedded in your distribution build.