Can anybody get these two fonts work as Webfont? I use almost webfont generator services but none works - webfonts

I have tried many times to generate or convert these two fonts into webfont but they are not working. I try almost webfont services found in Google search result but none works. Here are the fonts:
1) NotoSerifLao-Regular https://www.dropbox.com/s/a4e5jfwy5umlj41/NotoSerifLao-Regular.ttf?dl=0
2) NotoSerifLao-SemiBold https://www.dropbox.com/s/2x84v1acibga5iu/NotoSerifLao-SemiBold.ttf?dl=0
This webfont generator service https://www.fontsquirrel.com doesn't work at all but this service https://fontie.pixelsvsbytes.com works only with NotoSerifLao-Regular (the first one) but doesn't work with NotoSerifLao-SemiBold (the second one). I don't understand why it doesn't work with the second one, but the first one. I have these two fonts in my computer and they both work fine in MS Office.
I place the generated/converted fonts in a child theme like this:
-----fonts (folder)
child-theme}
-----css (folder)
So the path in my css looks like this:
#font-face {
font-family:'Noto Serif Lao';
src: url('fonts/Noto Serif Lao Regular.eot');
src: url('fonts/Noto Serif Lao Regular.eot?#iefix') format('embedded-opentype'),
url('fonts/Noto Serif Lao Regular.woff2') format('woff2'),
url('fonts/Noto Serif Lao Regular.woff') format('woff'),
url('fonts/Noto Serif Lao Regular.ttf') format('truetype'),
url('fonts/Noto Serif Lao Regular.svg#Noto Serif Lao Regular') format('svg');
font-weight: 400;
font-style: normal;
font-stretch: normal;
unicode-range: U+0020-00A0;
}
The above code is the example of the first font generated from this service fontie.pixelsvsbytes.com. And it works. As I said, this website works only with the first font, not the second one. The paths are same and correct. No errors found in chrome. I've tried other webfont generator services but they don't work at all. Could you please tell me how to get these two fonts work as webfont? Or if you know other webfont generator websites, please let me know. But I've tried almost all found in Google, none works. I've shared the fonts via Dropbox. You can download and test them.

