Using #font-face problems - css

I'm having a little trouble with using #font-face which really confuses me. I think I'm doing right or not.
So I made the declaration
#font-face{
font-family: Art Post black;
src: url('/fonts/ArtPostblack.ttf');
}
#font-face{
font-family: SimplyDelicious;
src: url('/fonts/SimplyDeliciousFont3.ttf');
}
Then made the calls
#blah{font-family:Art Post black; } #blah2{font-family:SimplyDelicious;}
Now problem is Art Post black works but SimplyDelicious doesn't work
Also when I remove Art Post black font. it doesn't change meaning the custom font is still not removed. So... I'm confused, am I doing it right? well I guess not.

Your syntax is right, but it is very basic. First, use this recommended #font-face syntax:
#font-face {
font-family: 'MyFontFamily';
src: url('myfont-webfont.eot?#iefix') format('embedded-opentype'),
url('myfont-webfont.woff') format('woff'),
url('myfont-webfont.ttf') format('truetype'),
url('myfont-webfont.svg#svgFontName') format('svg');
}
UPDATE: You need "" around the font name in both the #font-face syntax and in your css selection if the font name has spaces in it. It won't select correctly if you don't have the single or double quotes as your code shows. That's likely your problem. Use this new bulletproof syntax though too to make it more cross-browser.
source: http://www.fontspring.com/blog/the-new-bulletproof-font-face-syntax
Then make sure your links are correct. keep in mind, use a / at the beginning of your URL directs the browser to the root directory of your domain. So paste that into your address bar after the domain name and see if it downloads the font file, if so, your links are correct.

This way of calling different font may help :
#font-face {
font-family: 'myriadproregular';
src: local('myriadproregular'), url('myriadproregular.ttf') format("truetype");
}
#font-face {
font-family: 'myriadprocond';
src: local('myriadprocond'), url('myriadprocond.ttf') format("truetype");
}
#font-face {
font-family: 'myriadprosemibold';
src: local('myriadprosemibold'), url('myriadprosemibold.ttf') format("truetype");
}
and in your case
#font-face{
font-family: Art Post black; (why this font name have space? it was supposed to be like ArtPostblack )
src: url('/fonts/ArtPostblack.ttf');
}
#font-face{
font-family: SimplyDelicious;
src: url('/fonts/SimplyDeliciousFont3.ttf');
}
and make sure they are near to css files and proper path.

Related

SASS - font face not working with right path

I recently started using SASS and I want to import 2 fonts, Montserrat and Open Sans. Normally in CSS, you do something along the lines of
#font-face {
font-family: 'Montserrat'
src: url('../../webfonts/Montserrat.ttf');
}
And it works just fine. If my file structure looks like the following
CSS
Base
typography.sass
Webfonts
Montserrat.ttf
But I put the following code in my SASS file.
#font-face
font-family: 'Montserrat'
src: url("../../webfonts/Montserrat.ttf")
#font-face
font-family: 'Open Sans'
src: url("../../webfonts/OpenSans.ttf")
src: url("../../webfonts/OpenSans.ttf?iefix") format("embedded-opentype")
But the font's don't load. I tried similar question on this topic but none of them were succesfull for me. What could this problem be?
If your folder name is Webfonts and you reference it with url("../../webfonts/..., then you have your answer there (lowercase vs. uppercase w/W).
Also, your code example results in a double src attribute. I don't know if it is related to the problem.
#font-face
font-family: 'Open Sans'
src: url("../../webfonts/OpenSans.ttf")
src: url("../../webfonts/OpenSans.ttf?iefix") format("embedded-opentype")
The code above compiles to this, where the src overwrites itself for each time:
#font-face {
font-family: "Open Sans";
src: url("../../webfonts/OpenSans.ttf");
src: url("../../webfonts/OpenSans.ttf?iefix") format("embedded-opentype");
}
The src attribute should only be set once, but with multiple values instead. I think this will work in Sass:
#font-face
font-family: 'Open Sans'
src: url("../../webfonts/OpenSans.ttf"), url("../../webfonts/OpenSans.ttf?iefix") format("embedded-opentype")

Custom font on Wordpress not working

