Custom font not working on iOS even when using all formats possible - html

I'm trying to use the Gill Sans-Light font on my website, but for some reason I can't seem to make the font work on iOS devices only. To demonstrate what I mean, here's a screenshot of the same font when I open my website in an Android phone, and when I open it in an iOS phone.
Android:
iOS:
Yes, I know there are lots of questions in here about this particular problem, I've read through them all but I can't seem to make my font work no matter what solution I use.
If it helps, I used Transfonter to convert the font format to EOT, WOFF2, WOFF, TTF and SVG.
Here's my code:
#font-face {
font-family: 'Gill Sans';
src: url('../fonts/GillSans-Light.eot');
src: url('../fonts/GillSans-Light.eot?#iefix') format('embedded-opentype'),
url('../fonts/GillSans-Light.woff2') format('woff2'),
url('../fonts/GillSans-Light.woff') format('woff'),
url('../fonts/GillSans-Light.ttf') format('truetype'),
url('../fonts/GillSans-Light.svg#GillSans-Light') format('svg');
font-weight: 300;
font-style: normal;
}
Thank you for your help.

iOS and macOS both include Gill Sans as a system font, so you are probably getting the default Regular weight of that, rather than your hosted version.
One option would be to intentionally use the system version on platforms that have a font called Gill Sans installed:
#font-face {
font-family: 'Gill Sans';
src: local('GillSans-Light'),
url('../fonts/GillSans-Light.woff2') format('woff2'),
url('../fonts/GillSans-Light.woff') format('woff');
font-weight: 300;
font-style: normal;
}
A more predictable option, especially for a typeface like this where there are many different “cuts” or digital versions, is to change the font-family name to something less likely to conflict with a system font. For example:
#font-face {
font-family: 'Example family name';
src: url('../fonts/GillSans-Light.woff2') format('woff2'),
url('../fonts/GillSans-Light.woff') format('woff');
font-weight: 300;
font-style: normal;
}
h1 {
font-family: 'Example family name', GillSans-Light, sans-serif;
font-weight: 300;
font-style: normal;
}
Obligatory further reading: https://en.wikipedia.org/wiki/Eric_Gill

Related

How can I load a custom font with CSS in Safari?

I am creating a simple web page and I am applying a custom font (Roboto). I have declared them in the CSS file but Chrome detects it fine and Safari does not.
#font-face {
font-family: 'Roboto';
src: url('/fonts/roboto500.eot');
src: url('/fonts/roboto500.eot') format('embedded-opentype'),
url('/fonts/roboto500.woff2') format('woff2'),
url('/fonts/roboto500.woff') format('woff'),
url('/fonts/roboto500.ttf') format('truetype'),
url('/fonts/roboto500.svg') format('svg');
}
#font-face {
font-family: 'Roboto';
src: url('/fonts/roboto700.eot');
src: url('/fonts/roboto700.eot') format('embedded-opentype'),
url('/fonts/roboto700.woff2') format('woff2'),
url('/fonts/roboto700.woff') format('woff'),
url('/fonts/roboto700.ttf') format('truetype'),
url('/fonts/roboto700.svg') format('svg');
}
h1.site-title,
h2.subtitles {
font-family: 'Roboto' !important;
font-weight: bold;
}
h4.subtitles {
font-family: 'Roboto' !important;
font-weight: bold;
}
p {
font-family: 'Roboto' !important;
font-weight: normal;
color: rgb(90, 90, 90);
}
I checked with the Safari console to see if it was getting the fonts, and it does, but when I look at the files one by one, they don't match the original font.
Finally, thanks to some comments and such, I got it to work using another download link:
https://fonts.googleapis.com/css?family=Roboto
From here Google offers different components to add to the CSS of your project, what I did was, just in case in the future that typography was no longer available in that link and I lost it, I downloaded it from the link that appears and I put it locally in my project and linked it with the relative path.
I have no idea if it was because the files I downloaded didn't work or any other reason, but the fact is that from this link and using only the one in woff2 format, it works both in Chrome and Safari.
#font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 500;
src: url(../fonts/roboto/roboto.woff2) format('woff2');
}
I hope this may be of help to someone in the future. Many thanks to all of you who have responded.

