This article was written by John Daggett. John is a Mozilla contributor and has been working hard with font creators and web developers to improve the state of fonts on the web. This article is a high-level overview of whats different and shows some examples of WOFF in use. A full list of other supporting organizations can be found at the official Mozilla Blog.

In Firefox 3.5 we included support for linking to TrueType and OpenType fonts. In Firefox 3.6 we’re including support for a new font format – the Web Open Font Format, or WOFF. This format has two main advantages over raw TrueType or OpenType fonts.

  1. It is compressed, which means that you will typically see much smaller download sizes compared with raw TrueType or OpenType fonts.
  2. It contains information that allows you to see where the font came from – without DRM or labeling for a specific domain – which means it has support from a large number of font creators and font foundries.

The WOFF format originated from a collabaration between the font designers Erik van Blokland and Tal Leming with help from Mozilla’s Jonathan Kew. Each had proposed their own format and WOFF represents a melding of these different proposals. The format itself is intended to be a simple repackaging of OpenType or TrueType font data, it doesn’t introduce any new behavior, alter the @font-face linking mechanism or affect the way fonts are rendered. Many font vendors have expressed support for this new format so the hope is this will open up a wider range of font options for web designers.

Details on Differences between TrueType, OpenType and WOFF

First, compression is part of the WOFF format so web authors can optimize the size of fonts used on their pages. The compression format is lossless, the uncompressed font data will match that of the original OpenType or TrueType font, so the way the font renders will be the same as the original. Similar compression can be achieved using general HTTP compression but because compression is part of the WOFF format, it’s simpler for authors to use, especially in situations where access to server configuration is not possible.

Second, the format includes optional metadata so that a font vendor can tag their fonts with information related to font usage. This metadata doesn’t affect how fonts are loaded but tools can use this information to identify the source of a given font, so that those interested in the design of a given page can track down the fonts used on that page. Fonts in WOFF format are compressed but are not encrypted, the format should not be viewed as a “secure” format by those looking for a mechanism to strictly regulate and control font use.

Note: until Firefox 3.6 ships, users can test the use of WOFF fonts with Firefox nightly builds.

Examples

Below is a simple example that shows how to construct an @font-face rule that links to a WOFF font. To support browsers that only support direct linking to OpenType and TrueType fonts, the ’src’ descriptor lists the WOFF font first along with a format hint (“woff”), followed by the TrueType version:

/* Gentium (SIL International) */
 
@font-face {
  font-family: GentiumTest;
  src: url(fonts/GenR102.woff) format("woff"),
       url(fonts/GenR102.ttf) format("truetype");
}
 
body {
  font-family: GentiumTest, Times, Times New Roman, serif;
}

Structured this way, browsers that support the WOFF format will download the WOFF file. Other browsers that support @font-face but don’t yet support the WOFF format will use the TrueType version. (Note: IE support is a bit trickier, as discussed below). As WOFF is adopted more widely the need to include links to multiple font formats will diminish.

Other examples below demostrate the use of WOFF formatted fonts but each example has been constructed so that it will work in any browser that supports @font-face, including Internet Explorer.

A font family with multiple faces

Using a Postscript CFF font

African Language Display

Below is an example of how downloadable fonts can be used to render languages for which font support is usually lacking. The example shows the UN Declaration of Human Rights, translated into two African languages, and how these render with default browser fonts vs. with a downloadable font suited for rendering these languages.

Note that in one of these examples that the font size goes from a 3.1MB TTF to a 1MB WOFF font and in the other from a 172KB TTF to an 80KB WOFF file.

Another Postscript CFF font

An example in Japanese

Working With Other Browsers

Firefox 3.6 will be the first shipping browser to support the WOFF format so it’s important to construct @font-face rules that work with browsers lacking WOFF support. One thing that helps greatly with this is the use of format hints to indicate the format of font data before it’s downloaded; browsers that don’t recognize a given format simply skip data in a format they don’t support.

Internet Explorer, including IE8, only supports the EOT font format and only implements a subset of the @font-face rule descriptors. This makes creating cross-platform @font-face rules that work with IE especially tricky. One solution is to make different rules for IE:

@font-face {
  font-family: GentiumTest;
  src: url(fonts/GenR102.eot);  /* for IE */
}
 
@font-face {
  font-family: GentiumTest;
  /* Works only in WOFF-enabled browsers */
  src: url(fonts/GenR102.woff) format("woff"); 
}

