@font-face – MDC
Table of contents
- 1. Summary
- 2. Syntax
- 3. Values
- 4. Supported font formats
- 5. Examples
- 6. Notes
- 7. Browser compatibility
- 8. Specifications
- 9. See also
@font-face
Table of contents
- 1. Summary
- 2. Syntax
- 3. Values
- 4. Supported font formats
- 5. Examples
- 6. Notes
- 7. Browser compatibility
- 8. Specifications
- 9. See also
« CSS « CSS Reference
Summary
@font-faceallows authors to specify online fonts to display text on their web pages. By allowing authors to provide their own fonts,@font-faceeliminates the need to depend on the limited number of fonts users have installed on their computers.Syntax
@font-face { font-family: ; src: [,]*; [font-weight: ]; [font-style:Values
- Specifies a font name that will be used as font face value for font properties.
- URL for the remote font file location, or the name of a font on the user’s computer in the form
local("Font Name").- A font weight value.
A font style value. You can specify a font on the user’s local computer by name using the
local()syntax. If that font isn’t found, other sources will be tried until one is found.Supported font formats
- Gecko 1.9.1 (Firefox 3.5) supports TrueType and OpenType fonts.
- Gecko 1.9.2 (Firefox 3.6) adds support for WOFF.
Examples
This example simply specifies a downloadable font to use, applying it to the entire body of the document.
Web Font SampleThis is Bitstream Vera Serif Bold.
In this example, the user’s local copy of “Helvetica Neue Bold” is used; if the user doesn’t have that font installed (two different names are tried), then the downloadable font named “MgOpenModernaBold.ttf” is used instead:
- @font-face {
- font-family: MyHelvetica;
- src: local(“Helvetica Neue Bold”),
- local(“HelveticaNeue-Bold”),
- url(MgOpenModernaBold.ttf);
- font-weight: bold;
- }
@font-face { font-family: MyHelvetica; src: local("Helvetica Neue Bold"), local("HelveticaNeue-Bold"), url(MgOpenModernaBold.ttf); font-weight: bold; }Notes
- In Gecko, web fonts are subject to the same domain restriction (font files must be on the same domain as the page using them), unless HTTP access controls are used to relax this restriction.
Note: Because there are no defined MIME types for TrueType, OpenType, and WOFF fonts, the MIME type of the file specified is not considered.- When Gecko displays a page that uses web fonts, it initially displays text using the best CSS fallback font available on the user’s computer while it waits for the web font to finish downloading. As each web font finishes downloading, Gecko updates the text that uses that font. This lets the user to read the text on the page more quickly.
B
rowser compatibility
Browser Lowest version Support of Internet Explorer 4.0 Embedded OpenType fonts only Firefox (Gecko) 3.5 (1.9.1) TrueType and OpenType fonts only 3.6 (1.9.2) Web Open Font Format (WOFF) Opera 10.0 TrueType and OpenType fonts only Safari (WebKit) 3.1 (525) TrueType and OpenType fonts only See also MSDN Microsoft library @font-face.
Specifications
- CSS 2 Fonts 1998-05-12 Obsolete
- CSS 3 Fonts 2009 Working draft
- WOFF file format specification Draft
Retrieved from “https://developer.mozilla.org/index.php?title=en/CSS/@font-face“
Languages
Page last modified 17:49, 1 Aug 2010 by Verruckt