With webfonts (and really any font in general) the bold and italic and other variations are actually separate files that need to be loaded. So if you're using regular, bold, italic, and bold italic, you would need to load four separate files.
Google fonts
Just like with self-hosted, you have to explicitly tell Google fonts to get all of the weights and variants you want. You do that in the little box where you get the embed code. Click on the 'Customize' tab, and choose the variations you want.
Here are some examples. I'm using the #import option here, which you'd just drop into your stylesheet, but the pattern is the same for the standard link tag.
By default, it only includes the regular weight:
#import url('https://fonts.googleapis.com/css?family=Noto+Serif');
If you want regular and bold, it looks like this:
#import url('https://fonts.googleapis.com/css?family=Noto+Serif:400,700');
And if you want italics for both of those, you'd add those too:
#import url('https://fonts.googleapis.com/css?family=Noto+Serif:400,400i,700,700i');
Self-Hosted
In your code above it looks to me like you need to define the semibold font. If the CSS above is complete, it only defines the regular weight. The paths to the semibold versions need to be defined in another #font-face directive, with the font-weight set differently. It should probably look something like this:
#font-face {
font-family:'Noto Serif Lao';
src: url('fonts/Noto Serif Lao Regular.eot');
src: url('fonts/Noto Serif Lao Regular.eot?#iefix') format('embedded-opentype'),
url('fonts/Noto Serif Lao Regular.woff2') format('woff2'),
url('fonts/Noto Serif Lao Regular.woff') format('woff'),
url('fonts/Noto Serif Lao Regular.ttf') format('truetype'),
url('fonts/Noto Serif Lao Regular.svg#Noto Serif Lao Regular') format('svg');
font-weight: 400;
font-style: normal;
font-stretch: normal;
}
#font-face {
font-family:'Noto Serif Lao';
src: url('fonts/Noto Serif Lao Semibold.eot');
src: url('fonts/Noto Serif Lao Semibold.eot?#iefix') format('embedded-opentype'),
url('fonts/Noto Serif Lao Semibold.woff2') format('woff2'),
url('fonts/Noto Serif Lao Semibold.woff') format('woff'),
url('fonts/Noto Serif Lao Semibold.ttf') format('truetype'),
url('fonts/Noto Serif Lao Semibold.svg#Noto Serif Lao Semibold') format('svg');
font-weight: 700;
font-style: normal;
font-stretch: normal;
}
Working versions
Google Fonts
This one only uses regular and bold, without the italics. But you can set the #import directive to bring in whatever you need for the project. Just be careful to only load what you need, since lots of font files can slow down your site.
#import url('https://fonts.googleapis.com/css?family=Noto+Serif:400,700');
#import url(//fonts.googleapis.com/earlyaccess/notosanslao.css);
#import url(//fonts.googleapis.com/earlyaccess/notoseriflao.css);
h1 { font-family: sans-serif; margin: 0; }
h1.noto { font-family: 'Noto Serif', sans-serif; font-weight: 400; }
h1.bold { font-weight: 700; }
h1.lao { font-family: 'Noto Serif Lao'; font-weight: 400; }
h1.lao-bold { font-family: 'Noto Serif Lao'; font-weight: 700; }
h1.sans-lao { font-family: 'Noto Sans Lao'; font-weight: 400; }
h1.sans-lao-bold { font-family: 'Noto Sans Lao'; font-weight: 700; }
<h1 class="lao">ຕົວອັກສອນລາວ</h1>
<h1 class="lao-bold">ຕົວອັກສອນລາວ</h1>
<h1 class="sans-lao">ຕົວອັກສອນລາວ</h1>
<h1 class="sans-lao-bold">ຕົວອັກສອນລາວ</h1>
<h1 class="noto">Noto Serif Lao</h1>
<h1 class="noto bold">Noto Serif Lao Semibold</h1>
Self-hosted
For the self-hosted I only specified the TTF version since that's what you supplied above. I just used the Dropbox links for this demo, but you can swap them out for your specific paths. If you want to include other font formats (.woff, .svg, etc) you'll need to make sure you have separate files for all of those, for both weights.
font-face {
font-family:'Noto Serif Lao';
src: url('https://nwalton3.github.io/fonts/noto/noto-serif-lao/notoseriflao-regular-webfont.woff2') format('woff2'),
url('https://nwalton3.github.io/fonts/noto/noto-serif-lao/notoseriflao-regular-webfont.woff') format('woff');
font-weight: 400;
font-style: normal;
font-stretch: normal;
unicode-range: U+0E80-0EFF;
}
#font-face {
font-family:'Noto Serif Lao';
src: url('https://nwalton3.github.io/fonts/noto/noto-serif-lao/notoseriflao-bold-webfont.woff2') format('woff2'),
url('https://nwalton3.github.io/fonts/noto/noto-serif-lao/notoseriflao-bold-webfont.woff') format('woff');
font-weight: 700;
font-style: normal;
font-stretch: normal;
unicode-range: U+0E80-0EFF;
}
.lao {
font-family: 'Noto Serif Lao';
font-weight: 400;
}
.lao-bold {
font-family: 'Noto Serif Lao';
font-weight: 700;
}
<h1>No font: ຕົວອັກສອນລາວ</h1>
<h1 class="lao">Regular: ຕົວອັກສອນລາວ</h1>
<h1 class="lao-bold">Bold: ຕົວອັກສອນລາວ</h1>

I've worked on this some more and I found a couple of things.
It looks like the unicode ranges you were using are wrong. Lao characters have a unicode range of 0E80-0EFF.
Some of the font converters like to strip out non-latin characters, so that could be causing some issues as well. You need to make sure there's no subsetting, or that you've specified the Lao characters in the subset. I converted these with FontSquirrel and chose the Expert option with no subsetting. A similar issue was discussed in this question.
It looks like there may still be some spacing issues, but you'd be a better judge of that.
#font-face {
font-family: 'Noto Serif Lao';
src: url('https://nwalton3.github.io/fonts/noto/noto-serif-lao/notoseriflao-regular-webfont.woff2') format('woff2'),
url('https://nwalton3.github.io/fonts/noto/noto-serif-lao/notoseriflao-regular-webfont.woff') format('woff');
font-weight: 400;
font-style: normal;
font-stretch: normal;
unicode-range: U+0E80-0EFF;
}
#font-face {
font-family: 'Noto Serif Lao';
src: url('https://nwalton3.github.io/fonts/noto/noto-serif-lao/notoseriflao-bold-webfont.woff2') format('woff2'),
url('https://nwalton3.github.io/fonts/noto/noto-serif-lao/notoseriflao-bold-webfont.woff') format('woff');
font-weight: 700;
font-style: normal;
font-stretch: normal;
unicode-range: U+0E80-0EFF;
}
.lao {
font-family: 'Noto Serif Lao', sans-serif;
font-weight: 400;
}
.lao-bold {
font-family: 'Noto Serif Lao', sans-serif;
font-weight: 700;
}
<h1 class="lao">Regular: ຕົວອັກສອນລາວ</h1>
<h1 class="lao-bold">Bold: ຕົວອັກສອນລາວ</h1>

