font-family of a font, what is it? - css

I'm trying to find the CSS font-family name of the Helvetica Neue LT Std 97 Black Condensed font located here: http://fontscore.com/fonts/Helvetica-Neue-LT-Std-97-Black-Condensed_22554.html
I'm using #font-face to load the font onto the webpage, if not already on the users computer, however, I would like to be able to load the font, if found on the users computer first. I've tried several methods here, but none of these work:
font-family: HelveticaNeueLT Std Blk Cn
font-family: HelveticaNeueLT Std ExtBlk Cn
What is the name of this font that I should use when calling font-family? I probably have to put 97 somewhere in there also, but nothing works, have tried a ton of different ways to call it.
Here's what I'm using in the CSS:
#font-face {
font-family: hnc_font;
src: local('HelveticaNeueLT Std Blk Cn'), local('HelveticaNeueLTStd-BlkCn'), url('../fonts/hnc.otf') format('opentype'), url('../fonts/hnc.woff') format('woff'), url('../fonts/hnc.ttf') format('truetype'), url('../fonts/hnc.svg') format('svg');
font-weight: normal;
}
#font-face{
font-family: MyFont_IE;
src: url('../fonts/swiss_bc.eot');
}
.big_text
{
padding-top: .4em;
font-size: 5.5em;
font-family: HelveticaNeueLT Std Blk Cn, HelveticaNeueLTStd-BlkCn, hnc_font, MyFont_IE;
}

First of all try all your combinations by wrapping the name of the font in " quotes.
For example font-family: "Helvetica Neue LT Std 97 Black Condensed"
Then, the name that you call is defined by your #font-face declaration before the font-family. You can call it what ever you want.
For example if you first declare it like this
#font-face{
font-family: "MY_FONT_NAME";
src: url('PATH_TO/FONT_FILENAME.ttf');
}
you can later refer to it like this
font-family: "MY_FONT_NAME";
Edit based on the added CSS
try this
.big_text
{
padding-top: .4em;
font-size: 5.5em;
font-family: "HelveticaNeueLT Std Blk Cn", "HelveticaNeueLTStd-BlkCn", "hnc_font", "MyFont_IE";
}

Cheat with some javascript: http://jsfiddle.net/ucd2L/
var x = $("#test").css('font-family');
$("#test").append(x);
HTML
<p id="test">Text</p>

When using #font-face, there are two separate questions about font names.
The name you use in font-family declaration inside an #font-face rule is up to you, as long as it is a syntactically valid font name and you use that very same name in font-family declarations in normal CSS rules. So it can be font-family: foobar.
The name you use in the local(...) constructor when setting src in an #font-family rule must match the name under which the font is known in the system. It should be name you would use to get a local font in a font-family rule without any #font-face, and in principle it should be the PostScript name or the full name of the font, though browsers may accept other names too; see
css - machine specific font-family.

Related

font-family browser selection

I'm trying to set the browser to use the Quicksand font which I am pulling directly from a file in the same folder. When I format the code as follows the browser uses the Quicksand font:
#charset "utf-8";
#font-face {
font-family: Quicksand;
src: url('Quicksand-Regular.woff') format ('woff'),
url('Quicksand-Regular.tff') format('truetype');
}
h1, h2 {
font-family: Quicksand;
}
When I add more options for the font-family the browser defaults to the sans-serif font rather than using the Quicksand font.
#charset "utf-8";
#font-face {
font-family: Quicksand;
src: url('Quicksand-Regular.woff') format ('woff'),
url('Quicksand-Regular.tff') format('truetype');
}
h1, h2 {
font-family: Quicksand, sans-serif;
}
I'm trying to get the browser to default to Quicksand font with sans-serif as backup for an assignment and I can't figure out what exactly I'm doing wrong in the above code.
The font family of a text is set with the font-family property.
The font-family property should hold several font names as a "fallback" system. If the browser does not support the first font, it tries the next font, and so on.
Start with the font you want, and end with a generic family, to let the browser pick a similar font in the generic family if no other fonts are available.
Note: If the name of a font family is more than one word, it must be in quotation marks, like "Times New Roman".
More than one font family is specified in a comma-separated list:
p {
font-family: "Quicksand", sans-serif;
}

Cost of font-family vs font-weight