Fonts are not loading but URL is pointing well

I installed the "Recoleta" and "HK Grotesk" fonts on my website but both fonts are not loading on all devices and all browsers (specially Safari, as some people said it often loads on Chrome/Firefox).
I don't understand as the relative URLs are pointing well when I try them.
I'm using Gulp & Scss to compile my css (my fonts are in an original fonts.scss file compiled in a final app.css file).
I tried changing the position of fonts.scss (beginning/middle/end of app.scss) but doesn't change anything.
#font-face {
font-family: 'Recoleta', serif;
src: url('../fonts/recoleta/Recoleta-Medium.woff') format('woff');
src: url('../fonts/recoleta/Recoleta-Medium.eot?#iefix') format('embedded-opentype'),
url('../fonts/recoleta/Recoleta-Medium.eot') format('embedded-opentype'),
url('../fonts/recoleta/Recoleta-Medium.ttf') format('truetype');
font-weight: 500;
font-style: normal;
font-display: swap;
}
#font-face {
font-family: 'HK Grotesk', sans-serif;
src: url('../fonts/hk-grotesk/HKGrotesk-Bold.woff2') format('woff2');
src: url('../fonts/hk-grotesk/HKGrotesk-Bold.eot') format('embedded-opentype'),
url('../fonts/hk-grotesk/HKGrotesk-Bold.woff') format('woff'),
url('../fonts/hk-grotesk/HKGrotesk-Bold.ttf') format('truetype');
font-weight: bold;
font-style: 400;
font-display: swap;
}
This is the expected result : https://ibb.co/MRMk1jM
I just needed to remove the 'serif' or 'sans-serif' in the font-family.
#font-face {
font-family: 'Recoleta';
}
#font-face {
font-family: 'HK Grotesk';
}
#vbernet Kindly, try to genrate the fonts files from this website: (https://www.fontsquirrel.com/tools/webfont-generator) and then implement it. I think one of the font file type is missing which support to safari browser.

How can i include different font-weights with one font file?

I am currently making a website in Wordpress. The problem I have is using a font. I couldn't find an answer to my question here, so I decided to ask myself. Someone send a font to me to use, but the problem is when I open the file there are different styles of that font. To be clearer: the font is Avenir Next and the different styles are Avenir Next Bold, Avenir Next Medium, Avenir Next Ultra Light.
It is not a google font. I have tried to include it with #font-face :
#font-face {
font-family: Avenir Next;
src: url('http://localhost/cultuurfonds/wp-
content/themes/monstroid/fonts/Avenir-Next.ttf');
font-weight: bold;
font-weight: 700;
}
#font-face {
font-family: Avenir Next Medium;
src: url('http://localhost/cultuurfonds/wp-
content/themes/monstroid/fonts/Avenir-Next.ttf');
font-weight: normal;
font-weight: 400;
}
With this I can use the Avenir Next (which is pretty bold, so I don't want to use that), but Avenir Next Medium doesn't work.
It is a paid font, but I am not the one who bought it. That person send the font file (Avenir-Next.ttf) to me, so this is what I have to work with.
I prefer to not use a plugin to include it. I couldn't find a good plugin for it anyway. But if there is no other way than to use a plugin, I am willing to use it.
I hope my question is clear (first question here).
If you want to load fonts from your local files, firstly you have to use tools like https://www.web-font-generator.com/ to generate different formats of the font.
Then you have to load all formats of the font like this
#font-face {
font-family: 'AvenirNextLTPro';
src: url('fonts/AvenirNextLTPro-Regular.eot?#iefix') format('embedded-opentype'),
url('fonts/AvenirNextLTPro-Regular.otf') format('opentype'),
url('fonts/AvenirNextLTPro-Regular.woff') format('woff'),
url('fonts/AvenirNextLTPro-Regular.ttf') format('truetype'),
url('fonts/AvenirNextLTPro-Regular.svg#AvenirNextLTPro-Regular') format('svg');
font-weight: 400;
font-style: normal;
}
#font-face {
font-family: 'AvenirNextLTPro';
src: url('fonts/AvenirNextLTPro-Demi.eot?#iefix') format('embedded-opentype'),
url('fonts/AvenirNextLTPro-Demi.woff') format('woff'),
url('fonts/AvenirNextLTPro-Demi.ttf') format('truetype'),
url('fonts/AvenirNextLTPro-Demi.svg#AvenirNextLTPro-Demi') format('svg');
font-weight: 500;
font-style: normal;
}
As you can see font-family name is the same, but font weight size is different (Regular - 400 and Demi - 500)
Then, when you want to use different font weight in different elements you have to declare it like this:
p {
font-family: 'AvenirNextLTPro';
font-weight: 400;
}
h1 {
font-family: 'AvenirNextLTPro';
font-weight: 500;
}