Related

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

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

How do I specify that "bold" should be "Avenir Heavy" not "Avenir Black"?

I need to send HTML-formatted email using the Avenir font (if it's present in the OS). Two of this font's weights are Heavy and Black (the latter being the heaviest weight). I want mail clients to use Avenir Heavy for bold text, but they're using Avenir Black instead.
In my HTML I have a <style type="text/css"> tag with:
body {
font-family: Avenir, Helvetica, Arial, sans-serif;
}
.font_h1 {
font-weight: bold;
}
When I open my HTML file in a desktop browser (Firefox, Chrome, or Safari), it uses Avenir Heavy as the bold font. But when I email it and view it in Mac Outlook 2016 or in iOS 10's Mail client, those display the bold font with Avenir Black, which is a much heavier font. Same thing happens if I specify the font-weight as bolder.
Oddly, if I say:
body {
font-family: Avenir Heavy;
}
then the page is still rendered by desktop browsers with Avenir Medium, with Avenir Heavy used for bold.
I don't think that #font-face is my answer, because I'm not loading a font from a URL.
How can I tell the browser or mail client to specifically use Avenir Heavy as the bold weight?
I declare Avenir like this:
#font-face {
font-family: 'Avenir';
font-weight: 300;
font-style: normal;
src: local('Avenir Book'), local('Avenir-300'),
url('../../assets/fonts/Avenir-Book/Avenir-Book.eot') format('embedded-opentype'),
url('../../assets/fonts/Avenir-Book/Avenir-Book.woff') format('woff'),
url('../../assets/fonts/Avenir-Book/Avenir-Book.ttf') format('truetype');
}
#font-face {
font-family: 'Avenir';
font-weight: 500;
font-style: normal;
src: local('Avenir Medium'), local('Avenir-500'),
url('../../assets/fonts/Avenir-Medium/Avenir-Medium.eot') format('embedded-opentype'),
url('../../assets/fonts/Avenir-Medium/Avenir-Medium.woff') format('woff'),
url('../../assets/fonts/Avenir-Medium/Avenir-Medium.ttf') format('truetype');
}
#font-face {
font-family: 'Avenir';
font-weight: 700;
font-style: normal;
src: local('Avenir Heavy'), local('Avenir-700'),
url('../../assets/fonts/Avenir-Heavy/Avenir-Heavy.eot') format('embedded-opentype'),
url('../../assets/fonts/Avenir-Heavy/Avenir-Heavy.woff') format('woff'),
url('../../assets/fonts/Avenir-Heavy/Avenir-Heavy.ttf') format('truetype');
}
#font-face {
font-family: 'Avenir';
font-weight: 900;
font-style: normal;
src: local('Avenir Black'), local('Avenir-900'),
url('../../assets/fonts/Avenir-Black/Avenir-Black.eot') format('embedded-opentype'),
url('../../assets/fonts/Avenir-Black/Avenir-Black.woff') format('woff'),
url('../../assets/fonts/Avenir-Black/Avenir-Black.ttf') format('truetype');
}
And then in CSS:
body {
font-family: Avenir, Helvetica, Arial, sans-serif;
}
h1 {
font-weight: 900; // black
}
h2 {
font-weight: 700; // heavy
}
h3 {
font-weight: 500; // medium
}
...
I think you need to explicitly open the font (using a font processing app, such as fontforge) and check which family it belongs to. Then use that family name and you'll be home safe. Also, if you want to be precise about your weights, use numbered values such as
400 for normal
700 for bold
900 for black
etc.

H1 Font Weight displays different on WordPress Staging Site

