Create your own icon font and how to use it on websites

I. Basics

There has been many techniques to use vector icons on web sites. From importing bitmap image files (usually transparent PNG’s), to vectorized SVG’s or even using web fonts containing symbols instead of typical characters. All of those have advantages and disadvantages, so the choice is not always easy.

Even though, using non-standard fonts (in general) has became a standard of web development in the recent years. Displaying icons through fonts is the same as using non-standard fonts for titles and paragraphs. Times, where web designers could choose only from 5-10 different fonts, are – luckily – over.

Picons Font

Using icons as web fonts has many advantages:

  • fonts are scalable (no quality loss with different sizes);
  • no need to care about support for Retina displays;
  • easy to apply CSS properties (color, gradient, shadows, etc.) without editing the icon itself;
  • you can use the same icon (shape) in different sizes, colors (saves time and performance);

Nonetheless, icon fonts have also disadvantages. The biggest I see is the unreliable rendering across browsers. The problem can be demonstrated with the following screenshot:

Icon font vs. SVG comparison

The other disadvantage, which is also related to inconsistent rendering, is positioning. It can be tricky to position a tiny icon into center of a circle, so it looks the same in every browser.

If you want to get more deep into this, you can find many articles with pros and cons of using icons as web fonts (Ian Feather’s Article, CSS tricks, SitePoint, etc.).

OK, enough of this. Let’s create an icon font and show how to use it on a website.

II. Creating an icon font

The first thing you need to do is to make your own personal selection of icons. It’s prefered you do that for every project individually, because including all of the icons, even if not used on a project, makes the font file larger. Carrying about loading times is still crucial for the mobile experience.

All Picons icon collections come with included SVG’s of each icon. But, we also have an own icon font with 130 selected icons, if you want to jump the step of creating your own.

There is variety of free and paid tools for creating own fonts. Specialized tools such as icomoon, Fontello, etc. are free and very easy to use. We will show the steps based on comoon’s app.

Step 1: Drag & drop selected SVG’s and create a new set

step1

Step 2: Select all the icons you wish to include in an icon font (you can select them from various sets)

step2

Step 3: Generate the Font

step3

Step 4: Rename all the symbols as you wish and define a unicode character for each (optional)

step4

Step 5: Download the generated file

step5

III. Using the icon font on a website

Your generated icon font consists of various font formats (for cross-browser compatibility) and demo files including HTML and CSS.

Step 1: Copy the CSS code in the included “style.css” to your own CSS file

The included CSS file has a predefined class for each icon, telling your browser which character in the font to use for a specific symbol. You can also apply your own CSS styles to each icon (color, shading, etc…).

Step 2: Copy the folder “fonts” to your website folder

The folder “fonts” includes your generated icon font in different formats (woff, tff, svg, eot). Be sure that the uploaded fonts are linked from the imported CSS. If placed somewhere else than “fonts/”, then correct the link direction accordingly.

@font-face {
 font-family: ‘thin_custom’;
 src:    url('fonts/thin_custom.eot?hpwvww’);
 src:    url('fonts/thin_custom.eot?hpwvww#iefix’) format('embedded-opentype’),
 url('fonts/thin_custom.ttf?hpwvww’) format('truetype’),
 url('fonts/thin_custom.woff?hpwvww’) format('woff’),
 url('fonts/thin_custom.svg?hpwvww#thin_custom’) format('svg’);
 font-weight: normal;
 font-style: normal;
 }

Step 3: Insert the icons

An icon can be inserted with the following HTML code:

<span class=“icon-notebook”></span>

Where the class name “icon-notebook” is generated from the title you gave each icon when creating the icon font. The classes are referred to styling definitions in the included CSS file:

.icon-notebook:before {
 content: “61”;
}

The styling (size, color, hover, etc) can be applied inline (inside the HTML) or to your style.css.

Your feedback (including questions) is always welcome…

Picons as desktop & web font!

Picons Font

We are proud to announce the release of our first Picons Font. We hand picked 130 of our most used icons for you, and made them easy to use on your website through @font-face.

Picons Font - Overview

The bundle includes a desktop font (compatible with Mac & PC) and all @font-face formats (EOT, WOFF, SVG & Base64 Encode CSS). We also included SVGs of every icon so you can create your own individual font.

Available at: Picons.me