Introducing sIFR: The Healthy Alternative to Browser Text

UPDATE: Version 2.0 is now available. See article here.

It’s been well over ten years now since the debut of the graphical web browser and we still don’t have an easy way to deliver rich typography using HTML/CSS. With CSS we can size, style, color, kern, show, and hide our text but we can’t deliver something classical typesetters have delivered since at least the 15th century: custom typography. Until now. In concert with Shaun Inman and Tomas Jogin, I am releasing into the public domain a scalable, multiline, Flash 6 compatible version of IFR to help you reduce the amount of browser text in your life and free the world from the scourge of Arial.

An updated example of sIFR (now at version 2.0) is available here.

But first, a little history

Custom typography for the masses made its debut on computers in 1984 with the release of the Apple Macintosh. The original Mac came pre-installed with such jewels as Chicago, Geneva, New York, and London. As more foundries released digital Postscript versions of their masterpieces over the next several years, the pool of available typefaces grew to thousands. Want to design a wedding invitation? Use Sloop. Want to emulate an artist’s handwriting? Use Cezanne. Want to throw together a cheesy HR flyer? Use Comic Sans. The possibilities are endless, and in some cases, scary.

Then along came the web.

Originally used to spread technical documents across networks, the early web had no need for anything but the barest of typographic essentials. There was no imagery, no sound, no animation, no color, and none of the niceties we are used to seeing on the 21st century web. With the introduction of the Mosaic graphical web browser in 1993, this began to change. Text could now be rendered using any font installed on a user’s system.

A technology before its time?

This newfound support for custom typefaces was nice, but it ended up being of limited use for the following two reasons:

  1. Postscript typefaces were not represented on screen by their beautiful font outlines but rather by jaggy (“aliased”) bitmaps specially designed for low resolution displays. What this meant was that unless typeface designers created special bitmaps for each possible size on screen, the font ended up looking like crap. Even today, the best web typefaces (viz. Verdana, Tahoma, Helvetica) have been specially adapted for low-resolution displays and that’s why they look so clean on screen.
  2. There is only a tiny subset of fonts commonly installed on Macs, PCs, and (some) Linux machines. These include the usual suspects: Verdana, Times, Georgia, Helvetica, Courier, and the ugly kid in the corner that no one likes — Arial. Since most people have nothing but these core fonts installed on their systems, it is futile for a designer to specify another font to use on their web site when the user is unable to display it.

Eleven years later, the situation is finally changing. Mac OS X uses Quartz technology to display true Postscript anti-aliased fonts on-screen and the effect is stunning. Windows uses a slightly inferior technology called ClearType to accomplish a slightly inferior version of the same thing. With this newfound ability to display true versions of typefaces in web browsers, you’d think typography on the web would be exploding. Well it’s not. Why? Because no one has solved the second problem yet: how to deliver custom typefaces to people who don’t have them installed.

Premature proprietary panaceas

Several years ago, three possible solutions to this problem were floated out to the web development community. Netscape introduced a feature called “Dynamic Fonts” which downloaded a temporary character set for whatever font the designer had specified. This solution only worked in Netscape browsers of course. Then Bitstream, a renown type foundry, released a plug-in called the “Bitstream Font Player” which purported to do the same thing via a more compatible plug-in model. Eventually, Internet Explorer broke this functionality and Microsoft introduced their own solution for dynamic fonts: the very creatively named Web Embedding Fonts Tool, or WEFT. WEFT fonts took the form of downloadable EOT files which actually worked pretty well in PC Internet Explorer but were totally unsupported in any other browser or OS.

The problem with all of these solutions was that they were not compatible across OSes and browsers, but perhaps more importantly, they were too far ahead of their time. Who wants to view a custom font if it can’t be rendered as its designer intended, with anti-aliased Postscript goodness?

So here we are in 2004 and no one has come up with an easy solution to the problem of custom typography on the web.

Flash to the rescue

With today’s release of sIFR, or Scalable Inman Flash Replacement, we finally have a standards-compliant way to deliver rich typographical text in a flexible manner to over 90% of web users. What is this all about, you ask? Here’s a brief overview of how we got here:

