Safari giving precedence to installed font - css

Some of the designers working at my workplace noticed that on Safari the font of our website appeared to be the one installed on their machine and not the one we are serving.
We noticed it in two different occasions and with two different fonts: Montserrat and Open Sans.
The first time (with Montserrat) the user had a newer version of the font, and she saw the newest only on Safari, because she had installed it on her local machine (this wasn't happening on Chrome).
The second time (with Open Sans) we saw a bolder font only on a particular machine: we then discovered that on that machine the user had installed a bolder weight (700) than the one we were serving (600). And the rule was
font-weight: bold;
so I suppose that the browser picked up the boldest (700) from the installed fonts.
I did some research but didn't find any evidence of this. Does anyone know if there is any evidence/documentation on Safari giving precedence to installed fonts instead of the ones you are serving?
We are not using Google Fonts from Google's CDN, as we decided to download them and serve them from our own server.
EDIT: I'm adding the code we use to load the font (generated using Google Webfonts Helper):
#font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
src: url("font/opensans/open-sans-latin_cyrillic-400.eot");
src: local("Open Sans"), local("OpenSans"), url("font/opensans/open-sans-latin_cyrillic-400.eot?#iefix") format("embedded-opentype"), url("font/opensans/open-sans-latin_cyrillic-400.woff2") format("woff2"), url("font/opensans/open-sans-latin_cyrillic-400.woff") format("woff"), url("font/opensans/open-sans-latin_cyrillic-400.ttf") format("truetype"), url("font/opensans/open-sans-latin_cyrillic-400.svg#OpenSans") format("svg");
}
#font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 600;
src: url("font/opensans/open-sans-latin_cyrillic-600.eot");
src: local("Open Sans Semibold"), local("OpenSans-Semibold"), url("font/opensans/open-sans-latin_cyrillic-600.eot?#iefix") format("embedded-opentype"), url("font/opensans/open-sans-latin_cyrillic-600.woff2") format("woff2"), url("font/opensans/open-sans-latin_cyrillic-600.woff") format("woff"), url("font/opensans/open-sans-latin_cyrillic-600.ttf") format("truetype"), url("font/opensans/open-sans-latin_cyrillic-600.svg#OpenSans") format("svg");
}
#font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: 400;
src: url("font/montserrat/montserrat-latin-regular.eot");
src: local("Montserrat-Regular"), url("font/montserrat/montserrat-latin-regular.eot?#iefix") format("embedded-opentype"), url("font/montserrat/montserrat-latin-regular.woff2") format("woff2"), url("font/montserrat/montserrat-latin-regular.woff") format("woff"), url("font/montserrat/montserrat-latin-regular.ttf") format("truetype"), url("font/montserrat/montserrat-latin-regular.svg#Montserrat") format("svg");
}
#font-face {
font-family: 'Montserrat';
font-style: normal;
font-weight: 700;
src: url("font/montserrat/montserrat-latin-700.eot");
src: local("Montserrat-Bold"), url("font/montserrat/montserrat-latin-700.eot?#iefix") format("embedded-opentype"), url("font/montserrat/montserrat-latin-700.woff2") format("woff2"), url("font/montserrat/montserrat-latin-700.woff") format("woff"), url("font/montserrat/montserrat-latin-700.ttf") format("truetype"), url("font/montserrat/montserrat-latin-700.svg#Montserrat") format("svg");
}
And the relevant code to give a different font-face to different parts of the pages.
body{
font-family: "Open Sans", Helvetica, Arial, sans-serif;
font-size: 14px;
}
h6, h5, h4, h3, h2, h1{
font-family: inherit; // inheriting from body
font-weight: bold;
}
.view{
font-family: 'Montserrat', sans-serif;
}

Based on the code you show the solution is kind of obvious: if you don't want local fonts to interfere, don't tell the browser to try local() first. Or at all, really.
It's 2017, and in today's browser landscape you only want src: url(woff font version) format("woff"), nothing else: no other formats, no local-first, just explicitly the font your content should use. In the current browser landscape eot and svg don't even exist as valid formats anymore, and woff are ttf/otf, but with compression, and marked explicitly as intended "for the web" so that some normally required data can be left off, yielding an even smaller font payload. The only other format you might add is WOFF2, which uses a newer compression algorithm and allows "slicing" up a single font into several subsets so that the browser only loads the slices it needs to style your content instead of an entire font in one go.
Whatever generated this CSS for you appears to still be stuck in "how webfonts worked in 2012".

