Join GitHub today
Cufón aims to become a worthy alternative to sIFR, which despite its merits still remains painfully tricky to set up and use. To achieve this ambitious goal the following requirements were set:
- No plug-ins required – it can only use features natively supported by the client
- Compatibility – it has to work on every major browser on the market
- Ease of use – no or near-zero configuration needed for standard use cases
- Speed – it has to be fast, even for sufficiently large amounts of text
And now, after nearly a year of planning and research we believe that these requirements have been met.
So, how does it work?
- To include a font, you only need to load it with the standard
- There is no need to manually parse the file on client-side again
- It compresses extremely well. While often somewhat large in terms of file size without any compression, a compressed font usually weighs in 60-80% less than the original.
The renderer is a bit more complicated. It consists of 3 parts – a Core, which provides the API and common functionality, and two rendering engines. One of them renders VML shapes and is used for Internet Explorer (it supports VML from version 5.5), while the other one uses the widely supported HTML5
<canvas> element. Due to the path data already being VML, little work is needed in the VML engine. The canvas engine, however, must convert all paths to the corresponding sets of drawing commands provided by the canvas API. This turned out to be somewhat tricky at first, but a solution was found after two complete rewrites in the form of code generation and caching, resulting in a very fast renderer.
Inline SVG was also considered but quickly turned down due to it being surprisingly slow in the few browsers that actually support it properly.