Reputation: 536
I want to host Material Icons offline for my offline web development project (I will not have internet on the computer where is deployed). From my Google search, I found this SO answer. BUT it is Not working for me. My question is how to make it work. How to host material design icons offline for my offline project?
I have attached a .zip file of my SSCCE project, which reproduces the problem, here.
Basically I downloaded the MaterialIcons-Regular.eot
, MaterialIcons-Regular.ttf
, MaterialIcons-Regular.woff
and MaterialIcons-Regular.woff2
from here and put them in my project's directory.
Here is my index file:
<!DOCTYPE html>
<html>
<head>
<title>MaterializeTest</title>
<link rel="stylesheet" href="material-fonts.css" />
<link type="text/css" rel="stylesheet" href="materialize.min.css" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width; initial-scale=1"/>
<script src="jquery.min.js"></script>
<script src="materialize.min.js"></script>
</head>
<body>
<a href="#!"><i class="material-icons">chevron_left</i></a>
</body>
</html>
And here is the CSS file.
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: url(MaterialIcons-Regular.eot); /* For IE6-8 */
src: local('Material Icons'),
local('MaterialIcons-Regular'),
url(MaterialIcons-Regular.woff2) format('woff2'),
url(MaterialIcons-Regular.woff) format('woff'),
url(MaterialIcons-Regular.ttf) format('truetype');
}
.material-icons {
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
font-size: 24px; /* Preferred icon size */
display: inline-block;
line-height: 1;
text-transform: none;
letter-spacing: normal;
word-wrap: normal;
white-space: nowrap;
direction: ltr;
/* Support for all WebKit browsers. */
-webkit-font-smoothing: antialiased;
/* Support for Safari and Chrome. */
text-rendering: optimizeLegibility;
/* Support for Firefox. */
-moz-osx-font-smoothing: grayscale;
/* Support for IE. */
font-feature-settings: 'liga';
}
Upvotes: 4
Views: 10461
Reputation: 28909
Original but light weight Material Icons
This light-weight repository (https://www.npmjs.com/package/material-design-icons-iconfont) is a fork of the original repository of ~60MB but this is very much light weight because unnecessary files were removed from that original repository.
// install via bower/npm
bower install material-design-icons-iconfont
npm install material-design-icons-iconfont
// import or link
@import "~material-design-icons-iconfont/dist/material-design-icons.css";
<link rel="stylesheet" href="../node_modules/material-design-icons-iconfont/dist/material-design-icons.css">
<i class='material-icons'>done</i> // remember to add class `material-icons`
more on https://material.io/tools/icons/?style=baseline
Upvotes: 4
Reputation: 3614
I think you downloaded wrong files from somewhere. This is the path that you have to download correct fonts from: https://github.com/google/material-design-icons/tree/master/iconfont or use the one in my GH repo that worked for you already.
Also you need to call only one css in your html (php) file, like this:
<link rel="stylesheet" href="material-fonts.css" />
hth, k
Upvotes: 2
Reputation: 1647
First way to add icons will be following:
/* fallback */
@font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: url(https://fonts.gstatic.com/s/materialicons/v29/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;
-webkit-font-feature-settings: 'liga';
-webkit-font-smoothing: antialiased;
}
src: url()
as src: url(2fcrYFNaTjcS6g4U3t-Y5ZjZjT5FdEJ140U2DJYC3mY.woff2) format('woff2');
Second example: Looks like you download wrong files. You need to download this directory and put it into your folder, previous files have to removed.
Your materialFontTest.php should look like:
<!DOCTYPE html>
<html>
<head>
<title>MaterializeTest</title>
<link rel="stylesheet" href="material-icons.css" />
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<script src="jquery.min.js"></script>
<script src="materialize.min.js"></script>
</head>
<body>
<a href="#!"><i class="material-icons">chevron_left</i></a>
</body>
</html>
Upvotes: 5