Why are SVG Fonts so different?
- Web - Lien permanent
Une version française de cet article est disponible sur typographisme.net : Pourquoi les fontes SVG sont-elles différentes des autres ?
I’m sad to see that there are many misconception about SVG fonts. I’ve read a lot of articles and complains about the SVG font format and the last (but not the least) was an article from Alexander Limi explaining why Firefox will not pass the Acid3 test mainly due to a lack of SVG font support. All those complain are misplaced in many way because SVG fonts are misunderstood. Really? But in this case, what are SVG fonts made for? Let’s see that.
Forget it for regular text
One of the biggest misconceptions about SVG fonts is thinking that this format is suitable for regular HTML text. Unfortunately, it is not! In my opinion, this misconception is mainly due to Apple. Until iOS 4.2, SVG was the only format available to use custom fonts on iPhone and iPad. And because this support was (is?) somewhat buggy, SVG fonts’ reputation was badly injured.
Anyway, beyond iOS SVG font support, it’s a fact that SVG font format does not support font hinting. To understand that so called “lack” it’s important to think back about the specificity of the SVG image format. SVG shapes are placed in an absolute coordinate system and SVG documents do not have text flow ability such as HTML documents. Also, SVG documents do not necessarily have pixel perfect dimensions and the shapes can be subjected to mathematical transformations (rotation, scaling, skewing, etc.). So this means that a glyph can be placed anywhere in a document and its shape modified, but most of the time it won’t match a pixel perfect size nor even a pixel perfect grid. With all those constraints, hinting is not really helpful because it needs a pixel grid system to give its best.
If you simply try to use a WOFF font in an HTML document and apply a CSS3 2D transform, you’ll see that even with a hinting system, this does not really make a difference. But on the contrary, on regular HTML text that is pixel perfect positioned, SVG fonts are not so beautiful especially at small size. So yes, in an HTML document, SVG fonts are poor. But, as I said, it’s not their main purpose.
The power of drawing tools
In regards of other fonts formats, one of the biggest advantages of SVG fonts is the way shapes can be drawn.
Technically speaking, the shapes in SVG fonts can be made of any kind of curves (cubic or quadratic Bezier in different flavors or arc definitions) where shapes in TrueType fonts can only be made of quadratic Bezier curves. OpenType fonts are a bit smarter by supporting cubic Bezier curves, but for what I know no other font format supports arc definition. So, in theory the outlines produced for SVG fonts could be much more optimized than in other font formats. Ok, let’s be honest, it is not often the case in classical glyph design. But there is more. Because SVG fonts could use all the power of SVG it is possible to draw very complex shapes by mixing arbitrary paths and basic SVG shapes, which gives you a more control over your font design. So when you want to design an ornamental font, SVG gives you better tools to do so.
Practically speaking, it’s possible to use any software supporting SVG to draw fonts. This includes traditional font software such as FontForge but it’s also possible to take full advantage of drawing software such as Adobe Illustrator or Inkscape (this one provides powerful tools for drawing fonts). Of course such drawing software can be used to produce outlines for other font formats but you’ll always need to export them inside a specific font tool to convert those outlines to the right curves definition (which can have side effects on your design). With SVG, you don’t need to. You can directly use the output from your drawing software.
Animation, filters, video… \o/
Let’s go forward. SVG, beyond its drawing ability, has some amazing extension such as gradients, patterns, clipping, masking, animations, filters or even foreign object inclusion. It means that you can use all of this inside your SVG fonts. Yes it’s possible to produce native animated font with SVG. With filters, you can produce blurry or textured fonts. And with foreign object inclusion… Wow ! There’s no limit. Why not imagine a font with a sound background? Yes it’s possible, just include an HTML audio element and it’s done.
Of course it’s not necessarily wise to do such things. Especially if you want to use such a font for regular text. But think about it. The SVG font format unleashes your creativity to a brand new world. Say good-bye to the legacy “lead & paper” typography and jump out the final frontier with the upcoming of fonts made FOR the web (and not just backported to it).
Embedding and DOM Access
You think it’s amazing? Let’s go one step further in the twilight zone.
Historically speaking, ten years ago, SVG font was the only font format that could be embedded inside an SVG document. This feature was required to ensure that the rendering of a font inside an SVG document would remain consistent across different platforms and user-agents. Today, thanks to CSS @font-face and Data URI, it’s possible to embed any type of font format, but still, SVG fonts have always a huge advantage here.
As you know, SVG is an XML format so SVG font as well. This means that you can embed SVG fonts inside any XML document (for example in an SVG image or in an XHTML document and, in a near future, with HTML5, in any ordinary HTML document) and still have access to the glyphs through the DOM of the XML document. And this is huge because it means two crazy things:
- You can easily access the font content through Javascript and change it as you wish for whatever reason. The SVG font format lets you in control of each individual glyph at runtime.
- You can use CSS to style each individual glyph which gives you an amazing control on how the font will be rendered.
The other font formats do not provide such an easy and full access to their core design.
Security, accessibility, bla, bla, bla…
With such great power come amazing responsibilities. Security is one of the main concerns about SVG fonts. As Borris Zbarsky points out : Once you put an
and is damn right. This point have to be discussed but is it a reason to drop everything? I don’t think so. <iframe>
in a glyph, all sorts of issues arise
Another concern is about accessibility - so highly interactive fonts raise many issues, for example “how the user can control the animation on an animated font?”. But these questions are basically of the same type as those SVG brings on its own. So it’s possible to rely on the solutions available for SVG in a general purpose.
Of course it’s necessary for both browser constructors and web authors to take care about all those constrains. I’m sure some evil web authors will use SVG fonts badly, sure that browser vendors (all of them) do not presently do their best to support SVG fonts. So be it - but I think that SVG fonts are a real turning point in the history of typography and should be taken for what they really are: an amazing tool to bring fresh design ideas in typography and cool typography in web design. And it’s important to remember that SVG fonts do not play the same game as WOFF fonts on the web. Both formats have their strengths and weaknesses but there are not mutually exclusive.