Firefox Icon Font Overly Bold Anti-Aliasing - html

I'm aware that different browsers render text in different ways – and to a point, I'm cool with that. However upon experimenting with using icon fonts for one project, Firefox, in particular is irritating me.
Essentially I have a row of social media icons, which are displayed via #font-face and some pseudo classes. Except Firefox has a little issue with rendering them nicely...
Here's what they look like Chrome vs Firefox.
Chrome 23.0.1271.101 (Mac)
http://cl.ly/image/0M3t2S3N2A38/
(Perfect)
Firefox 17.0.1 (Mac)
http://cl.ly/image/053d2J0J312K
(Not-so-perfect)
You can probably see the issue I have...
I've also checked several other browsers to see if it's not just firefox. It is just firefox. Even IE does a nicer job.
The code:
CSS
#font-face {
font-family: 'icomoon';
src:url('fonts/icomoon.eot');
src:url('fonts/icomoon.eot?#iefix') format('embedded-opentype'),
url('fonts/icomoon.svg#icomoon') format('svg'),
url('fonts/icomoon.woff') format('woff'),
url('fonts/icomoon.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
[class^="icon-"]:before,
[class*=" icon-"]:before {
font-family: 'icomoon';
font-style: normal;
speak: none;
font-weight: normal;
line-height: 1;
text-align: center;
}
.icon-flkr:before {
content: "\2b";
}
.icon-fbk:before {
content: "\2c";
}
.icon-twitter:before {
content: "\3e";
}
.icon-lfm:before {
content: "\24";
}
.icon-lkdin:before {
content: "\25";
}
.icon-inst:before {
content: "\26";
}
HTML
<ul id="footer_social_list" class="group">
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
<li></li>
</ul>
I've tried a lot of things to try and fix this. From changing the opacity with CSS; to trying text shadow; changing the weights of both the #font-face, classes and inherited styles; using "data-icon"; even making sure each icon is aligned to the pixel grid.
Nothing has yet yielded any improvement in Firefox, and I'd say with the slight exception of the Instagram icon in IE9, everything looks good in every browser.
So why does Firefox do this? And is there anything I can do to make it behave?
PS: I haven't added -webkit-font-smoothing: antialiased; not that it affects Firefox anyway.

-moz-osx-font-smoothing: grayscale;
See the discussion leading to this new vendor prefixed solution for Firefox.

font-weight:normal !important;
This may seem like the obvious answer but no one mentioned it. Very possible you have a !important on your anchor tags somewhere along the line, keeping them from being normally weighted again.

This is another obvious answer that no one mentioned:
What you're talking about happens in all browsers: when you use light text on a dark background, the text seems more "weighty". The same is true for icon fonts... the small details will bloat out. (There are CSS font-smoothing and text-rendering properties that help correct this, but they don't necessarily work the same in all browsers. See here.)
One way you can get around it, if you want a dark-coloured icon on a lighter circle shape (without using SVG), is to use an icon without the circle, then create your own circle background with CSS.
You won't get a true knockout (the icons won't actually be negative space in the circle, so any background patterns behind your buttons won't show through the icons), but you will avoid the light-text-on-dark-background bleedout.
Of course, you will also lose your border-radius in older versions IE... so weigh (ahem) what matters more.

Related

Debugging differences in inherent height of element between two web pages

