Can't use Google's fonts properly - css

So I've been trying to import Google's fonts and integrate them into a website without success.
The CSS:
#import url(http://fonts.googleapis.com/css?family=Linden+Hill);
/*...*/
body.single-post p, body.page p{
font-family: 'Linden Hill', sans-serif;
}
For some reason, when I try to use the font, in both Firefox and Google Chrome, it doesn't load/show the font, with or without quotation marks wrapped around the font name.
Google Fonts's website says that to include the font, you do this:
font-family: 'Linden Hill', serif;
...but it doesn't work.
Now, for a different font, Tangerine (note that it's one word), it works if I include it without quotation marks, like so
#import url(http://fonts.googleapis.com/css?family=Tangerine);
/*...*/
body.single-post p, body.page p{
font-family: Tangerine, sans-serif;
}
...but if you do what Google Fonts tells you, and wrap it in single quotes, it magically stops working.
This is what it looks like in the inspector:
Am I doing something wrong?

It turns out that I had the #import after a #font-face definition.
/*some other #imports*/
#font-face {/*font face here*/}
#import url(/*the font URL here*/)
Moving it before the #font-face definition fixes the issue.

That should work with double quote:
font-family: "Linden Hill", serif;

yes you are doing wrong in css here (body.single-post p, body.page p),
see here if you are using directly like this.
body{
font-family: 'Linden Hill', sans-serif ;
}
you need to write css tree
try this may it work
body .single-post p, body .page p{
font-family: 'Linden Hill', sans-serif;
}
or if you can, show me the the code where you want to use it
its working fine the quotation make is not problem

Related

fontlibrary.org fonts, Print Preview, and strong/em not rendering as bold/italic

I'm trying to use fontlibrary.org to load fonts to produce documents as PDF. I currently use these same fonts on web sites and everything works as expected; however, when I try to print a document with these fonts, strong does not render bold and em does not render as italic. To work around this problem, I have to do this (this is already sass, so you can imagine the corresponding CSS):
body {
font-family: "HkGroteskRegular", sans-serif;
strong {
font-family: "HankenGroteskBold", sans-serif;
font-weight: bold;
}
em {
font-family: "HankenGroteskItalic", sans-serif;
font-style: italic;
}
}
h1, h2, h3, h4, h5, h6 {
font-family: "NormungRegular", serif;
strong {
font-family: "NormungBold", serif;
font-weight: bold;
}
em {
font-family: "NormungItalic", serif;
font-style: italic;
}
}
code, pre {
font-family: 'FantasqueSansMonoRegular', monospace;
strong {
font-family: "FantasqueSansMonoBold", monospace;
font-weight: bold;
}
em {
font-family: "FantasqueSansMonoItalic", monospace;
font-style: italic;
}
}
So that leaves me with a few questions:
How does this work at all on the web? How does the browser load the bold font for bold, the italic font for italics, and so on? Evidently, the browser simulates font variants for bold and italic, so it doesn't use the imported font variants.
Since this doesn't work for print, who's broken? Does fontlibrary.org serve the fonts incorrectly and the browser (and wkhtmltopdf) can't find them? Do both the browser and wkhtmltopdf load the font files incorrectly?
If fontlibrary.org is broken Since fontlibrary.org seems to use a font variant naming scheme that doesn't match what the rest of the world seems to except, then whom can I trust to serve these #font-face rules correctly? Do I have to write them myself to be sure?
Is there anything I can do to make this work better?
UPDATE: 2018-10-14. I have noticed that when I download the fonts so that they can be found locally, everything works. I suspect that this happens because the locally-installed font names follow a naming convention for the font variants that allows the browser, Print Preview, and pandoc to find them. I would really appreciate it if a few people would confirm that the naming convention solves the problem. In that case, I could tweak the #font-face rules to load the fonts from fontlibrary.org so that I don't need to install the fonts locally.
I believe that this is a result of how Fontlibrary shares their fonts. If you look at the file https://fontlibrary.org/face/hk-grotesk (which is the link containing the font face css) at the very bottom you will see a section marked "The following rules are deprecated."
If you use the font names from that section (i.e. "Hanken Grotesk") and not the special names (like "HankenGroteskBold"), then web browsers seem to find the correct bold & italic forms. It's only using these special names that I find trouble (in my case with the Libertinus fonts).
Unfortunately, as these names are marked "deprecated", I don't know how long they will stay working. Nor, do I know why Fontlibrary setup this naming convention, which makes it more difficult to use the fonts than is necessary (in my opinion).

CSS - renaming fonts

A fellow programmer has built a page with webfonts, but didn't provide any fallbacks in the font-family rules for where they added this to the appropriate html elements.
for example:
#someDiv { font-family: "my font"; }
In some special cases, we're not loading the webfont, and it looks pretty ugly. The font should fall back on Arial.
Instead of going over the CSS line-by-line and fix this, is there a way to add a font-face rule or something similar so that "my font" will show Arial?
Found the answer:
#font-face {
font-family: "my font";
src: local("Arial");
}
Add your fallbacks to the current font-family chain.
#someDiv { font-family: "my font", Arial, sans-serif; }

CSS3 font-face … how to make font-style:italic to use the actual italic version?