Eventually I used what #Mike'Pomax'Kamermans suggested in one of the last comments to his own answer, I'm posting it here just for clarity.
We removed every local specification and every src apart from the .eot file and the .woff2 file.
Then we added this declaration to tell Safari that our bold font should render with the 600 weight, otherwise Safari would look into the installed copy of the font (which included the 700 weight).
#font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: bold;
src: url('font/open-sans-latin_cyrillic_latin-ext-600.eot'); /* IE9 Compat Modes */
src: url('font/open-sans-latin_cyrillic_latin-ext-600.woff2') format('woff2'); /* Super Modern Browsers */
}

Related

#font face - Font behaviour different between local and live server

I am beginner in a coding world and asking the first question in here, hope I will explain myself correctly!
I have uploaded Proxima Nova Regular and Open Sans Light via font face and included below styling in my css file. Both fonts work, but not the way they should be. Proxima Nova renders with much more weight on, in comparison to the one installed on my computer. Also both fonts don't pick up html bolding feature? to make text bold I need to specify font weight in css file, there is no other way? Not sure what the problem is. I have tried to find a solution but couldn't find any. Maybe it is something really basic that I haven't been able to grasp yet during my learning journey.
I have downloaded fonts with the Font Squirrel.
Fonts are based in a separate assets folder to my css file.
I have tried to clear my font cache multiple times and it didn't help.
I am working with Chrome however have the same issue with other browsers: Mozilla and IE.
This is a font I am after and I had it working on my pc, having proxima nova and open sans installed locally: https://www.katietreggiden.com/about
this is what i get via font face and web server: https://youmedigital.com/
Thank you for your help in advance:-)
#font-face {
font-family: "Proxima Nova";
src: local("Proxima Nova");
src: url("assets/fonts/Proxima Nova.woff") format("woff"),
url("assets/fonts/Proxima Nova.woff2") format("woff2"),
url("assets/fonts/Proxima Nova.ttf") format("truetype");
font-style: normal;
font-weight: normal;
}
#font-face {
font-family: "Open Sans";
src: local("Open Sans");
src: url("assets/fonts/Open Sans Light.woff") format("woff"),
url("assets/fonts/Open Sans Light.woff2") format("woff2"),
url("assets/fonts/Open Sans Light.ttf") format("truetype");
font-style: normal;
font-weight: normal;
}
body {
font-family: "Proxima Nova";
font-weight: 300;
color: #575757;
}
h1, h2, h3, h4, h5, h6 {
font-family: "Open Sans";
font-weight: 300;
color: #000000;
}

#font-face - Fonts Not Requested by Browser, Not Loading

