Through getting some answers here and some research, I've come across a new approach to implementing icons. Rather than as images or css background, it seems you can approach icons as a font.
Will this method ultimately mean creating a one file font set that has each icon assigned to a character? Because this method is so new to me I really want to sure I approach it correctly first (I see great potential... so much better than creating different icons, exporting each as it's own .png file for every different color and size).
If that's the case, it'll take a bit of memorization (especially since I have over 26 icons). For those more experienced with fontforge, is there a way to say a specific word = character?
Also, in regards to implementing this on the website. I would then need to specify the font type within the css class/id (i.e. font=icons; ). And then I could change the size, color, etc. with css as well? Man, if this really is true. I wish I found out earlier... hours and hours could have been saved.
Anyway, any help with this is greatly appreciated. I'm about to get fontforge and start learning (if there's better free software for font creation, let me know). Hopefully this works out.
Accessibility One major advantage of SVG icons over Icon fonts is their superior accessibility. SVGs are armed with built in semantic elements – like < title > and < desc > that makes it accessible to screen reader and text browsers. Unlike icon fonts, SVGs are treated as an image and not as a text.
Select Encoding > Add Encoding Slots and enter the number of the glyphs you want — in this case, 3. FontForge will add the same number of slots at the very end of the font, and you will be moved there in the font chart.
I've successfully created a few icon fonts for my websites and the Inkscape FontForge approach as outlined in this how-to is pretty solid, and if you're used to using software such as Inkscape, it's also pretty easy too. Here's the steps I take:
I'll often leave this plain SVG document open, pasting in new icons and centering and sizing according to the last. This way there is size and position consistency across the icon set (and you don't have to keep choosing the directory to save your plain SVGs).
Hope that's of help.
Here's an open source example of what you're looking to do:
http://fortawesome.github.com/Font-Awesome/
If you look at their code, you can see how to run the CSS:
https://github.com/FortAwesome/Font-Awesome/blob/master/css/font-awesome.css
And if you want to edit the fonts, download FontAwesome.ttf and edit in FontForge. If you want to do your own TTF, you could, but just take a look and copy how they did it I guess.
(Disclaimer: I haven't done this part of the process. On our team one of the guys uses a proprietary Mac App to come up with the font. If I need to do my own icon fonts in future I'll probably use Inkscape and FontForge though. I've checked enough to see that FontForge can import SVG, I haven't tried it though).
When you're done and you have your TTF font as you want it, you need to convert the font into the many different formats needed to use as a web font. I use this free online tool:
http://fontface.codeandmore.com/
... which will give you your EOT, SVG, TTF and WOFF font files, which should cover you for almost all browsers. You then need to include these files in your CSS, as demonstrated in the file linked above. Note: for the SVG file, there is an ID that you will have to update. I think it is automatically chosen by the conversion tool, so you'll have to edit the SVG, check what the ID is and include it.
For example, in this code:
@font-face { font-family: 'MyIcons'; src: url('myiconfont-iconglyphs.eot'); src: url('myiconfont-iconglyphs.eot#iefix') format('embedded-opentype'), url('myiconfont-iconglyphs.woff') format('woff'), url('myiconfont-iconglyphs.ttf') format('truetype'), url('myiconfont-iconglyphs.svg#myiconfont-regular') format('svg'); font-weight: normal; font-style: normal; }
You may have to change the #myiconfont-regular
bit after the svg definition.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With