In 2001, I redesigned ESPN.com employing a custom-built Flash 4 component to display our headlines in bold anti-aliased Akzidenz Grotesk (the official ESPN on-air typeface). Using inline javascript, we were able to display rich headlines to people who had Flash 4 installed and plain text to those who didn’t. Additionally, the Flash component automatically scaled down all headlines to fit on one line no matter how much text was entered. The rich headlines drew praise from our users and the negative effect on the code was minimal.

Two years later, Shaun Inman invented a much better technique of embedding Flash headlines by not embedding them at all. Instead, Shaun wrote his pages out as standard XHTML and then used javascript and the Document Object Model to replace all designated text with Flash-rendered text a split second after the page had loaded. Known as IFR, or Inman Flash Replacement, this method was rightly praised by the web community for enabling rich typography without affecting any underlying XHTML code. The method had many revolutionary features and only a few shortcomings, the most glaring of which was the lack of support for multiple lines of text.

Several months after Shaun released IFR into the wild, Tom Werner and Rob Cameron built on Shaun’s code and released their own version called WAC-FR, or Werner and Cameron Flash Replacement. Tom and Rob proved that there was a lot more work to be done in the world of Flash Replacement by introducing a great set of features including support for multiple lines, CSS, and scalability based on a user’s text-zoom setting. The main drawbacks of WAC-FR were that it required Flash 7, it relied on a character count to estimate how many characters might fit on a line, and it sometimes used multiple Flash movies for single blocks of text. As of the summer of 2004, Flash 7 penetration is at about 60% so WAC-FR probably can’t be considered a solution for the masses yet, but that percentage improves every day.

As part of a major yet-to-be announced redesign project (think ESPN big… details soon), I had to come up with a way to display multiple line Flash headlines while keeping compatibility with Flash 6. Furthermore, the headlines had to adapt automatically to areas of different heights and widths.

sIFR is born

sIFR approaches text replacement in a totally different way than previous methods:

  • Traditional IFR says “Here’s the exact vertical and horizontal space we’re going to provide for this Flash headline. Make sure you don’t use too many words or they won’t show up.”
  • WAC-FR says “Here’s the text we need to display in Flash, here’s the type size to display it at. We’ll keep stacking Flash movies on top of each other until all the text is displayed.”
  • sIFR turns the model on its face and says “Here’s the exact space the headline fills up if rendered as browser text. Let’s draw a Flash movie that exact size and lay the type out as snugly as possible within it.”

The following explains the sIFR process:

  1. A page is requested and loaded.
  2. Javascript detects if Flash 6 or greater is installed.
  3. If no Flash is detected, the page is drawn as normal.
  4. If Flash is detected, the HTML element of the page is immediately given the class “hasFlash”. This effectively hides all text areas to be replaced but keeps their bounds intact. The text is hidden because of a style in the stylesheet which only applies to elements that are children of the html.hasFlash element.
  5. The javascript traverses through the DOM and finds all elements to be replaced. Once found, the script measures the offsetWidth and offsetHeight of the element and replaces it with a Flash movie of the same dimensions.
  6. The Flash movie, knowing its textual content, creates a dynamic text field and renders the text at a very large size (96pt).
  7. The Flash movie reduces the point size of the text until it all fits within the overall size of the movie.

This, of course, all happens too quickly for the user to even notice what’s going on, but below is a super slow motion example of the process (Flash required to see demo):

In addition to the improvements I’ve made to the original IFR on the Flash side of things, I worked with the incomparable Tomas Jogin to improve the replacement script itself. Tomas wrote in an entry several weeks ago that he wanted IFR to be able to replace not only structural elements like H1s and H2s, but all HTML elements, including DIVs. Tomas rewrote a portion of Shaun’s original IFR script to accomplish just that. So now we have in sIFR a solution which can dynamically replace any element of any height or width with a Flash movie that will correctly display one or multiple lines of text.

As another added bonus, I’ve built in the ability to automatically keep the Flash text linkable if the normal HTML version was linkable. You can even configure it so underlines show up when you hover over the text.

