My Webpage Doesn't Display Open Sans Font in iOS

I'm trying to use the web-based font Open Sans in a webpage. It seems to be showing well on the Windows side but in OS X 10.8.4 I get nothing but New Times Roman. I can see in iOS other pages with Open Sans font, such as your page right now, but not mine. I followed all kinds of directions I could find on the net regarding this seemingly common problem, to no avail. There may be something additional I'm missing which I have to add to divert the rendering of the font from the server hosting my webpage to some Google server, I guess, but I can't figure out what exactly. Has anyone had a similar problem?
judicoAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Tom BeckCommented:
Clarification: The problem is OS X, not iOS?

What does your @font-face definition look like? Does it include truetype format? Is the font loading?

Example:
@font-face { 
	font-family: 'openSansRegular'; 
	src: url('css/fonts/OpenSans-Regular.ttf') format('truetype');
	font-weight: normal; font-style: normal;
}

Open in new window

0
Tom BeckCommented:
Tested the following in Firefox and Chrome on OS X 10.10.2 and in iOS simulator. Open Sans displays correctly.
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
<style>
@font-face { 
	font-family: 'openSansReg'; 
	src: url('css/OpenSans-Regular.ttf') format('truetype'); 
	font-weight: normal; font-style: normal;
}
.testOpenSans {
	font-family: 'openSansReg';
}
.testTimesNR {
	font-family: 'Times New Roman'
}
.testArial {
	font-family: 'Arial'
}
</style>
</head>
<body>
<p class="testOpenSans">Some text for testing -- OpenSans-Regular</p>
<p class="testTimesNR">Some text for testing -- Times New Roman</p>
<p class="testArial">Some text for testing -- Arial</p>
<p>Some text for testing -- Default</p>
</body>
</html>

Open in new window

Open Sans at the top
0
judicoAuthor Commented:
I tried including your code into my CSS file but that caused no effect. Should the url stay as it's in your code? As for @font-face definition I use it's the following:

@font-face {
font-family: 'Open Sans';
font-style: italic;
font-weight: 400;
src: local('Open Sans Italic'), local('Open-Sans-Italic'),
url('OpenSans-Italic.woff') format('woff'),
url('OpenSans-Italic.ttf') format('truetype');
}
 
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 700;
src: local('Open Sans Bold'), local('Open-Sans-Bold'),
url('OpenSans-Bold.woff') format('woff'),
url('OpenSans-Bold.ttf') format('truetype');
}
 
@font-face {
font-family: 'Open Sans';
font-style: normal;
font-weight: 400;
src: local('Open Sans Regular'), local('Open-Sans-Regular'),
url('OpenSans-Regular.woff') format('woff'),
url('OpenSans-Regular.ttf') format('truetype');

Open in new window

0
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

Tom BeckCommented:
You need to adjust the path to the font file to suite your environment. Make sure the path is accessible to the web server.

I tried your syntax (after adjusting the file paths) and the bold and regular worked in Chrome, Firefox and Safari. The Italic only worked in Firefox until I change font-style:italic to font-style:normal. Then it worked in all three browsers.

Why do you name them all the same, "Open Sans"? How can you differentiate when applying them to your definitions?
0
judicoAuthor Commented:
Let me understand the file-path problem. It appears that the file paths are set up correctly in my code since it renders the font just fine in Windows. Are the file paths different for OS X?
0
judicoAuthor Commented:
Just tested you example of 14:40:07. Same thing -- instead of Open Sans I get Default/No Font which is Times New Roman.
0
judicoAuthor Commented:
Now I placed OpenSans-Regular.ttf in the main directory of the server and omitted css/ when calling it. Works. However, how do you change font color and size? Also, I thought I might be able to assemble all styles in a CSS file and not deal with changing the HTML code. I guess, that's OK, as long as I can also change font color and size.
0
Tom BeckCommented:
The path is critical and no, it's not different on a Mac. The path has to be relative to the css file or it has to be absolute. If your font files are in the same folder as the css file then you don't need to precede the file name with a directory name.

You change the color and size when you use the font in a definition. Here's my test page with sizes and colors.
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<title>Untitled Document</title>
<style>
@font-face {
	font-family: 'Open Sans Regular';
	font-style: normal;
	font-weight: 400;
	src: local('Open Sans Regular'), local('Open-Sans-Regular'),
	url('OpenSans-Regular.woff') format('woff'),
	url('OpenSans-Regular.ttf') format('truetype');
}
@font-face {
	font-family: 'Open Sans Italic';
	font-style: normal;
	font-weight: 400;
	src: local('Open Sans Italic'), local('Open-Sans-Italic'),
	url('OpenSans-Italic.woff') format('woff'),
	url('OpenSans-Italic.ttf') format('truetype');
}
@font-face {
	font-family: 'Open Sans Bold';
	font-style: normal;
	font-weight: 700;
	src: local('Open Sans Bold'), local('Open-Sans-Bold'),
	url('OpenSans-Bold.woff') format('woff'),
	url('OpenSans-Bold.ttf') format('truetype');
}
.testOpenSansRegular {
	font-family: 'Open Sans Regular';
	color:red;
	font-size: 1.2em;
}
.testOpenSansItalic {
	font-family: 'Open Sans Italic';
	color: blue;
	font-size: 1em;
	
}
.testOpenSansBold {
	font-family: 'Open Sans Bold';
	color: green;
	font-size: 1.8em;
}
.testTimesNR {
	font-family: 'Times New Roman'
}
.testArial {
	font-family: 'Arial'
}
</style>
</head>
<body>
<p class="testOpenSansRegular">Some text for testing -- OpenSans-Regular</p>
<p class="testOpenSansItalic">Some text for testing -- OpenSans-Italic</p>
<p class="testOpenSansBold">Some text for testing -- OpenSans-Bold</p>
<p class="testTimesNR">Some text for testing -- Times New Roman</p>
<p class="testArial">Some text for testing -- Arial</p>
<p>Some text for testing -- Default</p>
</body>
</html>

Open in new window

Note that I'm using different names for each style of Open Sans.

Result in Firefox, Chrome and Safari on OS X.
Screen Shot
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
judicoAuthor Commented:
Thanks a lot, Tom. Works very well.
0
Tom BeckCommented:
You're welcome. Glad it worked. Thanks for the points.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Fonts Typography

From novice to tech pro — start learning today.