Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Why arent people using SVG for this sort of thing? Isnt that HTML5's vector graphics format?

I supose if you're using icons w/ the express purpose of using them with in-line text, then this would be Ideal... but just seems like a weird hack, when there is SVG available...

The author of this website claims to simply be ignorant of SVG at the bottom? whats up with that?

Why is using a font "hack" better than using the intended container for vector graphics?

I guess web design has always sorta been about pushing the bounderies of browser quirks, but I kinda thought we were moving away from that. You would think the intended use of vector graphics would be designed to be just as good if not better than using a font to do the same thing.



> Why arent people using SVG for this sort of thing? Isnt that HTML5's vector graphics format?

1. SVG is slow, text layout engines (therefore fonts) are fast

2. SVG support is pretty terrible (not available on Android < 3, IE <= 8 and that's for support at all, inline-svg-in-HTML is even rarer and it's even easier to hit shitty implementation bugs), fonts are very well supported

3. I don't think you can use SVG in pure CSS, so you need markup, not so with fonts (theoretically you can use SVG as background, practically I'm sure it works half the time best)

4. You can't hint SVG, so it does not scale well from big to small resolutions

5. Mixing SVG and HTML text is absolutely awful, mixing text in an iconic font and actual text is much easier

6. Iconic fonts are trivially "sprited" (bundle all the icons in a single font file), this is more complex in SVG

7. Changing the color of an iconic font to match a new or alternative layout takes all of a single CSS property, likewise to change font (therefore the style of all the iconset) (this assumes the iconsets use the same characters as hooks for equivalent symbols).

> You would think the intended use of vector graphics would be designed to be just as good if not better than using a font to do the same thing.

You would, wouldn't you? But it turns out fonts are very, very good vector formats for (physical) rendering sizes.


You make valid points, but some don't convince me:

1. For non-animated icons with few shapes it doesn't matter. SVG performance has come a long way — I've used SVG charts with 3000 nodes and it worked smoothly zoomed in on the 2048px iPad.

Also, rendering of individual font glyphs is not necessarily faster. Hinted subpixel rendering costs, and text rendering engines rely on speed savings from caching prepredered glyphs.

3. Possible, but admittedly ugly with `url(data:text/svg,…)` in CSS.

4. I bet those icon fonts don't have hinting either, and autohinting designed for letters may deform icons.

5. You can reference external SVG files or put SVG in CSS.

7. SVG is styleable with CSS (although CSS internal to the file), so you have even more options for styling icons (e.g. you can have separate colors for fill and stroke or even each part of the icon).


Isn't the argument more that SVG sucks, rather than that there is anything fundamentally wrong with vector graphics?


Absolutely (hence my responding to why SVG is not used for this), fonts are vector graphics after all.


I don't think you've used svg before. It definitely does not suck.


No, I defiantly have, and it does. For a standard 13 years in the making, the number of decent FULL FEATURED implementations is minuscule. Stuff that mostly works likes Inkscape tends to use it's own dialect and not fully support all the features.


I agree with you that browser support sucks. the technology itself is really cool though. Scriptable, heirarchy based vectors. What's not to like?


There was an article posted here 1 day ago that explored to great lengths why SVG for scalable icons sounds good in theory - but does not work well in practice. And why icon fonts are the way to go for now. See here: http://www.pushing-pixels.org/2011/11/04/about-those-vector-...

Key point: SVG icons don't actually scale that well because SVG lacks hinting.


No, the point of that piece was not that icon fonts are the way to go. It was that one vector icon can't just be rendered at different resolutions without changing the level of detail, and most icon designers use vectors to render their large sizes, but often resort to manual bitmap pixel pushing at smaller sizes to get the look they want.

The key point is that you need to design different vectors or bitmaps for different actual rendered sizes, with different levels of detail, and one design will never be suitable for all sizes.


Pixel hinting. The desired icons in this case are small ubiquitous monochrome glyphs. Text fonts and font renderers have already optimized that specific use-case tremendously - so why not plug into that.


On the other hand implementing pixel hinting of some shape in a font is quite likely equally hard then writing a JS generator of optimized SVG. Yet rendering speed may be a problem.


IE8 and Android 2.4 don't support it for one, but it does seem SVG has never really had traction. I've heard SVG has poorer rendering performance in most browsers (I'm not actually sure if that's true), and that some folks feel it makes it easier for their assets to be copied.


SVG is gaining traction, eg through use of d3.js. svgweb can work as an IE shim. Old Android is a problem, but on the other side Microsoft are doing a good job and pushing SVG in IE9+.


That has always confused me a bit. It seems that most of the stuff that people are doing with canvas requires writing a vector graphics layers on top of it anyway.


SVG would be wonderful if it were not for the lack of native support early on in browser land. That skips over the none trivial problem of what it takes to create a symbol/glyph in SVG. Not only do you have to be a competent typographer, but you also have to be a programmer (SVG is very Postscript like). Yet more barriers to widespread use. None of this is fatal, but like speed-bumps, it certainly slows things down. I'm in general more happy adopting a widely used Unicode font for the things that I need in this category. Your mileage may vary.


Why would you need to be a programmer to make a SVG symbol/glyph? All vector-drawing programs can export it these days. I think creating a font is more difficult.

Having said that, fonts do have some properties that can be advantageous for black-and-white icons; for example, automatically coloring with the text color and style.


I'm not all that great at webdesign but I couldn't seem to implement this in CSS. Any suggestions in doing something similar with SVG?


The main advantages are listed on the page. Being able to apply CSS styles is the biggest one.


you can apply css to svg




Consider applying for YC's Fall 2026 batch! Applications are open till July 27.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: