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

前端 未结 13 897
旧巷少年郎
旧巷少年郎 2020-12-12 10:23

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

<
13条回答
  •  一个人的身影
    2020-12-12 10:52

    Spent an hour, fixing the font issues.

    Related answer - Below is for React.js website:

    1. Install the npm module:

      npm install --save typeface-roboto-mono

    2. import in .js file you want to use
      one of the below:

      import "typeface-roboto-mono"; // if import is supported
      require('typeface-roboto-mono') // if import is not supported

    3. For the element you can use
      one of the below:

      fontFamily: "Roboto Mono, Menlo, Monaco, Courier, monospace", // material-ui
      font-family: Roboto Mono, Menlo, Monaco, Courier, monospace; /* css */
      style="font-family:Roboto Mono, Menlo, Monaco, Courier, monospace;font-weight:300;" /*inline css*/

    Hope that helps.

提交回复
热议问题