I am trying to add google material-icons to my WordPress project locally currently on localhost using WAMP. With CDN, everything works perfectly but I want a static reference to icons.
Here is is my directory structure
/
-index.php
-css/
----style.min.css
----MaterialIcons-Regular.eot
----MaterialIcons-Regular.ttf
----MaterialIcons-Regular.woff
----MaterialIcons-Regular.woff2
In style.min.css I have:
.material-icons{
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
font-size: 24px; /* Preferred icon size */
display: inline-block;
width: 1em;
height: 1em;
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';
}
#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');
}
When I use icons in body as:
<i class="material-icons"></i>
The icons render just fine in chrome but not in firefox;
FireBug shows this error
Cross-Origin Request Blocked: The Same Origin Policy disallows reading
the remote resource athttp://192.168.0.8/wp/wp-content/themes/thediode/css/MaterialIcons-Regular.woff2. (Reason: CORS header 'Access-Control-Allow-Origin' missing).
192.168.0.8/wp is the root set in WordPress backend on localhost so that images and other resources are fetched properly and I guess this is the problem.
Any ideas?
will this work when live?
In your URL bar in FF go to about:config. Find security.fileuri.strict_origin_policy and set it to false.
OR
Might be a file path issue. Try adding a slash:
url("/MaterialIcons-Regular.woff2")
Related
I am trying to use Google Material Icons in an electron app and ran across an issue in rendering the icons. The icons render perfectly on Windows but not on OSX. Using devtools I have seen that both request the font as 'woff2' format successfully but only Windows appears to render the icon...OSX simply list the ligature text.
Windows (left), OSX (right)
These works in Windows build but not OSX...it simply lists home or
<i class="material-icons">home</i>
<i class="material-icons"></i>
I have also tried
<i class="material-icons" id="test"></i>
#test:after{ content: 'home' }
Not sure if this an issue with chromium build for OSX, a OS font issue, or what? If anyone could provide any guidance on some things to try I would really appreciate the help.
Here is the CSS being used
#font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: url(./fonts/Material-Design-Iconic-Font.eot); /* For IE6-8 */
src: local('Material Icons'),
local('MaterialIcons-Regular'),
url(./fonts/Material-Design-Iconic-Font.woff2) format('woff2'),
url(./fonts/Material-Design-Iconic-Font.woff) format('woff'),
url(./fonts/Material-Design-Iconic-Font.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';
}
So, I am not 100% sure on what the issue is but wanted to post an update if it could help anyone else.
On my Windows build I had a font installed MaterialIcons-Regular.ttf...once I copied it and then uninstalled it, the Windows app stopped rendering correctly.
I then copied the MaterialIcons-Regular.ttf to the fonts folder in my electron project and then updated my css to look like
#font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: url(fonts/MaterialIcons-Regular.ttf) format('truetype');
}
Now it seems to be working...Not sure if there was something wrong with the other font sets or if I have some css setup incorrectly.
So I wanted a custom glyphicon and used icomoon to do so. Instead of importing the entire library to the server, I simply used a stylesheet import to make things easier.
Now the stylesheet on icomoon only allowed the style.css link to be open for 24 hours, so I simply took the contents of the style.css file and put it on a custom domain.
Old style.css:
<link rel="stylesheet" href="https://i.icomoon.io/public/temp/8e91637825/UntitledProject/style.css">
New style.css
<link rel="stylesheet" href="http://thecommentsection.co.uk/style.css">
This is the contents of the style.css:
#font-face {
font-family: 'icomoon';
src: url('https://i.icomoon.io/public/temp/8e91637825/UntitledProject/icomoon.eot?kxcvpn');
src: url('https://i.icomoon.io/public/temp/8e91637825/UntitledProject/icomoon.eot?kxcvpn#iefix') format('embedded-opentype'),
url('https://i.icomoon.io/public/temp/8e91637825/UntitledProject/icomoon.ttf?kxcvpn') format('truetype'),
url('https://i.icomoon.io/public/temp/8e91637825/UntitledProject/icomoon.woff?kxcvpn') format('woff'),
url('https://i.icomoon.io/public/temp/8e91637825/UntitledProject/icomoon.svg?kxcvpn#icomoon') format('svg');
font-weight: normal;
font-style: normal;
}
[class^="icon-"], [class*=" icon-"] {
/* use !important to prevent issues with browser extensions that change fonts */
font-family: 'icomoon' !important;
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
/* Better Font Rendering =========== */
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.icon-rubyit:before {
content: "\1f4a3";
}
The Issue
The only thing I changed on the stylesheet import is the href link, but for some reason changing the link from the old to new suddenly stops the glyphicon from working?
Any ideas?
I'm trying to host the Google Material Design icon set for my website however I cannot get the icons to show in Chrome or Safari.
I'm using this CSS file:
#font-face {
font-family: 'Material Icons';
font-style: normal;
font-weight: 400;
src: url(/public/dist/font/Material-Design-Icons.eot); /* For IE6-8 */
src: url(/public/dist/font/Material-Design-Icons.woff2) format('woff2'),
url(/public/dist/font/Material-Design-Icons.woff) format('woff'),
url(/public/dist/font/Material-Design-Icons.ttf) format('truetype');
}
.material-icons {
font-family: 'Material Icons';
font-weight: normal;
font-style: normal;
font-size: 24px; /* Preferred icon size */
display: inline-block;
width: 1em;
height: 1em;
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';
}
Pulling in the file with:
link(rel="stylesheet", href="/public/dist/css/font.css")
Which I can see in the browser is loaded
The font itself is even loaded into the page, I can see the .woff file in the network tab on Chrome.
This is the public folder structure which is hosted 'as is' by the server
I'm using the font here (jade):
i.material-icons.prefix perm_identity
And I can see the CSS class above applied to that element
But the fonts don't render.
EDIT: People here having the same issue: https://github.com/google/material-design-icons/issues/205
This was caused by outdated icon fonts on the materializecss.com website, I used the ones off the Google GH repo and they worked sigh
Simply make use of google material design icons directly in your webpage.
You can find the details here https://google.github.io/material-design-icons/
I was able to fix this issue by using the google web font style sheet. It is much easier this way.. you can just include the style sheets in you webpage and all web font icon classes are loaded and you are good to go.
Simply add the below CSS link to your page and access material design icons by Google web fonts.
<link href="https://fonts.googleapis.com/icon?family=Material+Icons"
rel="stylesheet">
And specify icon you want to use.
<span class="material-icons">face</span>
For more details refer to the Material icon documentation
I have to use 'helvetica neue' as my asp.net default font. After installed in my pc, I able to add the font into my css, and it is worked while run the web application at local. But after I deployed into server. The 'helvetica neue' font is not working. Is it have to install the font on user computer?
My CSS:
#font-face { font-family: Delicious; src: url('../css/Fonts/HelveticaNeueLTPro-CnO.otf'); }
body
{
background: #fff;
color: #333;
/*font-family: HelveticaNeueLT Pro 63 MdEx;*/
font-family: Delicious, sans-serif;
font-size: 76%; /* all font sizes are related to this initial 'small' font-size setting (which is more or less 12pt) */
min-width: 730px; /* min- and max-width don't work in IE Win 6 and below */
max-width: 1250px;
}
your #font-face is not complete, and you need some more files:
EOT for IE,
SVG fir Ipad,
WOFF for FireFox
TTF/OTF for the rest
You can create those font files at Font Squirrel
#font-face {
font-family: 'Delicious';
src: url('../css/Fonts/HelveticaNeueLTPro-CnO.eot');
}
#font-face {
font-family: 'Delicious';
src: url(//:) format('no404'),
url('../css/Fonts/HelveticaNeueLTPro-CnO.woff') format('woff'),
url('../css/Fonts/HelveticaNeueLTPro-CnO.ttf') format('truetype'),
url('../css/Fonts/HelveticaNeueLTPro-CnO.svg#Delicious') format('svg');
font-weight: normal;
font-style: normal;
}
Basically a web font I am using is displaying too bold in Firefox. I used the above code to fix it in webkit browsers. -moz-font-smoothing: antialiased; does not work. So now I am asking all of you if there is another solution I am simply overlooking.
Note: Regardless of being an h1 or not the font still displays too bold.
relevant code:
#font-face {
font-family: 'GelatoScript';
src: url('../fonts/gelatoscript/gelatoscript.eot');
src: url('../fonts/gelatoscript/gelatoscript.eot?#iefix') format('embedded-opentype'),
url('../fonts/gelatoscript/gelatoscript.woff') format('woff'),
url('../fonts/gelatoscript/gelatoscript.ttf') format('truetype'),
url('../fonts/gelatoscript/gelatoscript.svg#GelatoScript') format('svg');
font-weight: normal;
font-style: normal;
}
h1.pale {
color: #f6ff96;
font-family: 'GelatoScript';
font-weight: 100;
font-size: 3.5em;
margin-bottom: 0;
text-shadow: .042em .042em 0px #787878;
}
<h1 class="pale" >Check this out!</h1>
The article Dennis Traub links to in the (previously) accepted answer is in regards to anti-aliasing for WebGL and has nothing to do with font smoothing. The simple answer to the question is: No.
Update: Firefox now supports -moz-osx-font-smoothing: grayscale; which works in basically the same way as -webkit-font-smoothing: antialiased;.
According to this article, Firefox 10 will be the first version that implements anti-aliasing.