I have two embedded fonts - a regular and a "real" italic version …
#font-face {font-family: 'MyFont-Regular';src: url('wf/2061CF_2_0.eot');src: url('wf/2061CF_2_0.eot?#iefix') format('embedded-opentype'),url('wf/2061CF_2_0.woff') format('woff'),url('wf/2061CF_2_0.ttf') format('truetype');}
#font-face {font-family: 'MyFont-RegularItalic';src: url('wf/2061CF_6_0.eot');src: url('wf/2061CF_6_0.eot?#iefix') format('embedded-opentype'),url('wf/2061CF_6_0.woff') format('woff'),url('wf/2061CF_6_0.ttf') format('truetype'); font-style:italic, oblique;}
I'm using the italic version on a few classes … 
.MyFont-RegularItalic, .italic, em { font-family: MyFont-RegularItalic; }
I'm applying MyFont-Regular on my body and I have an element div.example where I want the text to be italic.
In order to achieve this I would have to apply this …
div.example {
font-family:MyFont-RegularItalic;
}
This works of course fine. However, since I'm already applying the "regular" version of the font to my body I wonder if I can somehow make font-style:italic; work for this as well. So I don't want to apply the entire font-family again but simply declare it as italic.
div.example {
font-style:italic;
}
This doesn't work and leads to a browser-slanted italic version of the "regular" font - the real "italic" fontface is not used in this case.
Any ideas or tricks if it is possible to make my stylesheet automatically use the "real" italic version of the font when I apply font-style:italc to an element.
Thank you in advance,
Matt
update:
Add the style to the font declaration.
#font-face {
font-family:"MyFont";
src:url("myfont.ttf");
}
#font-face {
font-family:"MyFont";
src:url("myfont-italic.ttf");
font-style:italic;
}

#font-face not recognized

Ok I have my site up so far but the two fonts I used are not showing up. I transferred the fonts and put them in the same folder as my webpages. I also used #font-face in css (styless.css). I'm not sure where I went wrong.
Website: http://envycosmetics.zxq.net/TestSite/webpages/index.html
I'm looking at styless.css, and I can't see where you used #font-face. Make sure you do it like this:
#font-face { font-family: FontName; src: url('path/to/font.otf'); }
Then call it like this:
#navBar { font-family: FontName, sans-serif; }
Also, don't forget to call another font for browsers that don't support #font-face, as shown in #navBar values.
I also used #font-face in css (styless.css)
No... no, you didn't.

#font-face problem with font-weight in Safari

I just started using #font-face
This is on top of my css
#font-face {
font-family: Avenir;
src: url(../fonts/AvenirLTStd-Medium.otf);
}
body{
font-family:"Avenir",Helvetica;
background:#fff url(../images/main_bg.png) repeat-x scroll 0 0;
color:#321244;
}
and i have this below for a menu on joomla
#menu_bottom ul li a {
font-size:12px;
font-weight:600;
letter-spacing:-0.6px;
text-transform:uppercase;
this is on the html file
<li class="item23"><span>Menu Item</span></li>
This works in Firefox, but it is not working correctly on Safari or Chrome, the font is correct but the font-weight is not working, i checked on google-chrome developer tool and the computed font weight is 600.
I have tried using 100 or 900 the results on safari and chrome are the same, the font weight wont change.
Is there something wrong with my font-face declaration on top of my css file?
should i try adding something like this
#font-face {
font-family: Avenir;
src: url(../fonts/AvenirLTStd-Heavy.otf);
font-style: bold;
}
I tried but didnt work.
Should i add another font this are that i have on my font directory
AJensonPro-BoldIt.otf AvenirLTStd-BookOblique.otf
AJensonPro-Bold.otf AvenirLTStd-Book.otf
AJensonPro-It.otf AvenirLTStd-HeavyOblique.otf
AJensonPro-LtIt.otf AvenirLTStd-Heavy.otf
AJensonPro-Lt.otf AvenirLTStd-LightOblique.otf
AJensonPro-Regular.otf AvenirLTStd-Light.otf
AJensonPro-SemiboldIt.otf AvenirLTStd-MediumOblique.otf
AJensonPro-Semibold.otf AvenirLTStd-Medium.otf
AvenirLTStd-BlackOblique.otf AvenirLTStd-Oblique.otf
AvenirLTStd-Black.otf AvenirLTStd-Roman.otf
Or should i try another font format, something that is not otf, in IE seems to be working althought the width is bigger. I still need to fix that.
As explained here, you have to add
font-weight: normal;
font-style: normal;
inside the #font-face declaration and then use the font-weight:600; on your anchor.
Specifying a numerical value for font-weight is something you do at your peril. Different browsers interpret the values differently, and some don't interpret it as anything at all. You are best going with the standard "bold" ... which browsers get closest to matching in some semi-uniform way. Also, if you are using custom typefaces you should be certain your users have them on their systems. Also, some custom fonts don't respond well to the faux "bold" property. They will have a named "bold" face, like Avenir Bold, Avenir Black, Avenir Demibold, Avenir Demibold Condensed, etc., etc., etc.
Also, always include enough fallback fonts, including, at last, the "serif" or "sans-serif" or "monospace" general font specifier.
Better late than never. Hope this helps:
html { -webkit-font-smoothing: antialiased; }

Resources