I have an apparently identical element that's rendering slightly differently on two web pages. I'm sure it's down to some subtle difference in the CSS between the pages, but I can't pin down what it is. One is a live server with various layers of asset compilation and minification, the other is a static mockup.
The HTML is pretty simple:
<div class='category-icon'>
<span class='glyphicon glyphicon-globe'></span>
</div>
And the most immediately relevant CSS isn't much more complicated:
.category-block .category-icon {
font-size: 6em;
}
.glyphicon {
position: relative;
top: 1px;
display: inline-block;
font-family: 'Glyphicons Halflings';
font-style: normal;
font-weight: normal;
line-height: 1;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.glyphicon-globe:before {
content: "\e135";
}
Here's how it renders in Firefox, with the inspector on so you can see the bounds:
Note the height difference -- 120 vs. 84.
Here are the computed styles from Chrome, which shows the same behavior. Again note the difference in the rectangle height, and the grayed-out height values. (The Firefox inspector shows the same results, but doesn't give height.)
As you can see, it's nothing in the margin, border, or padding that's causing the difference; it's something about the rendering of either the <span/> itself or the surrounding text elements. (Note that the line-height is correctly 120px for both. Is there some reason the line-height would affect the height in one version but not in the other?)
As far as I can tell, the actual HTML is byte-for-byte identical. So I assume the problem is somewhere in the hairier parts of the CSS.
How should I go about diagnosing this problem? What else is likely to be causing the height difference, if I've drilled down this far and can't see anything in the inspector?
Edited to add: The applied styles (from the Chrome 'styles' tab) also appear identical -- see overlaid screenshots here.
David, you need to look at the truncated styles in your DOM inspector through the styles tab. The heights are different in your two examples. Computed styles will tell you what the page has rendered and the style tab will show you all the CSS rules being applied to your element. Look for a rule that is similar to height: 120px;
You will find the culprit there.

Materialize css icons doesn't show up in Safari browser

I noticed that materialized CSS icons does not show up in Safari (v5.1.7 (7534.57.2). Well searched a lot on this topic but there haven't been any documentation on browser compatibility where safari has been listed. Could anyone let me know if this is a bug which needs to be fixed or are there any alternatives to get this work in Safari.
Other browsers
Safari Browser
PS:Other functionalities of materializecss works well except icons
I faced the exact same issue. The following approach helped me:
I was facing problems with the font-icons provided by materialize css. There seems to be some problem with the font-icons in case if you are self-hosting it. I will update my answer with the exact bug number. So to fix it I downloaded and used the font-icons provided by Google and followed the steps mentioned over here.
Be sure to append the following to your CSS:
.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';
}
Another thing to make sure is to see to it that you are using all the font formats provided by google: WOFF2, WOFF, Truetype, EOT and even SVGs if possible to ensure cross browser compatibility.
In case if you are not self hosting the font-icons, just try including the above mentioned CSS code. I haven't tried this with CDN but it did work for me for self-hosted font-icons. So let us all know how things work out, so that in case if it doesn't, we can try some alternate solution.
suddenly you have the Lockdown mode on. Go to safari menu > settings > websites > Lockdown Mode, and turn it off on the websites you have there.

Google Font Letter Height Not Consistent

I am having a weird issue in Chrome where a Google Font is showing inconsistent letter heights. It only happens when I use text-transform: uppercase and it is fixed if I use font-weight:bold. I have some example code, where you can see the S is too tall in the word TESTING:
body {
font-family: 'Exo 2' !important;
line-height:1.42857143;
}
div {
width:40px;
}
span.upper {
display:block;
margin-top:20px;
font-size:18px;
text-transform:uppercase;
}
span {text-transform:uppercase; }
<link href="//fonts.googleapis.com/css?family=Exo+2:200,300,400,700,300italic,400italic,700italic|Raleway:200,300,400,600" rel="stylesheet" type="text/css">
<div>
Broken:<br>
<a href="#">
<span class="upper">Testing 123</span> </a>
<br>Normal:<br><br>
<span>Testing 123</span>
</div>
If I change the font to arial, it's fixed. Is there some CSS property I need to reset so that the font will render correctly?
This is a well known bug in Chrome on Windows. Chrome has made the political/ecosystem move to reduce dependencies on other companies and other established tech, like the move to fork Blink from Web-Kit. Chrome has also decided to ditch Microsoft font rendering. The result is poor sub-pixel rendering. You've noticed that once you bump your font up in size or weight the issue is resolved because the character strokes are wider than one pixel.
One solution for you: you can go into Chrome's flags:// to enable Direct Write.
But that doesn't help your users, of course. There are a few hacks.
One hack is to change up your font stack, so that SVG is called specifically for web-kit.
You can do this with a media query hack:
#media screen and (-webkit-min-device-pixel-ratio:0) {
#font-face {
font-family: 'chunk-webfont';
src: url('webfont.svg') format('svg');
}
}
So there are issues with this. It's not future-proof. It's a hack. But it works for now, and Chrome will be fixing this in the near future. Other, hacks include calling SVG first in your stack, but it has less reliable results.
I was having the same issues with Windows browsers and I tried using SVG first in the stack but it didn't work - I later found out that Chrome has since ditched support for SVG fonts. So I tried using a TTF version of my font placed first in the stack and for some reason it resolved the issue. Tested it in Chrome, Firefox and Edge. Oddly if I reference the TTF in a data URI it goes back to inconsistent letter heights again.