I'm attempting to load 4 fonts using #font-face as critical styles in the header for above-the-fold content, within <style> tags.
Rubik-Bold
Rubik-Italic
Rubik-LightItalic
Rubik-Regular
From what I can tell this should be correct, however only the first in the list loads. If I removed the first one, the next-in-line will be the first to load.
HTML:
#font-face {
font-family: 'Rubik';
src: url('//cdn.shopify.com/s/files/1/1735/6971/t/25/assets/Rubik-Bold.eot?2568338257603816725');
src: url('//cdn.shopify.com/s/files/1/1735/6971/t/25/assets/Rubik-Bold.eot?2568338257603816725#iefix') format("embedded-opentype"),
url('//cdn.shopify.com/s/files/1/1735/6971/t/25/assets/Rubik-Bold.woff?2568338257603816725') format("woff"),
url('//cdn.shopify.com/s/files/1/1735/6971/t/25/assets/Rubik-Bold.woff2?2568338257603816725') format("woff2"),
url('//cdn.shopify.com/s/files/1/1735/6971/t/25/assets/Rubik-Bold.ttf?2568338257603816725') format("truetype"),
url('//cdn.shopify.com/s/files/1/1735/6971/t/25/assets/Rubik-Bold.svg?2568338257603816725#timber-icons') format("svg");
font-weight: 700;
font-style: normal;
};
#font-face {
font-family: 'Rubik';
src: url('//cdn.shopify.com/s/files/1/1735/6971/t/25/assets/Rubik-Italic.eot?2568338257603816725');
src: url('//cdn.shopify.com/s/files/1/1735/6971/t/25/assets/Rubik-Italic.eot?2568338257603816725#iefix') format("embedded-opentype"),
url('//cdn.shopify.com/s/files/1/1735/6971/t/25/assets/Rubik-Italic.woff?2568338257603816725') format("woff"),
url('//cdn.shopify.com/s/files/1/1735/6971/t/25/assets/Rubik-Italic.woff2?2568338257603816725') format("woff2"),
url('//cdn.shopify.com/s/files/1/1735/6971/t/25/assets/Rubik-Italic.ttf?2568338257603816725') format("truetype"),
url('//cdn.shopify.com/s/files/1/1735/6971/t/25/assets/Rubik-Italic.svg?2568338257603816725#timber-icons') format("svg");
font-weight: 400;
font-style: italic;
};
#font-face {
font-family: 'Rubik';
src: url('//cdn.shopify.com/s/files/1/1735/6971/t/25/assets/Rubik-LightItalic.eot?2568338257603816725');
src: url('//cdn.shopify.com/s/files/1/1735/6971/t/25/assets/Rubik-LightItalic.eot?2568338257603816725#iefix') format("embedded-opentype"),
url('//cdn.shopify.com/s/files/1/1735/6971/t/25/assets/Rubik-LightItalic.woff?2568338257603816725') format("woff"),
url('//cdn.shopify.com/s/files/1/1735/6971/t/25/assets/Rubik-LightItalic.woff2?2568338257603816725') format("woff2"),
url('//cdn.shopify.com/s/files/1/1735/6971/t/25/assets/Rubik-LightItalic.ttf?2568338257603816725') format("truetype"),
url('//cdn.shopify.com/s/files/1/1735/6971/t/25/assets/Rubik-LightItalic.svg?2568338257603816725#timber-icons') format("svg");
font-weight: 300;
font-style: italic;
};
#font-face {
font-family: 'Rubik';
src: url('//cdn.shopify.com/s/files/1/1735/6971/t/25/assets/Rubik-Regular.eot?2568338257603816725');
src: url('//cdn.shopify.com/s/files/1/1735/6971/t/25/assets/Rubik-Regular.eot?2568338257603816725#iefix') format("embedded-opentype"),
url('//cdn.shopify.com/s/files/1/1735/6971/t/25/assets/Rubik-Regular.woff?2568338257603816725') format("woff"),
url('//cdn.shopify.com/s/files/1/1735/6971/t/25/assets/Rubik-Regular.woff2?2568338257603816725') format("woff2"),
url('//cdn.shopify.com/s/files/1/1735/6971/t/25/assets/Rubik-Regular.ttf?2568338257603816725') format("truetype"),
url('//cdn.shopify.com/s/files/1/1735/6971/t/25/assets/Rubik-Regular.svg?2568338257603816725#timber-icons') format("svg");
font-weight: 400;
font-style: normal;
};
This is what I get in Chrome's inspector:
Things I've tried based on similar threads I've read:
Eliminated all whitespace and put each #font-face on one line (solved the issue in another thread).
Tested the links that Shopify's CDN outputs, and they do work.
On the page, in the header:
HTML:
<div class="gift-line show-for-large">
<span>The Gift Line</span><span class="phone-number">XXX-XXX-XXXX</span>
</div>
And CSS, loaded before the font-face declarations (span should be inheriting this rule and therefore Rubik-Regular should be downloading):
body {
font-family: "Rubik", sans-serif;
font-weight: normal;
font-style: normal;
}
So in this case, I know that at least Rubik-Regular should be called in addition to Rubik-Bold. (There are no
Any suggestions? Thanks
Browsers try to minimize network connections by analizing your css and html to determine what font files you end up using and only download those.
Since you're using the same font-family name here you have to make sure you use each style combination of font-weight and font-style on the page for the browser to download all of them.
Also don't be tricked by some of the caching smarts browser put into place. Font's are cached quickly to prevent http requests.
I suggest you ignore the network traffic and inspect your element that is supposed to get the font and look at the computed tab.
For more information around how to debug fonts have a look at this short article by Paul Irish.

Load different font for different languages in SCSS

How do i utilize SCSS feature to load different font based on different language by using &:lang() in css?
I am planning to use it this way at top scss file chain. Do you think this is correct?
//Default font-family it's not Japan language
#font-face {
font-family: "xxx";
font-style: normal;
font-weight: normal;
src: url('xxx.eot');
src: local(xxx),
url("xxx.eot?#iefix") format("embedded-opentype"),
url("xxx.woff") format("woff"),
url("xxx.ttf") format("truetype"),
url("xxx.otf") format("opentype"),
url("xxx.svg#xxx") format("svg");
}
//If Japanese then
html:lang(ja) {
#font-face {
font-family: "Meiryo";
font-style: normal;
font-weight: normal;
src: url('Meiryo.eot');
src: local(Meiryo),
url("Meiryo.eot?#iefix") format("embedded-opentype"),
url("Meiryo.woff") format("woff"),
url("Meiryo.ttf") format("truetype"),
url("Meiryo.otf") format("opentype"),
url("Meiryo.svg#Meiryo") format("svg");
}
}
EDIT: the above code prints out like this without any error. This should have been a bug from scss
#font-face {
html:lang(jp) {
font-family: "Meiryo";
....
}
}
EDIT: it looks like unicode range is the solution. I'd love to know If you have any better solution. Thanks
https://developer.mozilla.org/en-US/docs/Web/CSS/#font-face/unicode-range
//If Japanese then
#font-face {
.......
unicode-range: 3000-303f;
}
The unicode-range CSS descriptor sets the specific range of characters to be used from a font defined by #font-face and made available for use on the current page. If the page doesn't use any character in this range, the font is not downloaded; if it uses at least one, the whole font is downloaded.