But will it scale?

With sIFR comes the introduction of a new feature I call “lazy scaling”. Since sIFR lets the original browser text determine the height and width of the area to be replaced, that area scales with the user’s text zoom setting. While WAC-FR does a great job of scaling on-the-fly when a user resizes text, sIFR only scales on page load. This is not much of a sacrifice in my opinion because firstly, I expect users to use sIFR mainly for text that is already large enough to see clearly, and secondly, because if a user is vision-impaired, they are probably surfing the web with text zoom consistently on. I don’t expect a lot of people are toggling between text zoom settings dynamically for every page they visit.

Limitations

The only significant restriction I am aware of so far is that you shouldn’t use Flash text which is markedly narrower than your browser text. Using text that is wider is no problem since Flash will just shrink it to fit, but for best results, try to match the metrics of your Flash font as closely as possible to the metrics of your browser font. Don’t be afraid to use negative kerning on your browser text if you have to. What I did was render a couple of lines of the custom font in Photoshop, take a screenshot, pull it into Dreamweaver, and overlay browser text on top of it. This way, you can tweak the kerning, leading, size, and weight of your browser text until you get a close match. You don’t have to get it perfect… just get it so that the browser text takes up either the same space or slightly less space than the custom font text. This is a one-time process and it only takes a few minutes.

If you must use markedly narrower Flash text, you can hack the script so that as soon as Flash is detected, your browser text is given extreme negative kerning values before the headline boxes are measured.

How to use it

Grafting sIFR into your site is simple:

  1. Open up “sIFR.fla”, double-click the font item in the library, and choose any font installed on your system. Export the movie out as “sIFR.swf” or whatever name you’d like.
  2. Set the CSS properties of your browser text as mentioned in the paragraph above.
  3. Set which items you’d like to replace at the bottom of the “sIFR.js” file.
  4. Include the “sIFR.js” file in the head element of your pages.

That’s it! You’ve just freed yourself from the typographical constraints of browser text.

What’s next for web typography?

While sIFR is a liberating solution, it clearly falls into the category of “things which shouldn’t have to be done”. Not coincidentally, this is the same category a lot of things on the web fall into. Using floats to create column layouts, using javascript to clear absolutely positioned elements, using empty alt tags, using image replacement methods, etc, etc, etc. There are simply a lot of things we do as web developers because of the glacial pace at which standards manifest themselves. Do we like standards? Yes, we do. But will we sacrifice our own ability to create better work on the web because of them? No, we won’t. Well, some people will.

I won’t.

In working through sIFR, I began to think of ways browser manufacturers could quickly implement anti-aliased custom typography. The only possible answer I could think of was licensing Flash’s rendering engine. We’ve already proven that Flash can render text as we like on all platforms, and we’ve already seen that every new version of Flash penetrates over 85% of computers within 14 months, so why can’t there be some sort of standard declaration in browsers which invokes a Flash font outline file and renders designated text in that typeface? Ideally, it would be a CSS declaration like so:

h1 {font-family-enhanced: "futura.swf"}

Update: It has been brought to my attention that the @font-face declaration is already part of the CSS2 spec (I thought it was just a Microsoft addition), so perhaps something like this instead:

@font-face {font-family: "Futura"; src: url("futura.swf") format("opentype", "flash");}

Since it’s a new property, it wouldn’t break any existing sites and would degrade gracefully as well. I know this sort of solution might be sacrilegious to the W3C, but what about the more progressive, quicker moving, less idealistic WHATWG? Here’s a group that is interested in improving browsers NOW, damn the purists. I really love what the WHATWG is doing in the HTML space these days, but I wonder if typography is even on their plate. Hey Macromedia, how about organizing a kegger with those guys or something?

In conclusion

Please feel free to use sIFR in your own projects or wherever the situation calls for it. I am under no illusions that this solution is perfect yet, so if you notice quirks or have improvements to suggest, please post them here. I will be happy to roll any improvements into new builds as soon as they are judged as such.

sIFR is offered free of charge, but also free of customer service. I usually try to answer all questions readers submit, but my time is limited.