Multicolored Icon Fonts

Since I have used Icon fonts, Its been a huge issue to have two colors with one class instead of a bunch of positioning or clipping.. since it is rather a common thing to have multicolored icons in a site, I came Across the solution today I thought I may just post this for people like me who looked for answers but only found complications...
Okay i am going to do this in a step-by-step manner:
ILLUSTRATOR PART
in illustrator copy the icon into a new document.
then cut the one color.
press save as and save as SVG
then paste the one you cut and delete the other one.
save as another SVG.
ICOMOON
Really is a great site.
start the app.
import the svg and download an save.
and then this is the CSS I used for a one class solution to multicolored font icons:
CSS
.icon-earth{
font-family: 'icomoon';
speak: none;
font-style: normal;
font-weight: normal;
font-variant: normal;
text-transform: none;
line-height: 1;
-webkit-font-smoothing: antialiased;
}
.icon-earth:after {
content: "\e006";
color:#F33;
font-size:6em;
}
.icon-earth:before {
content: "\e007";
color:#0C0;
font-size:6em;
letter-spacing:-1em;
}
HTML
<div class="icon-earth"></div>
its quiet easy to interpret the CSS for you own needs, if help is need please shout and I will go through this step by step aswell...
And Finally Here is the JSFIDDLE, although i cant get custom Icon Fonts happening in JsFiddle...
Browser support is IE8 and up and then everything else i have checked..

Custom font rendering problems

So I sometimes want to emphasize certain words like this:
<h1>I want to <span class="emphasis">emphasize</span> some text.</h1>
At the same time, I would like to use a custom font for h1 text:
#font-face
{
font-family: 'MuseoSlab';
src: url('https://digital_time_capsules.s3.amazonaws.com/fonts/Museo_Slab_500-webfont.eot');
src: url('https://digital_time_capsules.s3.amazonaws.com/fonts/Museo_Slab_500-webfont.eot?#iefix') format("embedded-opentype"), url('https://digital_time_capsules.s3.amazonaws.com/fonts/Museo_Slab_500-webfont.svg#MuseoSlab500Regular') format("svg"), url('https://digital_time_capsules.s3.amazonaws.com/fonts/Museo_Slab_500-webfont.woff') format("woff"), url('https://digital_time_capsules.s3.amazonaws.com/fonts/Museo_Slab_500-webfont.ttf') format("truetype");
font-weight: normal;
font-style: normal;
}
Example here.
Problem is, Chrome in Windows overlaps the span text:
Firefox and IE don't seem to render the font smoothly:
Opera seems to render it just the way I want:
Can anyone tell me what's going on, and how I can fix these problems?
EDIT:
Sometimes I have that egregious problem in Chrome; sometimes I don't. And I have the latest Chrome installed, too:
The reason why Firefox and IE show the font the way they do is that h1 element has font-weight: bold by default, and you are declaring the font as normal weight. What this browsers do is arguably the correct move: in lack of a bold typeface, they algorithmically bold the letters.
To avoid that, add h1 { font-weight: normal; }. Alternatively, use a bold typeface of the font family.
The odd overlap in your Chrome sounds like an installation-specific problem, so you should first consider updating or re-installing Chrome.
I had once exactly the same issue with Chrome. It appears to be related to the rendering of SVG fonts in Chrome. If you change the order of the font files in the #font-face so that the SVG is at the end of the list, the issue disappears. Your example on jsfiddle still renders incorrect in the current version of Chrome (29.0.1547.76), so the render bug is still present.
Hopefully this helps someone in the future, but I was able to correct this issue by following the solution in the following question: Chrome svg-Font-Rendering breaks Layout
This successfully fixed the non-smooth edges without breaking the layout and/or squishing the fonts.