CSS - Fonts are not rendering correctly in firefox for offline data

http://ocw.mit.edu/courses/mathematics/18-06sc-linear-algebra-fall-2011/download-course-materials/ try downloading the course from this link.
from the zip folder when i view the pages offline in firefox the fonts are not rendered correctly you can compare it with chrome and IE by opening the course in offline mode in both the browsers.
I tried using local() in #font-face src: but there was no impact, cant use .htaccess option as the course will be available offline after downloading and it may not be necessary to have apache on machines.
I tried changing the fileURI in about:config of firefox it worked but it is not a perfect solution as there are many users and they can't do this.
Please Suggest some solution.
code for base.css:
#font-face {
font-family: TitilliumText22LLight;
src: local("TitilliumText22LLight"), url('../webfonts/TitilliumText22L002- webfont.eot');
src: local("TitilliumText22LLight"), url('../webfonts/TitilliumText22L002-webfont.eot?#iefix') format("embedded-opentype"),
url('../webfonts/TitilliumText22L002-webfont.otf') format("otf"),
url('../webfonts/TitilliumText22L002-webfont.woff') format("woff"),
url('../webfonts/TitilliumText22L002-webfont.ttf') format("truetype"),
url('../webfonts/TitilliumText22L002-webfont.svg#TitilliumText22LLight') format("svg");
font-weight: normal;
font-style: normal;
}
#font-face {
font-family: TitilliumText22LRegular; /* Titillium Regular */
src: local("TitilliumText22LRegular"), url('../webfonts/TitilliumText22L003-webfont.eot');
src: local("TitilliumText22LRegular"), url('../webfonts/TitilliumText22L003-webfont.eot?#iefix') format("embedded-opentype"),
url('../webfonts/TitilliumText22L002-webfont.otf') format("otf"),
url('../webfonts/TitilliumText22L003-webfont.woff') format("woff"),
url('../webfonts/TitilliumText22L003-webfont.ttf') format("truetype"),
url('../webfonts/TitilliumText22L003-webfont.svg#TitilliumText22LRegular') format("svg");
font-weight: normal;
font-style: normal;
}
#font-face {
font-family: TitilliumText22LBold; /* Titillium Bold */
src: local("TitilliumText22LBold"), url('../webfonts/TitilliumText22L005-webfont.eot');
src: local("TitilliumText22LBold"), url('../webfonts/TitilliumText22L005-webfont.eot?#iefix') format("embedded-opentype"),
url('../webfonts/TitilliumText22L005-webfont.otf') format("otf"),
url('../webfonts/TitilliumText22L005-webfont.woff') format("woff"),
url('../webfonts/TitilliumText22L005-webfont.ttf') format("truetype"),
url('../webfonts/TitilliumText22L005-webfont.svg#TitilliumText22LBold') format("svg");
font-weight: bold;
font-style: normal;
}`
code for Courses_new.css :
#course_nav li a,
#course_nav li a:visited {
font-family: TitilliumText22LBold, Verdana;
color: #666;
font-size: 1.2em;
text-decoration: none;
text-transform: uppercase;
margin: inherit;
padding: inherit;
width: 125px;
}
in the above scenario course_new.css is calling the class TitilliumText22LBold from base.css but it is not applying on the text in offline mode which you can see in the left navigation panel when opening the page from zips.
When i remove verdana it is applying TitilliumText22LBold but still the fonts are not same as fonts in online mode.
Please suggest what should be done next so that this font should be applied in offline mode as well.
I have used custom fonts myself. My code worked on both sides, on and offline.
This is the CSS rule i added in the first lines of my css file:
#font-face { font-family: BebasNeue; src: url('../fonts/BebasNeue.otf'); }
And then i just called them in my css like this:
h1 {
font-family: BebasNeue;
}
I hope this is of any help.
And, my advise to you is to use .otf files! I have learned that TTF files won't load locally. that also might be your problem :)

How do you set web font stacks with multiple styles?

Web fonts tend to come split up into separate files for bold, italic, etc. I'm using a #font-face declarations like this (trimmed down to WOFF only for this example):
#font-face {
font-family: 'OpenSans';
src: url("fonts/OpenSans-Regular.woff") format("woff");
font-weight: normal;
font-style: normal;
}
#font-face {
font-family: 'OpenSansItalic';
src: url("fonts/OpenSans-Italic.woff") format("woff");
font-weight: normal;
font-style: normal;
}
#font-face {
font-family: 'OpenSansBold';
src: url("fonts/OpenSans-Bold.woff") format("woff");
font-weight: normal;
font-style: normal;
}
And then I implement the various styles:
body {
font-family: "OpenSans", Helvetica, sans-serif;
}
strong {
font-family: "OpenSansBold", Helvetica, sans-serif;
font-weight: normal; /* Web font is already bold */
}
em {
font-family: "OpenSansItalic", Helvetica, sans-serif;
font-style: normal; /* Web font is already italic */
}
I have to override the UA's bold/italic styling (the commented lines above). Otherwise, it will add a faux-bold/italic look to the text which is very ugly.
If I were to leave it like that, and one of the web font files failed to load, then the fallback font would not have the proper style. For example, this:
<strong>This text is bold</strong>
would display as Helvetica regular if OpenSans-Bold.woff failed to load, but I want it to be Helvetica bold.
How do you make sure that your fallback fonts get the correct bold/italic/regular styling?
you want to combine your #font-face rules.....only declare one font-family name, and declare the weights as your variables, like bold, italic, etc. the example below shows how to use Open Sans Regular with Open Sans Bold:
#font-face{font-family:"open_sansregular";
src:url("http://dev.bowdenweb.com/a/fonts/sans-serif/open-sans/open-sans-regular.eot");
src:url("http://dev.bowdenweb.com/a/fonts/sans-serif/open-sans/open-sans-regular.eot?#iefix") format("embedded-opentype"),
url("http://dev.bowdenweb.com/a/fonts/sans-serif/open-sans/open-sans-regular.woff") format("woff"),
url("http://dev.bowdenweb.com/a/fonts/sans-serif/open-sans/open-sans-regular.ttf") format("truetype"),
url("http://dev.bowdenweb.com/a/fonts/sans-serif/open-sans/open-sans-regular.svg#open_sansregular") format("svg");
font-weight:normal; font-style:normal}
#font-face{font-family:"open_sansregular";
src: url("http://dev.bowdenweb.com/a/fonts/sans-serif/open-sans/bold/open-sans-bold.eot");
src: url("http://dev.bowdenweb.com/a/fonts/sans-serif/open-sans/bold/open-sans-bold.eot?#iefix") format("embedded-opentype"),
url("http://dev.bowdenweb.com/a/fonts/sans-serif/open-sans/bold/open-sans-bold.woff") format("woff"),
url("http://dev.bowdenweb.com/a/fonts/sans-serif/open-sans/bold/open-sans-bold.ttf") format("truetype"),
url("http://dev.bowdenweb.com/a/fonts/sans-serif/open-sans/bold/open-sans-bold.svg#open_sansbold") format("svg");
font-weight:bold; font-style:normal}
if you are familiar wtih #font-face rule, its so easy...the only differences in the two rules above is the url(s) and the font-weight. so for italic, change the url to point to the italic font, and then change the style to font-style:italic.
there's a bunch of benefits you get from this, including less rewrites because you're not going to have to redeclare each font...you only declare it once.
but that essentially reduces your css to this:
body{font-family:"OpenSans", Helvetica, sans-serif}
strong{font-weight:700}
em{font-style:italic}
then simply build a better font stack that provides the amount/level of coverage that you desire.

Resources