Skip to content
This repository


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…


Cannot retrieve contributors at this time

file 278 lines (163 sloc) 14.144 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277

<!doctype html>
<!--[if lt IE 9]> <html class="no-js oldie" lang="en"> <![endif]-->
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <title>About Fonts in SVG | Divya Manian</title>
  <meta name="author" content="Divya Manian">
  <meta name="description" content="One area in my webfonts investigation that I wanted to know more about, was the state of SVG fonts. What is SVG? SVG stands for Scalable Vector &hellip;">

  <meta name="viewport" content="width=device-width, initial-scale=1">

  <link rel="canonical" href="">
  <link href="/stylesheets/screen.css" rel="stylesheet">
  <link href="" rel="alternate" title="Subscribe" type="application/atom+xml">
  <link href="" rel="alternate" title="Subscribe to Web Development updates" type="application/atom+xml">

<body >
  <div class="container">
    <div class="content">
      <header role="banner"> <h1><a href="/">Divya Manian</a></h1>
  <h2><a class="twitter" href="">twitter</a> <a class="rss" href="">RSS Feed</a> <a class="youtube" href="">Youtube Channel</a> <a class="github" href="">Github</a></h2>
      <nav class="sitenav"><a href="/">Home</a>
<a href="/archives">Archives</a>
<a href="/about.html">About</a>


  <nav class="article">
      <a class="previous" href="/book-reviews-for-september-2009.html" title="Book Reviews for September 2009">&#x276C;</a>
      <a class="next" href="/book-reviews-for-october-2009.html" title="Book Reviews for October 2009">&#x276D;</a>


<time datetime="2009-09-19T00:00:00+05:30" pubdate><span class='month'>Sep</span> <span class='day'>19</span> <span class='year'>2009</span></time>
      <h1 class="entry-title"><a href="/about-fonts-in-svg.html">About Fonts in SVG</a></h1>
<div class="entry-content"><p>One area in my <a href="" title="Font in your face | Nimbupani Designs">webfonts investigation</a> that I wanted to know more about, was the state of SVG fonts.</p>

<h3>What is SVG?</h3>


<p>SVG stands for Scalable Vector Graphics. SVG was created to fill the need for a standardized vector graphic solution for the web (read about <a href="">the history of SVG</a>). SVG uses XML to describe 2D graphics. So, a circle is defined in SVG as:</p>

    &lt;svg width=&quot;12cm&quot; height=&quot;4cm&quot; viewBox=&quot;0 0 1200 400&quot;
         xmlns=&quot;; version=&quot;1.1&quot;&gt;
      &lt;desc&gt;Example Circle&lt;/desc&gt;
      &lt;circle cx=&quot;600&quot; cy=&quot;200&quot; r=&quot;100&quot;
            fill=&quot;red&quot; stroke=&quot;none&quot; stroke-width=&quot;0&quot; /&gt;

<p>See <a href="/demo/svgfonts/circle.svg">the sample SVG</a>.</p>

<p>You can convert almost any <a href="" title="Vector graphics - Wikipedia, the free encyclopedia">vector graphic</a> to SVG format (here is <a href="">how to save your Adobe Illustrator files as SVG</a>). Typically, since SVG is XML (and a vector graphic), it will be smaller than other image formats.</p>


<h3>The elephant in the room</h3>

<p>Before I proceed, I must mention that <a href="">IE (even IE 8) does not support SVG</a>. <a href="">IE 9 Preview does have support for SVG</a>. Google Chrome&rsquo;s native support of SVG is not as good as Opera, <a href="">Firefox</a>, or <a href="">Safari</a> either (see <a href="" title="SVG Support in major browsers">this excellent chart of SVG support on various browsers</a>). Google has released <a href="">SVG Web</a> which allows SVG to be rendered on all browsers that support either SVG or Flash.</p>

<h3>Fonts in SVG</h3>