One minor downside of this is that IE doesn’t understand format hints and doesn’t parse @font-face URL’s correctly, it treats format hints as part of the URL, so web authors using the @font-face rules above will see the following in their access logs:

GET /fonts/GenR102.eot HTTP/1.1" 200 303536
GET /fonts/GenR102.woff)%20format(%22woff%22) HTTP/1.1" 404 335

IE successfully pulls down and uses the EOT version of the font but also tries to pull down the WOFF font with the format hint included in the URL. This fails and doesn’t affecting page rendering but it wastes valuable server resources. For more discussion, see Paul Irish’s blog post for one interesting workaround.

Another problem is that IE currently tries to download all fonts on the page, whether they are used or not. That makes site-wide stylesheets containing all fonts used on site pages difficult, since IE will always try to download all fonts defined in @font-face rules, wasting lots of server bandwidth.

Further Resources

Documentation

Latest draft WOFF specification
Original blog post on using @font-face
CSS3 Fonts working draft
MDC @font-face documentation

Tools

Jonathan Kew’s sample encoding/decoding code
woffTools – tools for examining and validating WOFF files
FontTools/TTX – Python library and tool for manipulating font data
Web-based font subsetting tool

General @font-face Examples

CSS @ Ten: The Next Big Thing
Example layout using Graublau Sans
Examples of Interesting Web Typography
The Elements of Typographic Style Applied to the Web

Font Resources

Font Squirrel
10 Great Free Fonts for @font-face
40 Excellent Free Fonts by Smashing Magazine

69 comments