I'm trying to figure out why my custom font is not loading on WordPress (MAMP, Mac, localhost).
The fonts are stored in wp-content/themes/twentysixteen/fonts/
Then in wp-content/themes/twentysixteen/style.css I have the following CSS:
#font-face {
font-family: "Averta-Regular";
src: font-url("./fonts/31907B_A_0.eot");
src: font-url("./fonts/31907B_A_0.eot?#iefix") format('embedded-opentype'), font-url("./fonts/31907B_A_0.woff2") format('woff2'), font-url("./fonts/31907B_A_0.woff") format('woff'), font-url("./fonts/31907B_A_0.ttf") format('truetype');
}
html {
font-family: "Averta-Regular", "Helvetica Neue", sans-serif;
-webkit-text-size-adjust: 100%;
-ms-text-size-adjust: 100%;
}
body {
margin: 0;
font-family: "Averta-Regular", "Helvetica Neue", sans-serif;
}
Chrome shows me this:
It only works if I have the font installed on my operating system.
Try changing font-url to url on lines 3 and 4 of your CSS. It looks like it just isn't recognizing the source of the custom fonts you're trying to load.
You have to link that font in functions.php
Like this
wp_enqueue_style( 'custom', get_template_directory_uri() . 'https://fonts.googleapis.com/css?family=Roboto' );
Download a ttf font, one available for commercial use, visit https://1001fonts.com/free-fonts-for-commercial-use.html?page=1&items=10 paste a copy into your theme and use #font-face just as you've done above. Everything should work just fine. While I was developing on my local server, everything was working fine. On publishing into public_html, the font refused to load. Had to change to a ttf, you can also try other web fonts format but the ttf works just fine. Better still you can use the google fonts.
I encountered something similar when I was using this wordpress uncode child theme and uploading custom fonts.
I realised it was because I didn't end the second src attribute with a ;
#font-face{
font-family: 'Lato';
src: url('fonts/Lato.eot');
src: url('fonts/Lato.eot?#iefix') format('embedded-opentype'),
url('fonts/Lato.woff') format('woff'),
url('fonts/Lato.ttf') format('truetype'),
url('fonts/Lato.otf') format('opentype'),
}
Once I replaced it, the fonts worked. Stupid mistake but hard to spot after you work for a couple of hours.
#font-face{
font-family: 'Lato';
src: url('fonts/Lato.eot');
src: url('fonts/Lato.eot?#iefix') format('embedded-opentype'),
url('fonts/Lato.woff') format('woff'),
url('fonts/Lato.ttf') format('truetype'),
url('fonts/Lato.otf') format('opentype');
}

External font not loading correctly CSS

My CSS custom font doesn't load onto the page when you load my website. At least, not until you click "home" or one of the other tabs. Anyone have any idea why this is and how to fix it? I used
#font-face {
font-family: OpenSansLight;
src: url(OpenSans-CondLight.ttf);
}
#font-face {
font-family: OpenBold;
src: url(OpenSans-CondBold.ttf);
}
#font-face {
font-family: OpenRegular;
src: url(OpenSans-Regular.ttf);
}
And
body, html{
background-color: #FFF;
margin:0;
padding:0;
height: 100%;
width:100%;
font-family:"OpenSansLight";
}
The font doesn't load until I click a link within my website. Anyone have any idea why?
EDIT: Still trying to resolve this... No dice so far.
Second edit: People keep telling me to check if the font is in the right place. IT IS. And everything works. But not upon loading the page, for some unknown reason. hence my question. Please don't answer if you don't even read my question.
Third edit: Another few hours of fiddling have not resolved the issue. I tried expanding the support of the fonts by using
#font-face {
font-family: 'OpenRegular';
src: url('opensans-regular-webfont.eot');
src: url('opensans-regular-webfont.eot?#iefix') format('embedded-opentype'),
url('opensans-regular-webfont.woff2') format('woff2'),
url('opensans-regular-webfont.woff') format('woff'),
url('opensans-regular-webfont.ttf') format('truetype'),
url('opensans-regular-webfont.svg#open_sansregular') format('svg');
font-weight: normal;
font-style: normal;
}
But still, the same thing happens.
Noteworthy: Firebug greys out the font when inspecting it when it's not showing, but turns blue and kicks in when I click home or one of the other tabs and the font works.
Fourth edit: A few more days have passed and I'm still struggling with this problem. It's driving me insane. Please help me. I've tried every single possibility on W3C, Google results, Stack Overflow and every suggestion, yet nothing works for me. I'm sure my code is correct but it just won't load on the first try no matter what I try.
Make sure that the CSS file and the font files are in the same directory, if not either put them in the same directory or amend the CSS to have the correct path to the files
#font-face {
font-family: OpenSansLight;
src: url(path/to/OpenSans-CondLight.ttf);
}
#font-face {
font-family: OpenBold;
src: url(path/to/OpenSans-CondBold.ttf);
}
#font-face {
font-family: OpenRegular;
src: url(path/to/OpenSans-Regular.ttf);
}

