I used this font face and it works fine:
#font-face {
font-family: IRANSansWebLight;
src: url(fonts/IRANSansWeb_Light.ttf) format("truetype")
}
But when I try to use the same font which is converted to woff it doesn't work:
#font-face {
font-family: IRANSansWebLight;
src: url(fonts/iransansweb_light-webfont.woff) format("woff");
}
What I'm missing?
As I don't know about your folder structure, I would suggest you to change the URL of the font to:
url(../fonts/iransansweb_light-webfont.woff)
If that doesn't fix your problem, you should try to use Google Font Helper. Search for your desired font and follow the instructions. Here's a link to it.
Related
i want to add a custom font to my html page, but it does not work, i tried everything possible, checked other questions, trying to solve it their way, but nothing.
the font is in the same folder as my html file(the css is in the html file)
In html css i wrote:
#font-face {
font-family: regular;
src: url("8bitoperator_jve.ttf");
//src: local("8bitoperator_jve.ttf"); i tried this too
}
body {
background-color: #000;
color: #FFF;
font-family: regular;
}
The src attribute of #font-face specifies the resource containing the font data. This can be:
url: a URL to a remote font file location;
local: the name of a font on the user's computer.
In your case, you are passing a URL to local. Instead, you should use url:
#font-face {
src: url('8bitoperator_jve.ttf');
}
If you want, you can also use both. But remember to give precedence to local, i.e.:
#font-face {
src: local('Name of your font here'), url('8bitoperator_jve.ttf');
}
You should find a specific font in local, but a font file in url. I mean, the local font doesn't need any path or file extension whereas a font file need it. If you want to target a local files first you can try like that:
#font-face {
font-family: regular;
src: local("8bitoperator_jve"),url("8bitoperator_jve.ttf") format('truetype');
}
Also you can try loading the font-face from an external CSS file.
I have recently been trying to embed font to my website. I don't get it to work, i have watched and read tutorials. I wan't to embed a font called "Ubuntu Light" in ttf format. This is what i have been trying:
#logBtn{
font-family: 'UbuntuLight';
}
#font-face{
font-family: "UbuntuLight";
src: url("CSS/Ubuntu-L.ttf");
}
And the file in the folder: Treeview of project
I'm almost new to this, i've been coding HTML and CSS in maybe 4 months now.
I have been stuck at this before, and that made me cancel my project, because i gave up. But i don't want to give up again. So i would really appreciate some help! :)
You can embed a font quick and easy by using this code:
#font-face {
font-family: 'Name';
src: url('Font.ext');
font-weight: 400;
font-style: normal;
}
Where Font.ext should be replaced with your font file and its extention (file type) e.g.
src: url('Ubuntu-L.ttf');
And the following font-weight and font-style should be referencing the specific font choice.
The url(...) path is relative to the stylesheet.
Therefore, because your stylesheet is in the CSS folder you don't need to include that in the url:
#font-face{
font-family: "UbuntuLight";
src: url("Ubuntu-L.ttf");
}
I have a font file in font directory of my project and use it to css file,in my system working true but not working in the client system.how to use it that correct result ?
my font-face in css is :
#font-face {
font-family: 'Yekan';
src: url('font/Yekan.eot');
src: url('Font/Yekan.woff');
src: url('Font/Yekan.eot?#iefix') format('embedded-opentype'), url('font/Yekan.ttf'), url('font/Yekan.svg');
font-weight: bold;
}
My font path is :
You can also try creating a web font
https://www.web-font-generator.com/
Try to remove all the ' ' from the css.
This should work for you.
I am trying to add a local font to a site I am testing. It is called "AcrosstheRoad.ttf" and can be found in my assets/fonts/ folder. I am doing the following to try to read it into the CSS file:
#font-face {
font-family: 'AcrosstheRoad';
src: url('assets/fonts/AcrosstheRoad.ttf') format('truetype');
}
And I want to use it as a certain header type so I am using
h3{
font-family: 'AcrosstheRoad';
color: #333;
}
But unfortunately the font is not loading in. Does anyone know what I'm doing wrong?
Thanks!
Christina
First add a slash before assets:
(('/assets/fonts/AcrosstheRoad.ttf'))
That may or may not be the problem, depending on where your CSS file is, and how your website is structured.
If the above doesn't work, convert the font to .woff2 and .woff (try using this: http://www.fontsquirrel.com/tools/webfont-generator). The reasoning behind this is that some browsers are really picky. Change your CSS to:
#font-face {
font-family: 'AcrosstheRoad';
src: url('/assets/fonts/AcrosstheRoad.woff2') format('woff2'),
url('/assets/fonts/AcrosstheRoad.woff') format('woff');,
url('/assets/fonts/AcrosstheRoad.ttf') format('truetype');
}
I am trying to load a custom font in my website. In my style.css I have the following attributes declared
#font-face {
font-family: billabong;
src: url('./fonts/billabong.ttf');
font-weight: bold;
}
h1.header {
font-family: billabong;
}
And in my html I have the following code;
<h1 class="header">Welcome to</h1>
However, it seems to be defaulting to some other font type so i assume it cannot find it.
The font is back one directory from my css file, and inside a folder called fonts, have i provided the correct path for it to find it? If this is not the issue does anyone know what I am doing wrong?
try adding Apostrophes in the font-family attribute.
font-family: 'billabong';
Also use more formats. not all browsers support ttf.
read more about that here:http://socialcompare.com/en/comparison/browser-fonts-support-comparison
You could export ttf to webfont here: http://www.font2web.com/
I think the only problem here is your directory.
Try first putting your font file all the way up to the same directory as your html file.
Then try this code:
#font-face {
font-family: billabong;
src: url(billabong.ttf);
font-weight: bold;
}
h1.header {
font-family: billabong;
}
If this doesn't work try putting your font-weight:bold; into the header class see if that helps.
If it works then put it back to where you had it. I hate to guess but as i understand you have a fonts file inside your css file. I am assuming that your html file is one directory higher than your css file. In that case you can say
#font-face {
font-family: billabong;
src: url(css/fonts/billabong.ttf);
font-weight: bold;
}
h1.header {
font-family: billabong;
}
You don't need to use apostrophes for your attribute or source url i have made many websites using custom fonts and haven't seen a problem with compatibility and such.
In any case i would always refer to the w3schools website they explain it the best way:
http://www.w3schools.com/cssref/css3_pr_font-face_rule.asp
Hopefully that helps.