Does certain fonts can't be used for embedding in css?

I am trying to embed a font and I tried it before and it works. My code was just a regular one which is accepted by other browsers.
#font-face {
font-family: KozGoPr6N;
src: url('../font/KozGoPr6N-Bold.otf') format('opentype');
src: url('../font/KozGoPr6N-Bold.woff') format('woff');
font-weight: normal;
font-style: normal;
}
But then when I am trying to embed ShinGoPro it doesn't work at all.
This is my code before:
#font-face {
font-family: ShinGoPro-Bold;
src: url('../fonts/ShinGoPro-Bold.otf') format('opentype');
src: url('../fonts/ShinGoPro-bold.woff') format('woff');
font-weight: bold;
font-style: normal;
}
Then I use fontsquirrel and still it doesn't work.
#font-face {
font-family: 'a-otf_shin_go_pror';
src: url('../fonts/shingopro-regular-webfont.eot');
src: url('../fonts/shingopro-regular-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/shingopro-regular-webfont.woff2') format('woff2'),
url('../fonts/shingopro-regular-webfont.woff') format('woff'),
url('../fonts/shingopro-regular-webfont.ttf') format('truetype'),
url('../fonts/shingopro-regular-webfont.svg#a-otf_shin_go_pror') format('svg');
font-weight: normal;
font-style: normal;
}
Somehow I've been thinking if this font is not applicable for embedding but then I do need to get this font to work for my web page. Does this font cannot really be embedded in CSS? Is there anything I can do for this to work?
EDIT
My code is for crossbrowser and it doesn't work at all. I linked the file of the font so that people can try what I'm trying to do. I already tried using fontsquirrel and it doesn't work at all.
Does this font cannot really be embedded in CSS? Is there anything I can do for this to work?
^ This is referring to all browsers.

How can I use Google's Roboto font on a website?

