How to host material icons offline?

后端 未结 19 2478
无人及你
无人及你 2020-12-02 06:55

My apologies if this is a very simple question, but how do you use google material icons without a



        
19条回答
  •  温柔的废话
    2020-12-02 07:51

    The upper approaches does not work for me. I download the files from github, but the browser did not load the fonts.

    What I did was to open the material icon source link:

    https://fonts.googleapis.com/icon?family=Material+Icons

    and I saw this markup:

        /* fallback */
    @font-face {
      font-family: 'Material Icons';
      font-style: normal;
      font-weight: 400;
      src: local('Material Icons'), local('MaterialIcons-Regular'), url(https://fonts.gstatic.com/s/materialicons/v22/2fcrYFNaTjcS6g4U3t-Y5ZjZjT5FdEJ140U2DJYC3mY.woff2) format('woff2');
    }
    
    .material-icons {
      font-family: 'Material Icons';
      font-weight: normal;
      font-style: normal;
      font-size: 24px;
      line-height: 1;
      letter-spacing: normal;
      text-transform: none;
      display: inline-block;
      white-space: nowrap;
      word-wrap: normal;
      direction: ltr;
      -moz-font-feature-settings: 'liga';
      -moz-osx-font-smoothing: grayscale;
    }
    

    I open the woff font url link https://fonts.gstatic.com/s/materialicons/v22/2fcrYFNaTjcS6g4U3t-Y5ZjZjT5FdEJ140U2DJYC3mY.woff2

    and download the woff2 file.

    Then I replace the woff2 file path with the new one in material-icons.css

    @font-face {
      font-family: 'Material Icons';
      font-style: normal;
      font-weight: 400;
      src: url(iconfont/MaterialIcons-Regular.eot); /* For IE6-8 */
      src: local('Material Icons'),
           local('MaterialIcons-Regular'),
           /* Old file: url(iconfont/MaterialIcons-Regular.woff2) format('woff2'), */
           /* load new file */ 
           url(2fcrYFNaTjcS6g4U3t-Y5ZjZjT5FdEJ140U2DJYC3mY.woff2) format('woff2'),
           url(iconfont/MaterialIcons-Regular.ttf) format('truetype');
    }
    

    That makes thing works for me.

提交回复
热议问题