There is something that I am not seeing that I could use some help on.
The CSS for the H1 tag on this site: www.californiacounselgroup.com is what I'm trying to put on the staging site. If you look at "Fixed-Fee Legal Service" on the live site, the text is thin (300 weight).
If you look at the same text on the staging site, it is different. http://calcou.01hearts.com/ .
I've cleared cache, tried two browsers and inspected element. I've checked that the "Lato" Google Font is loaded into the theme options the same.
What's am I not seeing here? Any help would be appreciated.
Teresa
Looking at the headers being sent to Google fonts It doesn't appear that you are actually pulling the font weight of 300. I'm only seeing 400, 700 in both regular and italic.
This is how the header parameters are being pulled:
#font-face {
font-family: 'Lato';
font-style: normal;
font-weight: 400;
src: local('Lato Regular'), local('Lato-Regular'), url(http://fonts.gstatic.com/s/lato/v11/1YwB1sO8YE1Lyjf12WNiUA.woff2) format('woff2');
}
#font-face {
font-family: 'Lato';
font-style: normal;
font-weight: 700;
src: local('Lato Bold'), local('Lato-Bold'), url(http://fonts.gstatic.com/s/lato/v11/H2DMvhDLycM56KNuAtbJYA.woff2) format('woff2');
}
#font-face {
font-family: 'Lato';
font-style: italic;
font-weight: 400;
src: local('Lato Italic'), local('Lato-Italic'), url(http://fonts.gstatic.com/s/lato/v11/PLygLKRVCQnA5fhu3qk5fQ.woff2) format('woff2');
}
#font-face {
font-family: 'Lato';
font-style: italic;
font-weight: 700;
src: local('Lato Bold Italic'), local('Lato-BoldItalic'), url(http://fonts.gstatic.com/s/lato/v11/HkF_qI1x_noxlxhrhMQYEFtXRa8TVwTICgirnJhmVJw.woff2) format('woff2');
}
Try making sure you're actually pulling font weight 300 from Google.

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.

How to define separate fonts for each font-style - CSS

I have an HTML page, containing various font-styles like normal, bold, italics, oblique etc., defined using CSS. I want to use separate fonts for each font-style, say, myboldfont for bold, myitalicsfont for italics etc. I import fonts using #font-face, like,
#font-face {
font-family: "MyNormal";
font-style: normal;
font-weight: normal;
src: url("mynormalfont.woff") format("woff");
}
#font-face {
font-family: "MyBold";
font-style: normal;
font-weight: normal;
src: url("myboldfont.woff") format("woff");
}
#font-face {
font-family: "MyItalics";
font-style: normal;
font-weight: normal;
src: url("myitalicsfont.woff") format("woff");
}
#font-face {
font-family: "MyOblique";
font-style: normal;
font-weight: normal;
src: url("myobliquefont.woff") format("woff");
}
and imported normal, italics, bold and oblique fonts. I defined body styling like;
body{
font-family: MyNormal, MyBold, MyItalics, MyOblique;
}
Is this enough to define styling for all font-styles in the body? I mean if I assign font-style: italic or font-weight: bold to an element, will the italics font or bold font be used? Or what should I do to achieve this, so that if I use font-weight: bold for any element, myboldfont.woff should be used.
This should work:
#font-face {
font-family: "MyFont";
font-style: normal;
font-weight: normal;
src: url("mynormalfont.woff") format("woff");
}
#font-face {
font-family: "MyFont";
font-style: normal;
font-weight: bold;
src: url("myboldfont.woff") format("woff");
}
And this:
...{
font-family:"MyFont";
font-weight:bold;
}...
Then you would always use the same name for the font-family, but you would change the different properties.
The CSS listed in the question is the safest approach. IE8 has display issues when more than 1 weight, or when more than 4 weights or styles, are linked to a font-family name. Using a unique font-family name for each font variation avoids this problem.
When a unique font-family name is used for each font variation, it's not necessary to identify the weight or style in the #font-face declartion, or in the CSS rules for HTML elements that use the font.
Also, to support the widest possible set of browsers, use a combination of .woff, .ttf, and .eot for the embedded fonts. This is the approach used by TypeKit:
#font-face {
font-family: 'MyNormal';
src: url('mynormalfont.eot');
src: url('mynormalfont.eot?#iefix')
format('embedded-opentype'),
url('mynormalfont.woff') format('woff'),
url('mynormalfont.ttf') format('truetype');
}
#font-face {
font-family: 'MyBold';
src: url('myboldfont.eot');
src: url('myboldfont.eot?#iefix')
format('embedded-opentype'),
url('myboldfont.woff') format('woff'),
url('myboldfont.ttf') format('truetype');
}
#font-face {
font-family: 'MyItalics';
src: url('myitalicsfont.eot');
src: url('myitalicsfont.eot?#iefix')
format('embedded-opentype'),
url('myitalicsfont.woff') format('woff'),
url('myitalicsfont.ttf') format('truetype');
}
#font-face {
font-family: 'MyOblique';
src: url('myobliquefont.eot');
src: url('myobliquefont.eot?#iefix')
format('embedded-opentype'),
url('myobliquefont.woff') format('woff'),
url('myobliquefont.ttf') format('truetype');
}
And the font variants are used as follows:
p {
font-family: MyNormal, sans-serif; /* Still useful to add fallback fonts */
font-size: 12px;
}
h2 {
font-family: MyBold, sans-serif;
font-size: 20px;
}
The downside is that the font-family name has to be specified in every CSS rule that uses one of the font variations. But that could be considered the price that has to be paid for wide cross-browser support at present.