This is my @font-face declaration to support different font variants, in this case the bold and bolder version of my font.
@font-face {
font-family: "santana";
src: url("data:font/ttf;base64,AAEAAAALAI....") format('truetype');
font-weight: normal;
font-style: normal;
}
@font-face {
font-family: "santana";
src: url("data:font/ttf;base64,AAEAAAALAI....") format('truetype');
font-weight: bold;
}
@font-face {
font-family: "santana";
src: url("data:font/ttf;base64,AAEAAAALAI....") format('truetype');
font-weight: bolder;
}
Right now I'm just working with Chrome and Firefox. In Chrome the normal and bold variants work, but not the bolder variant (keeps the 'bold' one). In Firefox only the bold variant works as expected, in any other case the bolder variant is used (even for normal weight).
Is this a known issue or is there a better way to do this declaration?
The @font-face CSS at-rule specifies a custom font with which to display text; the font can be loaded from either a remote server or a locally-installed font on the user's own computer.
While a typeface is a set of design features for letters and other characters, a font is the variation in weight and size of a typeface. A font family is a group of related fonts.
Typography Basics There are five basic classifications of typefaces: serif, sans serif, script, monospaced, and display. As a general rule, serif and sans serif typefaces are used for either body copy or headlines (including titles, logos, etc.), while script and display typefaces are only used for headlines.
The font-variant CSS shorthand property allows you to set all the font variants for a font. You can also set the CSS Level 2 (Revision 1) values of font-variant , (that is, normal or small-caps ), by using the font shorthand.
There are 2 separate issues here:
Keywords
The problem with using font-weight keywords appears to be that lighter
and bolder
are not absolute values like normal
and bold
(always 400 and 700, respectively), but are relative to the established boldness of the parent element (100 lighter or darker). It may not be possible to treat lighter
and bolder
as if they're absolute values.
As @HTMLDeveloper and @Christoph suggested, using numeric values rather than keywords is the easy solution to this, and may by itself be an adequate solution (if support for IE8 isn't needed).
@font-face {
font-family: "santana";
src: url("data:font/ttf;base64,AAEAAAALAI....") format('truetype');
font-weight: 400;
font-style: normal;
}
@font-face {
font-family: "santana";
src: url("data:font/ttf;base64,AAEAAAALAI....") format('truetype');
font-weight: 700;
}
@font-face {
font-family: "santana";
src: url("data:font/ttf;base64,AAEAAAALAI....") format('truetype');
font-weight: 900; /* or whatever weight you need to use for "bolder" */
}
IE8 and earlier
Some browsers have display issues when multiple weights or styles are associated with the same font-family
name.
Specific issues I'm aware of: (there may be others)
The solution is to use a unique font-family
name for each font variation:
@font-face {
font-family: "santana";
src: url("data:font/ttf;base64,AAEAAAALAI....") format('truetype');
}
@font-face {
font-family: "santana-bold";
src: url("data:font/ttf;base64,AAEAAAALAI....") format('truetype');
}
@font-face {
font-family: "santana-bolder";
src: url("data:font/ttf;base64,AAEAAAALAI....") format('truetype');
}
This approach is commonly used by font services like Typekit. If support for a wide variety of browsers is needed (or at least, IE8 in particular), this could be considered one of the prices you have to pay when embedding fonts.
In font-face single font the quotes for font family name is not needed. you should remove and run it will works fine. font-family: santana; font-weight: 900;
do not need for single font, it needs only multiple fonts. instead of bolder use numerical value it should works fine.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With