Right-click here to download the latest sIFR (1.1.4) or check out an example online.

sIFR is now at version 2.0. Please see the most recent sIFR article for details, files, and examples.

Alright, have at it!

Like this entry? You can follow me on Twitter here, subscribe via email here, or get the RSS feed if that's how you roll.

209 Responses:

  1. Netscape 8 and sIFR

    First off, who beat Netscape 8 with the ugly stick? It’s the most horrendously designed application I’ve seen in a…

  2. Vakker tekst, i Flash

    Det finnes utrolig mange .gif rundt om kring hvis eneste formål er å gjengi “pen” tekst, slik at den ser ut som i Photoshop. Hørte jeg “vanskeligheter” med oppdatering? Nå finnes det en Flash-løsning, som gir pene, myke bokstaver. Om…

  3. Rich Accessible Typography

    sIFR ovvero Scalable Inman Flash Replacement è un nuovo approccio al design di siti Web che sfrutta gli standard più volte citati e sempre presenti nei più attuali siti Internet. Il vantaggio pratico di questa tecnologia è quello di permettere

  4. […] Mike Davidson – Introducing sIFR: The Healthy Alternative to Browser Text (tags: css) […]

  5. […] you are interested in sIFR, a good place to start is the blog page Introducing sIFR: The Healthy Alternative to Browser Text. Its main disadvantage as a tool is that it relies on the visitor’s having installed the […]

  6. […] main distraction has been steady client work. Anyhow – in the meantime, I apologize for my tiresome SiFR […]

  7. […] with without CSS for those headlines with funny fonts – use sIFR to replace your text with a Flash image of the text. Neat, although you’d need to be a bit of […]

  8. […] Cualquiera que haya seguido el desarrollo de sIFR en los últimos meses conocerá la mayoría de lo que voy a contar, pero dado que este es el anuncio oficial de sIFR 2.0, a continuación se presenta una vista general de la tecnología utilizada. De cualquier forma, eres libre de leer la perspectiva histórica completa en mi post original: Introducing sIFR: The Healthy Alternative to Browser Text. […]

  9. […] http://www.mikeindustries.com/blog/archive/2004/08/sifr […]

Shared
The Ocean in 185 Lines of Javascript:

Mesmerizing. Try tweaking some of the variables in the “sea” section of the code.

“"Design had been a vertical stripe in the chain of events in a product’s delivery; at Apple, it became a long horizontal stripe, where design is part of every conversation.””
Why I Just Asked My Students To Put Their Laptops Away:

A great essay about how toxic everyday distractions can be.

Humanity's deep future:

A group of researchers at the Future of Humanity Institute talk about where our race may be going and how artificial intelligence could save or kill us all.

Steve Jobs speaks about the future at the International Design Conference in 1983:

31 years later, it’s safe to say this is one of the most prescient speeches about technology ever delivered. Jobs covers wireless networking, tablets, Google StreetView, Siri, and the App Store (among other things) many years before their proliferation. A fantastic listen.

How to travel around the world for a year:

Great advice for when you finally find the time.

LiveSurface:

A fantastic app for prototyping your design work onto real world objects like billboards, book covers, and coffee cups. This seems like just as great of a tool for people learning design as it does for experts.

50 problems in 50 days:

One man’s attempt to solve 50 problems in 50 days using only great design. Some good startup ideas in here…

How to Do Philosophy:

If you’ve ever suspected that most classical philosophy is a colossal waste of time, Paul Graham tells you why you’re probably right.

TIME: Why Medical Bills Are Killing Us:

Stephen Brill follows the money to uncover the pinnacle of corruption that is the U.S. Health Care system. A must-read article if there ever was one.

DIY Dot Org:

A beautifully designed site full of fun and challenging DIY projects. I could spend months on here.

The Steve Jobs Video Archive:

A collection of over 250 Steve Jobs videos in biographical order

Self-portraits from an artist under the influence of 48 different psychoactive drug combos.

Water Wigs are pretty amazing.

David Pogue proposes to his girlfriend by creating a fake movie trailer about them and then getting a theater to play it before a real movie. Beautiful and totally awesome.