<p>Like in any vector graphic, SVG can have text. If you want the text to render a font on any SVG Viewer, you have 3 options:</p>


    <li><p><em>Use web-safe fonts:</em> This is the easiest. An example:</p>
            <pre>&lt;text x=&quot;100&quot; y=&quot;100&quot; style=&quot;font-family: impact, georgia, times, serif; font-weight: normal; font-style: normal&quot;&gt;
    Text using web safe font
            <p>See demo of <a href="/demo/svgfonts/svg-websafe.svg">SVG rendered with web-safe font</a></p>
        <li><p><em>Use @font-face CSS declaration to specify fonts:</em> Browsers will render text just as they render HTML using @font-face. For example, Firefox does not allow cross-site linking of fonts, so it will not render a font if it is in another server (you need to add a <a href="" title="beautiful fonts with @font-face at">HTTP header to allow cross-site linking</a>). </p>
  &lt;style type=&quot;text/css&quot;&gt;
    @font-face {
        font-family: Delicious;
        src: url(&#x27;;);
&lt;text x=&quot;100&quot; y=&quot;100&quot; style=&quot;font-family: &#x27;Delicious&#x27;; font-weight:normal; font-style: normal&quot;&gt;
 Text using CSS @font-face
<p>See a demo of <a href="/demo/svgfonts/svg-fontface.svg">SVG text rendered with CSS @font-face</a></p>
            <em>Use fonts defined using SVG&rsquo;s font element: </em> SVG format provides a common font format that will be supported by all confirming SVG viewers. An SVG font will have a file extension of &ldquo;.svg&rdquo; and will be formatted as XML. Here are <a href="">some examples of SVG fonts</a>. There are two ways of using SVG Fonts: </p>
    <li><p><em>Using external SVG Fonts: </em> You can link to an external SVG using the font-face element of SVG (not the CSS @font-face declaration).</p>
<li><p><em>Embed font within the svg file:</em> Most Vector Graphic editors default to this option.</p></li>
            <p><a href=",frankbruder/article/SVGFonts-usage" title="Frank Bruder - SVG Fonts: How To">This page on SVG Fonts</a> explains exhaustively how to use SVG fonts (and how to convert fonts from other formats to SVG). It has great examples of these two methods of using SVG fonts.</p>

<h3>Using SVG Fonts for HTML</h3>

<p>Using the CSS <a href="">@font-face declaration</a>, you can also specify SVG fonts instead of just TTF/EOT/OTF fonts. It looks like only Opera 10 and Safari 4 support SVG fonts in CSS (<a href="" title="Web fonts example">see a demo of SVG Fonts in HTML</a>). There is a <a href="">bug filed for Firefox</a> but no fix yet.</p>

<h3>Why use SVG fonts?</h3>

    <li><em>Universal support:</em> Any conforming SVG viewer will render the text in the SVG font specified.</li>
    <li><em>Store multiple fonts in a single file:</em> You can create a single SVG file with multiple fonts and use the &#8220;id&#8221; of that specific font element to declare which font you want to use in your HTML or SVG document.</li>
    <li><em>Open Source:</em> The font file is completely open. If <a href="">the font you are using is missing glyphs</a> you can add the glyph you need.</li>
    <li><em>Chrome Support:</em> (Thanks for this suggestion <a href="">@paul_irish</a>!) If you use SVG font format in CSS @font-face declaration for HTML/SVG, it will now work on the latest releases of Chrome, Safari, and Opera (though not on Firefox!).</li>

<h3>Disadvantages of SVG fonts</h3>

        <p>The main drawback to SVG fonts is there is no provision for <a href="">font-hinting</a>. The SVG standard states:</p>
        <blockquote cite="">
            <p>SVG fonts contain unhinted font outlines. Because of this, on many implementations there will be limitations regarding the quality and legibility of text in small font sizes. For increased quality and legibility in small font sizes, content creators may want to use an alternate font technology, such as fonts that ship with operating systems or an alternate WebFont format.</p>
<p>SVG support across browsers is still not consistent. The support for SVG fonts in HTML is even worse.</p>

<h3>The Future</h3>

<p>SVG has gained a lot of traction in the recent months. Projects like <a href="">SVG Web</a> can only make the adoption easier. Different browsers support SVG text differently. But, as someone said, these are interesting times for SVG.</p>


    <p class="meta">This post was posted by

<a href="/about.html">Divya Manian</a>


<time datetime="2009-09-19T00:00:00+05:30" pubdate><span class='month'>Sep</span> <span class='day'>19</span> <span class='year'>2009</span></time> in

<span class="categories">
    <a class='category' href='/categories/web-development/'>Web Development</a>

. If you would like to update this post, <a href="">please send a pull request</a>.

    <div id="disqus_thread" aria-live="polite"><noscript>Please enable JavaScript to view the <a href="">comments powered by Disqus.</a></noscript>

  <aside id="articles">
    <p><img class="avatar" src="" height=48> <a href="">Divya Manian</a> lives in SF. <a href="/about.html">More about me ❭</a></p>
    <h2>Posts on Web Development</h2>
    <ul><li><a href="/diversity-in-conferences.html">Diversity in Conferences</a></li><li><a href="/using-decimal-percentage-values-in-responsive-design.html">Using decimal percentage values in responsive design</a></li><li><a href="/using-background-clip-for-text-with-css-fallback.html">Using background clip for text with CSS fallback</a></li><li><a href="/markup-free-icon-fonts-with-unicode-range.html">Markup-free icon fonts using unicode-range</a></li><li><a href="/jscamp-css-next.html">JSCamp: CSS Next</a></li><li><a href="/some-updates.html">Some Updates</a></li><li><a href="/css-object-model.html">CSS Object Model</a></li><li><a href="/fake-bolding-of-web-fonts.html">Fake Bolding of Web Fonts</a></li><li><a href="/html5please-api.html">Html5please API</a></li><li><a href="/html5please.html">html5please</a></li><li><a href="/mustache.html">mustache, hogan, handlebars</a></li><li><a href="/redesign-notes.html">Redesign Notes</a></li><li><a href="/summary-of-various-exciting-css-drafts-and-proposals.html">Summary of various exciting CSS drafts and proposals</a></li><li><a href="/this-revolution-needs-new-revolutionaries.html">This revolution needs new revolutionaries</a></li><li><a href="/some-css-transition-hacks.html">Some CSS Transition hacks</a></li><li><a href="/safe-css-defaults.html">Safe CSS Defaults</a></li><li><a href="/unplugged-2011.html">Unplugged 2011</a></li><li><a href="/bokeh-with-css3-gradients.html">Bokeh with CSS3 Gradients</a></li><li><a href="/making-pure-css3-demos-better.html">Making "Pure CSS3" demos better</a></li><li><a href="/web-opener-at-opera.html">Web Opener at Opera</a></li><li><a class="btn" href="/categories/web-development/">More</a></li></ul>
  <footer role="contentinfo"><p>
  Copy to your heart’s content 2013 - Divya Manian -
  <span class="credit">Powered by <a href="">Octopress</a></span>


<script type="text/javascript">
      var disqus_shortname = 'nimbublog';
      var disqus_developer = 1;
        var disqus_url = '';
        var disqus_identifier = '';
    (function () {
      var dsq = document.createElement('script'); dsq.type = 'text/javascript'; dsq.async = true;
      dsq.src = 'http://' + disqus_shortname + '';
      (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(dsq);

<script src="/javascripts/octopress.js"></script>

    var _gaq=[['_setAccount','UA-97188-1'],['_trackPageview']];
    (function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];

Something went wrong with that request. Please try again.