I've inherited a code project wherein the fonts are not set up in the most sensible way. The site uses a few weights of the Proxima Nova font.
Instead of binding these font files to the same font family (i.e. font-family: "Proxima Nova"), a new font-family is created for each weight of the Proxima Nova font.
In practice, what this means is that in order to change the font weight, you write font-family: "Proxima Nova Bold" instead of font-weight: 700.
I am curious to know if this has consequences other than the obvious legibility problems. The more technical the answer, the better.
EDIT:
Here is an example to illustrate what my preferred method is, in case there's something wrong with how I do things:
#font-face {
font-family: 'Ubuntu';
src: url('Ubuntu-RI-webfont.eot');
src: url('Ubuntu-RI-webfont.eot?#iefix') format('embedded-opentype'),
url('Ubuntu-RI-webfont.woff') format('woff'),
url('Ubuntu-RI-webfont.ttf') format('truetype'),
url('Ubuntu-RI-webfont.svg#UbuntuItalic') format('svg');
font-weight: normal;
font-style: italic;
}
#font-face {
font-family: 'Ubuntu';
src: url('Ubuntu-B-webfont.eot');
src: url('Ubuntu-B-webfont.eot?#iefix') format('embedded-opentype'),
url('Ubuntu-B-webfont.woff') format('woff'),
url('Ubuntu-B-webfont.ttf') format('truetype'),
url('Ubuntu-B-webfont.svg#UbuntuBold') format('svg');
font-weight: 700;
font-style: normal;
}
Another example: #font-face: Only using one font-family with different font-weights?
Short answer: no.
The properties you specify in a #font-face rule are used to resolve "the font-... values tuple" to "the actual font resource on the network indicated by src", so whether you declare your font as:
#font-face {
/* identifying font-... values: 1 */
font-family: SillyBoldItalicSmallcaps;
/* font resource to use when values match: */
src: url(./font-bold-italic-SC.woff) format("WOFF");
}
and then resolve it with some document CSS using:
.rulename {
/* values to use to find a specific font resource: 1 */
font-family: SillyBoldItalicSmallcaps;
}
(where the tuple {font-family} is matched against the declared tuple) or whether you declare your font as:
#font-face {
/* identifying font-... values: 4 */
font-family: MyFont;
font-weight: bold;
font-style: italic;
font-variant: smallcaps;
/* font resource to use when values match: */
src: url(./font-bold-italic-SC.woff) format("WOFF");
}
and then resolve it with some document CSS using:
.rulename {
/* values to use to find a specific font resource: 4 */
font-family: MyFont;
font-weight: bold;
font-style: italic;
font-variant: smallcaps;
}
(where the tuple {font-family,font-weight,font-style,font-variant} is matched against the declared tuple) there is no difference in the actual resource found by the CSS engine based on the font-... values you provided. Both end up finding the ./font-bold-italic-sc.WOFF font for styling the text: the core mechanic is the same in both cases, in that we "resolve a font-... values tuple to the declared resource that matches that values tuple". The important thing to note is that in both cases the tuples are unique. In the first case because the font-family is a uniquely identifying string, in the second case because while the font-family may no longer be uniquely identifying, the additional property values yield a unique combination that can resolve to a single font resource.
The only real difference is that the latter makes life considerably easier when it comes to development and maintenance (the end result is identical as far as the consuming client is concerned). And ease translates directly into improved efficient, better code, lower cost, and a whole slew of things that all translate into "we should be doing it this way".
It is often a result of the actual font file encoding and not related to any usage. Some font vendors do not package their fonts into one nice, easy family. But instead the foundry itself splits each weight into a new file. (I dislike this, but it's not really that uncommon.)
I believe that Proxima Nova is one such font -- where each weight is a separate file and not part of one "family" file.

Custom fonts not being loaded in CSS

I have an index.html that links to a main.css. Per one of the answers to a SO question about using custom fonts, I have loaded my custom font as such by saving the file FoundrySterling-Medium.otf in the appropriate folder, and then calling it as such:
#font-face{
font-family: "FoundrySterling";
src: "assets/fonts/FoundrySterling-Medium.otf",
}
later on, for the body element, I set it up as such:
body, input, select, textarea {
color: #fff;
font-family: 'FoundrySterling', sans-serif;
font-size: 15pt;
font-weight: 400;
letter-spacing: 0.075em;
line-height: 1.65em;
}
However, no matter what, the font will not show, and instead the default Helvetica or Arial (depending Mac or PC) is used instead. What am I missing?
Thanks!
This is your original code:
#font-face{
font-family: "FoundrySterling";
src: "assets/fonts/FoundrySterling-Medium.otf",
}
Why are you not using a semi-colon at the end? Not sure if intentional.
#font-face{
font-family: "FoundrySterling";
src: url("assets/fonts/FoundrySterling-Medium.otf");
}
try changiing
src: "assets/fonts/FoundrySterling-Medium.otf",
to
src: url('http://domain.com/fonts/font.ttf'); /*URL to font*/
I hope it would help you.
Note that certain font-formats don't work on all browsers; you can use fontsquirrel.com's generator to avoid too much effort converting.
You can find a nice set of free web-fonts provided by Google Fonts (also has auto-generated CSS #font-face rules, so you don't have to write your own).
Change your code to use the url(...) syntax:
Swap:
src: "assets/fonts/FoundrySterling-Medium.otf"
With:
src : url('assets/fonts/FoundrySterling-Medium.otf');

Adding fallback fonts to the #font-face definition

Is it possible to add a fallback font directly to the definition of the font-face?
Example:
#font-face {
font-family: 'MyWebFont', Arial, Helvetica, sans-serif;
src: url('fonts/MyWebFont.eot');
src: url('fonts/MyWebFont.eot?#iefix') format('embedded-opentype'),
url('fonts/MyWebFont.woff') format('woff');
font-weight: normal;
font-style: normal;
}
And then using it as font-family value with automatic fallback, like so:
p {
font-family: MyWebFont;
}
My goal is not to having to define the fallback fonts everywhere I define a new font-family. If not like above, can I somehow achieve this without JavaScript? Thanks for your help!
No, you cannot specify any fallback fonts inside a #font-face rule, because such a rule defines a font face and assigns a name to it. Inside the rule, the font-family part can contain only one name, the name you choose to assign. It would be pointless list several names there, since only the first one can possibly matter (and, besides, in this context no name has any predefined meaning, e.g. Arial would not mean the Arial font but be just an arbitrary assigned name).
Fallback fonts can be specified only in normal font-family rules.
Consider organizing your style sheet so that the relevant font-family list appears only once, using a suitable list of selectors, like
p, blockquote, .foobar, .something {
font-family: MyWebFont, Arial, Helvetica, sans-serif;
}
You can totally add fallback fonts to a #font-face rule!* You don't add them to the font-family descriptor (that's for giving your font family a name); you add them to the src descriptor, which accepts multiple values. If the browser can't find (or doesn't support) the first font, it will try loading the next one, and so on. You can have it look for fonts installed on the user's system using the local() function:
#font-face {
font-family: bodytext;
src: url(fonts/MyWebFont.woff) format("woff"),
local(Arial),
local(Helvetica);
}
Some people may argue that url() and local() weren't designed to be used this way. Typically, they're used to provide local and remote versions of the same font, with the web-font functioning as a fallback if the local font can't be found. Here's such an example from the W3C specs:
#font-face {
font-family: MyGentium;
src: local(Gentium), /* use locally available Gentium */
url(Gentium.woff); /* otherwise, download it */
}
But there's nothing to say you can't use it in place of a regular font stack. Check out this W3C example:
Create an alias for local Japanese fonts on different platforms:
#font-face {
font-family: jpgothic;
src: local(HiraKakuPro-W3), local(Meiryo), local(IPAPGothic);
}
*There are some caveats though. Don't expect this to work exactly like the familiar font-family stack that you're used to. Firstly, there's no fallback for individual characters that may not be supported by your font. Secondly, you can't refer to generic font-families (like sans-serif, system-ui, etc). For those features, you're stuck with the classic font stack. But you can happily use both features, encapsulating all your named fonts in the #font-face rule, and adding the generic font as your last-resort fallback in the font-family declaration:
p {
font-family: bodytext, sans-serif;
}
CSS Variables is one solution to stay DRY
:root {
--MainFont: "Gotham", "Franklin Gothic Medium", "Arial Narrow", Arial, sans-serif;
--HeavyFont: "Gotham Black", "Franklin Gothic Medium", "Arial Narrow", Arial, sans-serif;
}
body {
font-family: $MainFont;
}
h1 {
font-family: $HeavyFont;
}

font-face for local fonts

I have a framework of html/css pages using a font-face declaration with a otf. Now I want to switch it to a common font like Verdana. How can I assign Verdana to the font-face declaration avoiding a numerous replacement of font-family declaration? In other words: How can I use the font name declarated by font-face as a font variable?
#font-face {
font-family: 'bauer-bodoni.otf';
src: url(../fonts);
Should be something like this (which is not working in this form):
#font-face {
font-family: 'Verdana', 'Arial', sans-serif;
Thank you very much in advance.
-R.
EDIT/ANSWER: I've found out on my own. The trick is not to list the fonts the way you do in a normal font declaration, separated by comma, but with a "local()" for each:
#font-face {
font-family: 'myOwnFontSet';
src: local('Verdana');
src: local('Arial');
src: local(sans-serif);
Your update is still wrong. You need the following:
#font-face {
font-family: 'myOwnFontSet';
src: local('Verdana'), local('Arial'), local(sans-serif); }

Resources