Add a bought font file to my WebStorm project using SASS. Angular Project

I want to know what am i missing here?
I have the following definition in my SASS file:
#font-face
font-family: "NHaasGroteskDSPro"
src: url("fonts/NHaasGroteskDSPro-95Blk.otf") format("otf")
h1.ir-page-header
font-family: "NHaasGroteskDSPro"
font-weight: 800
font-size: 30px
And the relevant HTML element is:
<h1 class="ir-page-header">some text</h1>
The developer tool shows that the element has the required class and its not override by other css styles.
Sadly the font showed is not the font wanted.
here is a link to the font page on fonts.com:
http://www.fonts.com/font/linotype/neue-haas-grotesk/display-family-pack
I thought it will be easy to find the answer online but after spending 2 hours on a 10 min task i decided to post my question for future generations :-)
Well i changed the #font-face to be:
#font-face
font-family: "Neue Haas Grotesk"
font-weight: 800
font-style: normal
src: url("fonts/NHaasGroteskDSPro-95Blk.otf") format("opentype")
And it solved the problem.
Better solution will be using webfonts. You need different font formats to support different browsers and achieve smallest file size. In a case of paid font, please see http://www.fonts.com/web-fonts.
CSS Webfont declaration looks like this:
#font-face {
font-family: 'FontName';
src: url('/fonts/font-webfont.eot');
src: url('/fonts/font-webfont.eot?#iefix') format('embedded-opentype'),
url('/fonts/font-webfont.woff2') format('woff2'),
url('/fonts/font-webfont.woff') format('woff'),
url('/fonts/font-webfont.ttf') format('truetype'),
url('/fonts/font-webfont.svg#FontName') format('svg');
font-weight: normal;
font-style: normal;
}

css and php displaying fonts from folder

i understand its a bit rude to ask a question from scratch however i have done my research and tried a few examples with no sucess.
im trying to display a font from my local servers.
ex. DigitaldreamNarrow.ttf
which is located in :
css/fonts/DigitaldreamNarrow.ttf
i have tried placing it in my css file in the following manner:
#font-face {
font-family: DigitaldreamNarrow;
src: url(‘css/fonts/DigitaldreamNarrow.ttf’);
}
.top {
font-family: DigitaldreamNarrow;
font-size: 0.2%;
}
however at this point im lost and i dont see any results in my display.
help?
Deploying fonts via CSS is generally unsupported. Take a look at Cufon.
#font-face {
font-family: 'ArvoRegular';
src: url('Arvo-Regular-webfont.eot');
src: local('☺'), url('Arvo-Regular-webfont.woff') format('woff'), url('Arvo-Regular-webfont.ttf') format('truetype'), url('Arvo-Regular-webfont.svg#webfontau9vOdrl') format('svg');
font-weight: normal;
font-style: normal;
}
You're going to have different results from different browsers (not all browsers support/use 'eot' for example). Check out font squirrel, and download an #face kit. Very helpful resource. http://www.fontsquirrel.com/fontface
This is more than likely the direction fonts will take, and Cufon will likely become "Gif Builder"...IMO.
#trey, write this
#font-face {
font-family: 'DigitaldreamNarrow';
src: url(‘../css/fonts/DigitaldreamNarrow.ttf’);
}
may there is a problem with your url please it.
May be you have to add inverted comma to the font .

Resources