Post a comment
  1. Pingback from Mozilla Firefox 3.6 Beta Coverage | profirefox.org | FireFox Plugins, Themes and Updates Blog.. on November 20th, 2009 at 3:18 pm:

    [...] Support for the WOFF font format. [...]

    Reply

  2. Pingback from Download Mozilla Firefox 3.6 Beta 3 | tech-Know kishan on November 20th, 2009 at 5:32 pm:

    [...] native video can now be displayed full screen, and supports poster frames.Support for the WOFF font format.Improved JavaScript performance, overall browser responsiveness and startup time.Support for new [...]

    Reply

  3. dogmother wrote on November 26th, 2009 at 6:18 pm:

    No conversion tools yet? What is fontsquirrel using for the online converter?

    Reply

  4. Brett Zamir wrote on November 28th, 2009 at 12:20 am:

    Besides being an informative post, it’s great to see citations from the UDHR!

    As far as fonts supporting Unicode, I made a request at https://bugzilla.mozilla.org/show_bug.cgi?id=512619 for Mozilla to consider hosting some very basic (and free) fonts on a server which could be automatically retrieved and cached whenever Unicode characters were encountered but not supported in one’s default font support (and where font-face wasn’t specified). Rather than put the burden on developers (and avoid a potential single point of failure for their users), how about facilitating the download of basic fonts covering all specified Unicode code points for all users (without interfering with the ability for sites to cause custom fonts to be downloaded)?

    This way, the dream of Unicode–for any human script to be practically viewed along with any others without extra hurdles–could really be realized.

    Reply

  5. Pingback from firefox 3.6 Beta4 | 活在當下 on December 3rd, 2009 at 7:42 pm:

    [...] Played with typography on the web using WOFF fonts? [...]

    Reply

  6. Pingback from 字形公社 › Core Fonts on December 4th, 2009 at 3:38 am:

    [...] 1996年Microsoft发起了一项名为“Core fonts for the Wed”的互联网字体标准化项目。包括Arial,Times New Roman和Verdana在内的10套字体可在Microsoft网站免费下载。由于互联网浏览器的工作原理和电脑字体自身的特点(比如版权问题),网页中的字体信息并不像图片或其他多媒体文件那样事先被下载到临时缓存文件夹中,再通过浏览器呈现出来;所有网页中的字体成分都需要调用用户系统中已有的字体文件(例如网页设计师通过CSS指定网页中的字体为Tahoma,当互联网终端的用户浏览该网页时,浏览器会根据CSS代码调用系统中的Tahoma字体文件,并完成显示),一旦用户的系统中没有指定的字体,他所看到的网页在文字显示上就是有差异的,而这种差异有时候变得非常棘手(例如网页可读性降低、设计风格改变或者页面要素布局变动等)。而比较直观的解决办法就是让尽可能多的电脑上(不论采用何种OS)都安装尽可能多相同的字体文件以争取相对一致的显示效果。这也就成为了Microsoft发起这一项目的初衷。垄断的好处就在于人多好办事,那时候的Microsoft权倾一时,尽管2002年公司以用户不断违反“最终用户协议”为由终止了该项目(真正的原因或许是Micorsoft向Mac和Linux用户叫板,Apple在2007年延长了与Microsoft的协议以确保Mac用户可放心使用这些字体,至于Linux用户命运如何就不从而知了,谁都知道Microsoft有多恨Linux),但如今这些字形已经普遍到没有人会去担心自己的电脑里是否安装了它们(果然好办事才能办好事)。其中有些字形进一步成为网页编程中默认的字体方案,也就是所谓的“Web Safe fonts”,至今仍支配着当前99%以上的网页文本。尽管现在主流的浏览器已经开始支持网页嵌入式字体(例如时下刚出炉的香饽饽Web Open Font Format),但想要撼动传统的、相对成熟的互联网字形设计也不是一蹴而就的(况且网页嵌入式字体的可行性有待研究,例如嵌入动辄四、五兆的中文字体就很不现实;还有想来让人头痛的版权问题)。 [...]

    Reply

  7. Pingback from Welcome to the new look! « Not Wild About the Font on December 5th, 2009 at 9:34 pm:

    [...] web page. Right now, every browser supports a different font format, but it looks like there may be some progress towards agreeing a common standard – here’s [...]

    Reply

  8. hAl wrote on December 20th, 2009 at 5:03 am:

    Why not support EOT ?
    This is effectivly OpenType but in optimised form (contains OT subsets thus smaller files).
    Much more effective for webpages than opentype and truetype itself and already in use on the internet for 10 years.

    Reply

  9. Pingback from Mozilla Firefox 3.6 Beta 5 Released | Lets see ... Whats Going on on December 23rd, 2009 at 7:28 am:

    [...] Support for the WOFF font format. [...]

    Reply

  10. Pingback from Download Firefox 3.6 Beta 5 Officially | Tricks Machine on December 24th, 2009 at 1:00 am:

    [...] Support for the WOFF font format. [...]

    Reply

  11. Pingback from Beta 5 of Firefox 3.6 | The Browser Guru on December 24th, 2009 at 3:55 pm:

    [...] Support for the WOFF font format. [...]

    Reply

  12. Pingback from FireFox 3.6 beta | by zeltera on December 29th, 2009 at 4:19 am:

    [...] Suport pentru Web Open Font Format [...]

    Reply

  13. Pingback from Mozilla Україна вітає з Новим Роком! » Mozilla Україна on December 30th, 2009 at 11:05 am:

    [...] формату шрифтів WOFF (Web Open Font Format – Відкритий формат веб [...]

    Reply

  14. Pingback from Real Fonts and Rendering: The New Elephant in the Room | Programming Blog on January 4th, 2010 at 10:51 am:

    [...] The problem isn’t just that foundries have yet to agree on a standard font format that protects their intellectual property. And that, even when they do, it will be a while before all browsers support that standard—leaving aside the inevitable politics that impede all standardization efforts. Those are problems, but they’re not the elephant. Call them the coyotes in the room, and they’re slowly being tamed. [...]

    Reply

  15. Pingback from Mozilla & web fonts: W(OF)TF!? · brand:GNU on January 4th, 2010 at 6:45 pm:

    [...] — for example.Future doesn’t appear to be better for webmaster: Mozilla plans to publish a new font format that will be implemented in Firefox 3.6.x (and right now only in it).This – already confirmed by [...]

    Reply

  16. Pingback from New Feature: Typekit support | Mile Wide... Inch Deep... on January 5th, 2010 at 2:08 am:

    [...] setting this up, I read a little today about Mozilla’s WOFF initiative — an attempt to make fonts more flexible and accessible on the web. It remains to be seen [...]

    Reply

  17. Pingback from Firefox 3.6 beta 5, disponible | Espacio Linux on January 5th, 2010 at 7:40 am:

    [...] navegador y el usuario.El video nativo abierto puede mostrarse en pantalla completa.Soporte para el formato web de fuentes abierta.Mejoras en el rendimiento de JavaScript, en la capacidad de respuesta general y a la hora del [...]

    Reply

  18. Pingback from Firefox officially the most popular browser! | Technoheads on January 5th, 2010 at 3:06 pm:

    [...] Support for the WOFF font format. [...]

    Reply

  19. Pingback from Firefox 3.6 RC1 Available Now | Tech Dreams on January 6th, 2010 at 11:25 am:

    [...] WOFF font format support [...]

    Reply

1 2

Add your comment