I want to use Google's Roboto font on my website and I am following this tutorial:
http://www.maketecheasier.com/use-google-roboto-font-everywhere/2012/03/15
I have downloaded the file which has a folder structure like this:
Now I have three questions:
I have css in my media/css/main.css url. So where do I need to put that folder?
Do I need to extract all eot,svg etc from all sub folder and put in fonts folder?
Do I need to create css file fonts.css and include in my base template file?
The example he uses this
#font-face {
font-family: 'Roboto';
src: url('Roboto-ThinItalic-webfont.eot');
src: url('Roboto-ThinItalic-webfont.eot?#iefix') format('embedded-opentype'),
url('Roboto-ThinItalic-webfont.woff') format('woff'),
url('Roboto-ThinItalic-webfont.ttf') format('truetype'),
url('Roboto-ThinItalic-webfont.svg#RobotoThinItalic') format('svg'); (under the Apache Software License).
font-weight: 200;
font-style: italic;
}
What should my url look like, if I want to have the dir structure like:
/media/fonts/roboto
You don't really need to do any of this.
Go to Google's Web Fonts page
search for Roboto in the search box at the top right
Select the variants of the font you want to use
click 'Select This Font' at the top and choose the weights and character sets you need.
The page will give you a <link> element to include in your pages, and a list of sample font-family rules to use in your CSS.
Using Google's fonts this way guarantees availability, and reduces bandwidth to your own server.
There are TWO approaches that you can take to use licensed web-fonts on your pages:
1. Font Hosting Services like Typekit, Fonts.com, Fontdeck, etc.
These services provide an easy interface for designers to manage fonts purchased, and generate a link to a dynamic CSS or JavaScript file that serves up the font. Google even provides this service for free (here is an example for the Roboto font you requested).
JS font loaders like the one used by Google and Typekit (i.e. WebFont loader) provide CSS classes and callbacks to help manage the FOUT that may occur, or response timeouts when downloading the font.
<head>
<!-- get the required files from 3rd party sources -->
<link href='http://fonts.googleapis.com/css?family=Roboto' rel='stylesheet' type='text/css'>
<!-- use the font -->
<style>
body {
font-family: 'Roboto', sans-serif;
font-size: 48px;
}
</style>
</head>
2. The DIY approach
This involves getting a font licensed for web use, and (optionally) using a tool like FontSquirrel's generator (or some software) to optimize its file size. Then, a cross-browser implementation of the standard #font-face CSS property is used to enable the font(s).
This approach can provide better load performance since you have a more granular control over the characters to include and hence the file-size.
/* get the required local files */
#font-face {
font-family: 'Roboto';
src: url('roboto.eot'); /* IE9 Compat Modes */
src: url('roboto.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('roboto.woff') format('woff'), /* Modern Browsers */
url('roboto.ttf') format('truetype'), /* Safari, Android, iOS */
url('roboto.svg#svgFontName') format('svg'); /* Legacy iOS */
}
/* use the font */
body {
font-family: 'Roboto', sans-serif;
font-size: 48px;
}
TLDR;
There are two major approches to embed custom fonts on your website. Using font hosting services along with #font-face declaration gives best output with respect to overall performance, compatibility and availability.
Source: https://www.artzstudio.com/2012/02/web-font-performance-weighing-fontface-options-and-alternatives/ (link is dead)
UPDATE
Roboto: Google’s signature font is now open source. You can now manually generate the Roboto fonts using instructions that can be found here.
Old post, I know.
This is also possible using CSS #import url:
#import url(http://fonts.googleapis.com/css?family=Roboto:400,100,100italic,300,300ita‌​lic,400italic,500,500italic,700,700italic,900italic,900);
html, body, html * {
font-family: 'Roboto', sans-serif;
}
The src refers directly to the font files, therefore if you place all of them on /media/fonts/roboto you should refer to them in your main.css like this:
src: url('../fonts/roboto/Roboto-ThinItalic-webfont.eot');
The .. goes one folder up, which means you're referring to the media folder if the main.css is in the /media/css folder.
You have to use ../fonts/roboto/ in all url references in the CSS (and be sure that the files are in this folder and not in subdirectories, such as roboto_black_macroman).
Basically (answering to your questions):
I have css in my media/css/main.css url. So where do i need to put that folder
You can leave it there, but be sure to use src: url('../fonts/roboto/
Do i need to extract all eot,svg etc from all sub folder and put in fonts folder
If you want to refer to those files directly (without placing the subdirectories in your CSS code), then yes.
Do i need to create css file fonts.css and include in my base template file
Not necessarily, you can just include that code in your main.css. But it's a good practice to separate fonts from your customized CSS.
Here's an example of a fonts LESS/CSS file I use:
#ttf: format('truetype');
#font-face {
font-family: 'msb';
src: url('../font/msb.ttf') #ttf;
}
.msb {font-family: 'msb';}
#font-face {
font-family: 'Roboto';
src: url('../font/Roboto-Regular.ttf') #ttf;
}
.rb {font-family: 'Roboto';}
#font-face {
font-family: 'Roboto Black';
src: url('../font/Roboto-Black.ttf') #ttf;
}
.rbB {font-family: 'Roboto Black';}
#font-face {
font-family: 'Roboto Light';
src: url('../font/Roboto-Light.ttf') #ttf;
}
.rbL {font-family: 'Roboto Light';}
(In this example I'm only using the ttf)
Then I use #import "fonts"; in my main.less file (less is a CSS preprocessor, it makes things like this a little bit easier)
For Website you can use 'Roboto' font as below:
If you have created separate css file then put below line at the top of css file as:
#import url('https://fonts.googleapis.com/css?family=Roboto:300,300i,400,400i,500,500i,700,700i,900,900i');
Or if you don't want to create separate file then add above line in between <style>...</style>:
<style>
#import url('https://fonts.googleapis.com/css?
family=Roboto:300,300i,400,400i,500,500i,700,700i,900,900i');
</style>
then:
html, body {
font-family: 'Roboto', sans-serif;
}
With css:
#font-face {
font-family: 'Roboto';
src: url('../font/Roboto-Regular.ttf') format('truetype');
font-weight: normal;
font-style: normal;
}
/* etc, etc. */
With sass:
#font-face
font-family: 'Roboto'
src: local('Roboto'), local('Roboto-Regular'), url('../fonts/Roboto-Regular.ttf') format('truetype')
font-weight: normal
font-style: normal
#font-face
font-family: 'Roboto'
src: local('Roboto Bold'), local('Roboto-Bold'), url('../fonts/Roboto-Bold.ttf') format('truetype')
font-weight: bold
font-style: normal
#font-face
font-family: 'Roboto'
src: local('Roboto Italic'), local('Roboto-Italic'), url('../fonts/Roboto-Italic.ttf') format('truetype')
font-weight: normal
font-style: italic
#font-face
font-family: 'Roboto'
src: local('Roboto BoldItalic'), local('Roboto-BoldItalic'), url('../fonts/Roboto-BoldItalic.ttf') format('truetype')
font-weight: bold
font-style: italic
#font-face
font-family: 'Roboto'
src: local('Roboto Light'), local('Roboto-Light'), url('../fonts/Roboto-Light.ttf') format('truetype')
font-weight: 300
font-style: normal
#font-face
font-family: 'Roboto'
src: local('Roboto LightItalic'), local('Roboto-LightItalic'), url('../fonts/Roboto-LightItalic.ttf') format('truetype')
font-weight: 300
font-style: italic
#font-face
font-family: 'Roboto'
src: local('Roboto Medium'), local('Roboto-Medium'), url('../fonts/Roboto-Medium.ttf') format('truetype')
font-weight: 500
font-style: normal
#font-face
font-family: 'Roboto'
src: local('Roboto MediumItalic'), local('Roboto-MediumItalic'), url('../fonts/Roboto-MediumItalic.ttf') format('truetype')
font-weight: 500
font-style: italic
/* Roboto-Regular.ttf 400 */
/* Roboto-Bold.ttf 700 */
/* Roboto-Italic.ttf 400 */
/* Roboto-BoldItalic.ttf 700 */
/* Roboto-Medium.ttf 500 */
/* Roboto-MediumItalic.ttf 500 */
/* Roboto-Light.ttf 300 */
/* Roboto-LightItalic.ttf 300 */
/* https://fonts.google.com/specimen/Roboto#standard-styles */
This is what I did to get the woff2 files I wanted for static deployment without having to use a CDN
TEMPORARILY add the cdn for the css to load the roboto fonts into index.html and let the page load.
from google dev tools look at sources and expand the fonts.googleapis.com node and view the content of the css?family=Roboto:300,400,500&display=swap file and copy the content. Put this content in a css file in your assets directory.
In the css file, remove all the greek, cryllic and vietnamese stuff.
Look at the lines in this css file that are similar to:
src: local('Roboto Light'), local('Roboto-Light'), url(https://fonts.gstatic.com/s/roboto/v20/KFOlCnqEu92Fr1MmSU5fBBc4.woff2) format('woff2');
copy the link address and paste it in your browser, it will download the font. Put this font into your assets folder and rename it here, as well as in the css file. Do this to the other links, I had 6 unique woff2 files.
I followed the same steps for material icons.
Now go back and comment the line where you call the cdn and instead use use the new css file you created.
Try this
<style>
#font-face {
font-family: Roboto Bold Condensed;
src: url(fonts/Roboto_Condensed/RobotoCondensed-Bold.ttf);
}
#font-face {
font-family:Roboto Condensed;
src: url(fonts/Roboto_Condensed/RobotoCondensed-Regular.tff);
}
div1{
font-family:Roboto Bold Condensed;
}
div2{
font-family:Roboto Condensed;
}
</style>
<div id='div1' >This is Sample text</div>
<div id='div2' >This is Sample text</div>
Use /fonts/ or /font/ before font type name in your CSS stylesheet. I face this error but after that its working fine.
#font-face {
font-family: 'robotoregular';
src: url('../fonts/Roboto-Regular-webfont.eot');
src: url('../fonts/Roboto-Regular-webfont.eot?#iefix') format('embedded-opentype'),
url('../fonts/Roboto-Regular-webfont.woff') format('woff'),
url('../fonts/Roboto-Regular-webfont.ttf') format('truetype'),
url('../fonts/Roboto-Regular-webfont.svg#robotoregular') format('svg');
font-weight: normal;
font-style: normal;
}
/* -- Roboto-Family -- */
#font-face {
font-family: 'Roboto';
src: url('./fonts/Roboto/Roboto-Thin.woff') format('woff'), url('./fonts/Roboto/Roboto-Thin.ttf') format('truetype');
font-weight: 100;
font-style: normal;
}
#font-face {
font-family: 'Roboto';
src: url('./fonts/Roboto/Roboto-ThinItalic.woff') format('woff'), url('./fonts/Roboto/Roboto-ThinItalic.ttf') format('truetype');
font-weight: 100;
font-style: italic;
}
#font-face {
font-family: 'Roboto';
src: url('./fonts/Roboto/Roboto-Light.woff') format('woff'), url('./fonts/Roboto/Roboto-Light.ttf') format('truetype');
font-weight: 300;
font-style: normal;
}
#font-face {
font-family: 'Roboto';
src: url('./fonts/Roboto/Roboto-Regular.woff') format('woff'), url('./fonts/Roboto/Roboto-Regular.ttf') format('truetype');
font-weight: 400;
font-style: normal;
}
#font-face {
font-family: 'Roboto';
src: url('./fonts/Roboto/Roboto-Italic.woff') format('woff'), url('./fonts/Roboto/Roboto-Italic.ttf') format('truetype');
font-weight: 400;
font-style: italic;
}
#font-face {
font-family: 'Roboto';
src: url('./fonts/Roboto/Roboto-Medium.woff') format('woff'), url('./fonts/Roboto/Roboto-Medium.ttf') format('truetype');
font-weight: 500;
font-style: normal;
}
#font-face {
font-family: 'Roboto';
src: url('./fonts/Roboto/Roboto-MediumItalic.woff') format('woff'), url('./fonts/Roboto/Roboto-MediumItalic.ttf') format('truetype');
font-weight: 500;
font-style: italic;
}
#font-face {
font-family: 'Roboto';
src: url('./fonts/Roboto/Roboto-Bold.woff') format('woff'), url('./fonts/Roboto/Roboto-Bold.ttf') format('truetype');
font-weight: 700;
font-style: normal;
}
#font-face {
font-family: 'Roboto';
src: url('./fonts/Roboto/Roboto-Black.woff') format('woff'), url('./fonts/Roboto/Roboto-Black.ttf') format('truetype');
font-weight: 900;
font-style: normal;
}
#font-face {
font-family: 'Roboto';
src: url('./fonts/Roboto/Roboto-BlackItalic.woff') format('woff'), url('./fonts/Roboto/Roboto-BlackItalic.ttf') format('truetype');
font-weight: 900;
font-style: italic;
}
/* -- Roboto-Condensed-Family -- */
#font-face {
font-family: 'Roboto Condensed';
src: url('./fonts/Roboto/RobotoCondensed-Bold.woff') format('woff'), url('./fonts/Roboto/RobotoCondensed-Bold.ttf') format('truetype');
font-weight: 700;
font-style: normal;
}
#font-face {
font-family: 'Roboto Condensed';
src: url('./fonts/Roboto/RobotoCondensed-BoldItalic.woff') format('woff'), url('./fonts/Roboto/RobotoCondensed-BoldItalic.ttf') format('truetype');
font-weight: 700;
font-style: italic;
}
#font-face {
font-family: 'Roboto Condensed';
src: url('./fonts/Roboto/RobotoCondensed-Light.woff') format('woff'), url('./fonts/Roboto/RobotoCondensed-Light.ttf') format('truetype');
font-weight: 300;
font-style: normal;
}
#font-face {
font-family: 'Roboto Condensed';
src: url('./fonts/Roboto/RobotoCondensed-LightItalic.woff') format('woff'), url('./fonts/Roboto/RobotoCondensed-LightItalic.ttf') format('truetype');
font-weight: 300;
font-style: italic;
}
it's easy
every folder of those you downloaded has a different kind of roboto font, means they are different fonts
example: "roboto_regular_macroman"
to use any of them:
1- extract the folder of the font you want to use
2- upload it near the css file
3- now include it in the css file
example for including the font which called "roboto_regular_macroman":
#font-face {
font-family: 'Roboto';
src: url('roboto_regular_macroman/Roboto-Regular-webfont.eot');
src: url('roboto_regular_macroman/Roboto-Regular-webfont.eot?#iefix') format('embedded-opentype'),
url('roboto_regular_macroman/Roboto-Regular-webfont.woff') format('woff'),
url('roboto_regular_macroman/Roboto-Regular-webfont.ttf') format('truetype'),
url('roboto_regular_macroman/Roboto-Regular-webfont.svg#RobotoRegular') format('svg');
font-weight: normal;
font-style: normal;
}
watch for the path of the files, here i uploaded the folder called "roboto_regular_macroman" in the same folder where the css is
then you can now simply use the font by typing font-family: 'Roboto';
It's actually quite simple. Go to the font on Google's website, and add its link to the head of every page you want to include the font.
Did you read the How_To_Use_Webfonts.html that's in that zip file?
After reading that, it seems that each font subfolder has an already created .css in there that you can use by including this:
<link rel="stylesheet" href="stylesheet.css" type="text/css" charset="utf-8" />
Spent an hour, fixing the font issues.
Related answer - Below is for React.js website:
Install the npm module:
npm install --save typeface-roboto-mono
import in .js file you want to use
one of the below:
import "typeface-roboto-mono"; // if import is supported
require('typeface-roboto-mono') // if import is not supported
For the element you can use
one of the below:
fontFamily: "Roboto Mono, Menlo, Monaco, Courier, monospace", // material-ui
font-family: Roboto Mono, Menlo, Monaco, Courier, monospace; /* css */
style="font-family:Roboto Mono, Menlo, Monaco, Courier, monospace;font-weight:300;" /*inline css*/
Hope that helps.