Icon Fonts vs. SVGs: An Ultimate Guide to Accessible Web Icons
Tags: emoji, css, webdev, a11y
Published: 2019-07-07 13:20:03


<h2>Preface</h2>

<p>
Many web designers and developers today are putting SVG <!-- <abbr title="Scalable Vector Graphics">SVG</abbr> --> as an alternative to font technology used to represent icons in the web world. To what extent is this decision wise and correct?
</p>

<p>
This is what this article is trying to answer.
</p>

<p>
First, in this study we proceed from two hypotheses:
</p>

<ul>
<li>Browser or screen reader does not have any errors or limitations: All recommended standards are supported and error-free, and screen reader is capable of reading all Unicode characters properly, and any bug or aspect of failure in either of them is a responsibility of their developers.</li>
<li>What concerns us here are the solutions that deal with icons as properties displayed by CSS instructions, not as objects being called by HTML tags, such as <code>&lt;img&gt;</code>, <code>&lt;object&gt;</code> or <code>&lt;svg&gt;</code>, etc, since icons are not part of the content, they are part of the reusable resources and software components, so care should be taken to be requested from the server only once. Those CSS properties are usually either <code>background</code> property or <code>content</code> property, and we exclude the first of them because it is a presentation attribute that does not have any semantic meaning —so it is not accessible— first, and it is unlikely to appear when printing second. The only remaining property we have is <code>content</code>.</li>
</ul>

<h2>Glossary</h2>

<dl>

<dt id="accessibility">Accessibility</dt>

<dd>

<p>
For icons, it means the ability to express the icon with a semantic string that is significant to the nature of the icon and its function. In Unicode symbols, the semantic text is the description assigned to the character in the official Unicode blocks. In SVG files, it can be the <a href="#fragment-identifier">Fragment Identifiers</a> in a <a href="#spritesheet">Spritesheet</a>, or the <code>&lt;title&gt;</code> tag in a single SVG file.
</p>

<p>
The accessibility of icon helps users with special needs (visual disability in particular) identify and demonstrate the content of the icon using software called <q>screen readers</q> dedicated for this category of users. This also helps search engines understand the meaning and semantic of the icon, which makes semantic a very important issue —as is known— for webmasters.
</p>

<p>
You can imagine search engines as a category of users with special needs, but their requirements belong to the category of developer requirements, not the user ones in practice, because a search engine is not a human user, and there is nothing obliges you to meet its requirements other than your keen on attracting real and end users to your site.
</p>

<p>
<a href="#scalability">Scalability</a> is another aspect of icon accessibility, helping users with special needs (visually impaired people in particular) see icons at a larger size.
</p>

<figure id="web-accessibility-model">
<img src="https://richstyle.org/media/a11y-model.png"
	alt="A simplified model for Web Accessibility"
	title="Web Accessibility Model" />
<figcaption>Web Accessibility Model<br/><a href="https://richstyle.org/media/a11y-model-icon-credits.png">[Icon credits]</a></figcaption>
</figure>

</dd>

<dt id="code-point">Code Point</dt>

<dd>

<p>
Any value in the Unicode codespace; that is, the range of integers from <code>0</code> to <code>10FFFF</code><sub>hex</sub> (i.e. in Hexadecimal Numerical System). It’s an atomic unit of a textual string.
</p>

<p>
Not all code points are assigned to encoded characters necessarily. Rather, there are seven fundamental classes of code points in Unicode standards: </p>

<ol>
<li>Graphic (the most popular usage): a code point stores a glyph, which is a visual representation of a character (characters like letter, number, punctuation mark, or pictograph).</li>
<li>Format.</li>
<li>Control.</li>
<li>Private-Use.</li>
<li>Surrogate.</li>
<li>Noncharacter.</li>
<li>Reserved.</li>
</ol>

<figure id="glyphs-in-code-points">
<img src="https://richstyle.org/media/glyphs-in-code-points.png"
	alt="Glyphs in Code Points: Liberation Sans font vs. Liberation Serif font." />
<figcaption>The main different between a font and another: different glyphs in the same code point.</figcaption>
</figure>

</dd>

<dt id="emoji">Emoji</dt>

<dd>

<p>
A symbol formally encoded (indexed) in Unicode standard. It’s typically colorful. Its plural form could be <em>emoji</em> or <em>emojis</em>. However, Unicode Consortium uses <em>emoji</em> as plural.
</p>

<p>
An emoji could be an emotional expression, a verb, an object, or even an abstract symbol.
</p>

<p>
The following table shows a brief history of emoji.
</p>

<table id="brief-history-of-emoji">
<caption>A brief history of emoji</caption>
<thead>
<tr>
	<th>Portmanteau</th>
	<th>Roots</th>
	<th>Meaning</th>
	<th>Description</th>
	<th>Inventor</th>
	<th>Year</th>
	<th>Example</th>
	<!-- <th>Note</th> -->
</tr>
</thead>
<tbody>
<tr id="emoticon">
	<th>Emoticon</th>
	<td>emot + icon</td>
	<td>emotion + icon</td>
	<td>Vertical emotional symbol typed using a combination of regular keyboard characters.</td>
	<td>Scott Fahlman</td>
	<td>1982</td>
	<td>:-)</td>
	<!-- <td>Emoticons actually originated on the PLATO IV computer system in 1972.</td> -->
</tr>
<tr id="kaomoji">
	<th>Kaomoji</th>
	<td>kao + moji</td>
	<td>face + character</td>
	<td>Horizontal emotional symbol typed using a combination of regular keyboard characters.</td>
	<td>Kim Tong Ho</td>
	<td>1986</td>
	<td>^_^</td>
	<!-- <td>Kim Tong Ho <a href="https://groups.google.com/forum/#!msg/fj.questions.misc/-6DJXmcI13c/JIc3AWmvmlcJ">attributed</a> this innovation to himself, but some believe he does not have enough proof of his claim.</td> -->
</tr>
<tr id="pictograph">
	<th>Pictograph</th>
	<td></td>
	<td></td>
	<td>Symbol formally encoded (indexed) in Unicode standard.</td>
	<td></td>
	<td>1993</td>
	<td>☺</td>
	<!-- <td>At the time, there was only a few pictographs when Unicode 1.1 was released.</td> -->
</tr>
<tr>
	<th>Emoji</th>
	<td>e + moji</td>
	<td>picture + character</td>
	<td>Colorful version of a <a href="#pictograph">pictograph</a>.</td>
	<td>Shigetaka Kurita</td>
	<td>1999</td>
	<td><!-- 🙂 --><img alt="🙂" title="🙂" src="https://richstyle.org/media/smile.svg" /></td>
	<!-- <td>Emoji weren’t encoded (indexed in Unicode tables) at the time. Rather, they have formally encoded as Emoji as of 2010, when Unicode 6.0 was released.</td> -->
</tr>
</tbody>
</table>

<p>
Additional notes:
</p>

<ul>
<li><em>Emoticons</em> actually originated on the PLATO IV computer system in 1972.</li>
<li><em>Kaomoji</em>: Kim Tong Ho <a href="https://groups.google.com/forum/#!msg/fj.questions.misc/-6DJXmcI13c/JIc3AWmvmlcJ">attributed</a> this innovation to himself, but some believe he does not have enough proof of his claim.</li>
<li><em>Pictograph</em>: At the time, i.e. in 1993, there was only a few pictographs when Unicode 1.1 was released.</li>
<li><em>Emoji</em> weren’t encoded (indexed in Unicode tables) at the time. Rather, they have formally encoded as Emoji as of 2010, when Unicode 6.0 was released.</li>
</ul>

</dd>

<dt id="fragment-identifier">Fragment Identifier</dt>

<dd>

<p>
A text string inside an SVG <a href="#spritesheet">spritesheet</a>, used to uniquely identify a part of the total image (sub-image).
</p>

<p>
Fragment identifier in SVGs is either the <code>&lt;view&gt;</code> tag or the <code>ID</code> property or both.
</p>

</dd>

<dt id="maintainability">Maintainability</dt>

<dd>

<p>
In this context, we mean the ability to edit code using a simple text editor or simple image editor, without a need for additional software and tools.
</p>

</dd>

<dt id="performance">Performance</dt>

<dd>

<p>
In this context, we mean fewer HTTP requests when loading icons. In practice, the ideal performance is to limit the process of calling icons to a single HTTP request.
</p>

</dd>

<dt id="pua">Private Use Area (PUA)</dt>

<dd>

<p>
One of the Unicode tables, located in the range <code>U+E000-F8FF</code>. It is intended to allow font developers to insert non-standard characters.
</p>

<p>
There are also two other tables for the same purpose:
</p>

<ul>
<li>Supplementary Private Use Area - A, located in the range <code>U+E0000-FFFFF</code>.</li>
<li>Supplementary Private Use Area - B, located in the range <code>U+100000-10FFFF</code>.</li>
</ul>

</dd>

<dt id="replacement-glyph">Replacement Glyph</dt>

<dd>

<blockquote>

<p>
A glyph used to render a character that cannot be rendered with the correct appearance in a particular font. It often is shown as an open or black rectangle. Also known as a missing glyph.
</p>

<!--
<p>
See <a href="http://www.unicode.org/versions/Unicode11.0.0/ch05.pdf#G7730">Section 5.3, Unknown and Missing Characters</a>.
</p>
-->

<cite><a href="http://unicode.org/glossary/#replacement_glyph">Unicode Glossary</a></cite>

</blockquote>

</dd>

<dt id="resizibility">Resizibility</dt>

<dd>

<p>
In the context of this article, we mean the ability to change an image size by:
</p>

<ul>
<li>Nature: i.e. <a href="#scalability">Scalability</a>.</li>
<li>Ability to control its size through CSS instructions (mainly <code>width</code> and <code>height</code>).</li>
</ul>

</dd>

<dt id="scalability">Scalability</dt>

<dd>

<p>
The ability to zoom-in an image without being distorted. It’s one of the aspects of <a href="#accessibility">icon accessibility</a>.
</p>

</dd>

<dt id="spritesheet">Spritesheet</dt>

<dd>

<p>
An image file represents a container for a set of images stacked side by side, forming a single image grouped from a set of images.
</p>

<p>
This image can be bitmap, in PNG, JPG, or GIF format, or vector; in SVG format, but most of the spritesheet images are bitmap.
</p>

<figure>
<img src="https://richstyle.org/media/google-icons.png" alt="Screenshot of the old Google icons file as a spritesheet." />
<figcaption>The old Google icons grouped into a single image file in PNG format</figcaption>
</figure>

</dd>

<dt id="svg-container">SVG Container</dt>

<dd>

<p>
Any file format allows storing a set of SVG icons and graphics in a single file.
</p>

</dd>

</dl>

<h2>Historical Overview</h2>

<p>
There are two categories of solutions for representing icons on the web:
</p>

<h3>The Old Solutions: Raster Images</h3>

<p>
Some of the most common formats are PNG, JPG, GIF, and recently WebP format. The main disadvantage of this type of image is that it is fixed in size and can not be zoomed-in without deformation. This type of image can be used in two ways:
</p>

<ul>
<li>Each icon is in a file: an abandoned method, probably only used in the early days of the Internet, because it requires multiple HTTP requests: a request for each image (icon). The address of each icon here depends on its name, which is in the interest of both user (<a href="#accessibility">accessibility</a> for users with special needs) and developer (<a href="#maintainability">maintainability</a>, and <a href="#accessibility">accessibility</a> for search engines).</li>
<li>All the icons are stacked side by side in a single file (<a href="#spritesheet">spritesheet</a>): Each icon’s address is determined by selecting a space from the total area of ​​the image file as much as the desired-icon space and position, and cropping it by specific instructions written in CSS, to be displayed cropped (truncated) in the browser. The result is a single HTTP request for all the icons. And since it —unlike the first method— relies on arithmetic instructions (CSS instructions) to access the desired icon instead of a specific semantic name, it suffers —in contrast to the first method too— from the difficulty of maintenance (for developer) and difficulty in accessibility (for users with special needs, and for search engines).</li>
</ul>

<h3>The Current Solutions: Vector Images</h3>

<p>
These images are <a href="#scalability">scalable</a>, and have two main formats:
</p>

<ul>
<li>Fonts: Icons are stored here in a single file too, but it’s not an image file, it’s a font file, TTF or other common font-formats, so that each icon occupies a character (or rather: a <a href="#code-point">code point</a>) in it. In this method, icon can be called (encoded and requested) in an <em>engineering</em> rather than <em>artistic</em> way by just typing the character in the CSS code. This method shares the first old method with <a href="#maintainability">maintainability</a> and <a href="#accessibility">accessibility</a>, and the second old method with <a href="#performance">performance</a>, because of its relying on a one HTTP request for icons at once; a feature that has been and remains the secret behind the spreading and popularity of this solution in the world of the web until the present day, but it:
<ul>
<li>Also <a href="#scalability">scalable</a>: i.e. has the ability to zoom-in images (icons) without losing its smoothness.</li>
<li>And is limited —until recently— in the ability to colorize (multicolor in a single icon). But that has changed now, and color fonts have become a reality. You can now see Firefox support in its recent versions for this type of font by previewing <a href="https://color.typekit.com/">Color.TypeKit.com</a>.</li>
</ul>
</li>
<li>SVG format: Allows you to use multi-color and scalable icons at the same time.<br/>
The issue of providing SVG icons together in a single file (which we will call it here <a href="#svg-container">SVG containers</a>), similar to the old second solution (one bitmap) or the first current solution (fonts), in order to avoid multiple HTTP requests, is an issue that is possible, but the problem is that these solutions vary in terms of advantages and disadvantages, and we will discuss each in detail later on.</li>
</ul>
</li>
</ul>

<p>
No doubt, we will rule out the category of the old solutions that based on raster (fixed bitmap) images. Our study is limited to the second category of the solutions: the current solutions that better meet <a href="#accessibility">accessibility</a> requirements, represented by fonts and <a href="#svg-container">SVG containers</a>.
</p>

<h2>Icon Categories</h2>

<p>
Before going into the available solutions and balancing between them, let’s try to sort icons and symbols currently circulating in the web world, according to the characteristics and features they have, and the functions they perform.
</p>

<p>
Functionally, icons can be divided into three categories:
</p>

<ul>
<li>UI Icons: These are the familiar icons in any digital platform to express a specific object, function, or state within the system, such as the bent-paper icon, which expresses files, the scissors icon that expresses <strong>Cut</strong> function, and the triangle warning icon indicating a danger state or a warning message.</li>
<li>Commercial logos: Like Facebook, Twitter, Android, Windows, and Apple, etc.</li>
<li>Countries’ flags.</li>
</ul>

<p>
In terms of characteristics and features, we are concerned with two factors:
</p>

<ul>
<li>Standardization: the extent to which these symbols are fit for Unicode support, not necessarily the actual support they currently have.<br/>
This fitness is related to the extent of the code’s popularity and its continued use.
</li>
<li>The extent to which they need for multicolor: i.e., do these symbols require, by their nature, more than one color, or is one color enough to express it?</li>
</ul>

<p>
Consequently, icon categories can be categorized as follows:
</p>

<table class="fixedTable" id="icon-categories">
<caption>Categories of web icons</caption>
<thead>
<tr>
	<th></th>
	<th>Standardization</th>
	<th>Multi-color</th>
</tr>
</thead>
<tbody>
<tr>
	<td>UI icons</td>
	<td>✓</td>
	<td>✕</td>
</tr>
<tr>
	<td>Commercial logos</td>
	<td>✕</td>
	<td>✓</td>
</tr>
<tr>
	<td>Countries’ flags</td>
	<td>✓</td>
	<td>✓</td>
</tr>
</tbody>
</table>

<p>
Commercial logos, contrary to UI icons and the Countries’ flags, are subject to what commercial organizations behind them are subject to, such as change, modify, rise, fall and merge, they should not be included in Unicode blocks.
</p>

<p>
On the other hand, the first category (UI icons category) remains the only category in which the designer has the freedom to color or not, whilst commercial logos and countries’ flags do not give developer in principle freedom to step in their design or modify any of them, yet he/she stay subject to the will of the original designer of the logo or the flag.
</p>

<p>
The representation of country flags by Unicode characters is usually done by using ISO-3166 country codes, such as US symbol for the United States, and DE symbol for Germany, etc, but using Regional Indicator Symbol Letters rather than the regular ASCII characters, which is within the range <code>U+1F1E6-1F1FF</code>, so the United States symbol is indicated by 🇺🇸, Germany’s one by 🇩🇪… and so on. As to how these symbols can be turned into Countries’ flags, we will talk about this later.
</p>

<figure id="regional-indicator-symbol-letters">
<img src="https://richstyle.org/media/regional-indicator-symbol-letters.png"
	alt="Screenshot of GNOME Character Map for Regional Indicator Symbol Letters"
	title="Regional Indicator Symbol Letters" />
<figcaption>Regional Indicator Symbol Letters</figcaption>
</figure>

<p>
For a perfect preview of the way flags are displayed in this way, use a recent version of Firefox to browse the following page:
<a href="https://color.typekit.com/#flags">Color.TypeKit.com/#Flags</a>.
</p>

<p class="msg-warning">
If Noto Emoji font is installed on your device, you will notice that the United States and Germany symbols have already been converted to the corresponding flag images, but without coloring. If Noto Color Emoji font is installed, the flags will appear colored (using Firefox until the moment of this writing). Noto Emoji and Noto Color Emoji fonts use the <a href="#ligatures">ligatures</a> technique that we will discuss later.
</p>

<h2>Fonts Technique</h2>

<p>
Critics of the use of fonts to represent icons argue that it is just a trick that does not live up to standard practice, and a sufficient evidence for us here is the propagation of <a href="#replacement-glyph">blank-rectangles</a> phenomenon when waiting for a font to load or failure to load it.
</p>

<figure>
<img src="https://richstyle.org/media/blank-rectangles-in-twitter.png"
	alt="Blank-rectangles in Twitter log-in screen." />
<figcaption>Blank-rectangles phenomenon before a web-page loading is completed.</figcaption>
</figure>

<p>
They had all the right before <a href="#emoji">Emoji</a> emerged and supported increasingly by Unicode standard. Today, it is enough for a designer to be careful to use the correct characters in the font used, according to Unicode standard, to ensure the match between the icons at the server-side, and their equivalents at the client-side.
</p>

<figure>
<img src="https://richstyle.org/media/noto-emoji-and-unifont-fonts.png"
	alt="A web page uses icons from Noto Emoji and UniFont fonts." />
<figcaption>Local icons (before downloading RichStyle font from the server)</figcaption>
</figure>

<figure>
<img src="https://richstyle.org/media/richstyle-font.png"
	alt="The same web page uses icons of RichStyle font." />
<figcaption>Server-side icons (RichStyle font)</figcaption>
</figure>

<p>
The client-side environment may involve a font representing these icons even before the font is loaded by the server or when it fails to load.
</p>

<p>
If a font such as Symbola, Noto Emoji, or Unifont, is pre-installed on user’s device, then the icons installed on his or her device will show to him/her first, pending the download of the required font from the server, just like when showing a web page using a local font pending the loading of the custom font (the site’s font) from the server.
</p>

<p>
However, modern browsers are preventing —by their default behavior— the emergence of local fonts as fallback fonts in such a case, as some view this behavior as hijacking the user experience and distort —albeit temporarily— the image of the page being loaded, while others —including me— view the emergence of readable text, using any font whatsoever, as better than nothing.
</p>

<p>
Designers express the first case, which prevents any font from appearing before the custom font is loaded, with the term “Flash of Invisible Text” or FOIT, and express the second case, which shows a fallback font before the custom font is loaded, with the term “Flash of Unstyled Text” or FOUT. The following video shows the difference between the two cases in a live show.
</p>

<figure>
<video src="https://richstyle.org/media/FOIT-vs-FOUT.mp4"
	alt="FOIT vs. FOUT"
	width="640" height="360" controls="controls" />
<figcaption>FOIT vs. FOUT</figcaption>
</figure>

<p>
We say “by their default behavior” because CSS standards became allowing you now to modify and override this behavior. You can see the details of <code>font-display</code> property assigned to this task on <a href="https://css-tricks.com/almanac/properties/f/font-display/">font-display | CSS-Tricks</a>.
</p>

<p>
Perhaps the next illustration of <a href="https://meowni.ca/">Monica Dinculescu</a> is the best representation of the values of <code>font-display</code> property and the behavior of these values across timeline.
</p>

<figure>
<a href="https://speakerdeck.com/notwaldorf/fontastic-web-performance?slide=74">
<img src="https://richstyle.org/media/css-font-display-values.png"
	alt="A graph showing the values of `font-display` property and the behavior of these values across the timeline." />
</a>
<figcaption><code>font-display</code> values</figcaption>
</figure>

<p>
In short, I think the best option to load icon fonts committed to Unicode standards is the value <code>fallback</code> as shown below.
</p>


<pre>
@font-face {
	font-family: &#39;RichStyle&#39;;
	src: …;
	font-display: fallback;
}
</pre>

<p>
The <code>fallback</code> option allows you to temporarily block the fallback font —if any in the user’s computer— in the hope that the custom font will appear directly without going through the temporary deformation phase of the page design that the fallback font may cause, until the custom-font load is complete and appears in the folds of the page.
</p>

<p>
This option represents a compromise between FOIT and FOUT.
</p>

<p>
This matching also guarantees excellent <a href="#accessibility">accessibility</a> for icons, which means the ability to express and access these icons and symbols and their semantics using meaningful standard characters, rather than the graphical dimensions of <a href="#spritesheet">spritesheets</a>, which will not allow search engine or screen reader to extract any semantic data out of it.
</p>

<p>
As we are talking here about a solution that was not allow multicolor until recently, it is an acceptable solution for the first category of icons: UI icons.
</p>

<p>
Yes; designer does not have to use colors here, i.e. in UI icons, but what about user? What is his or her point of view: Should icons be monochromatic or multicolored?
</p>

<p>
We may not have a statistical answer to that now, but from our point of view; monochrome icons are better.
</p>

<p>
In details, these icons became, day by day, and by experience and practice, an <em>alphabet</em>, like any other alphabet, which is meant to be used for practical fleeting reading, not to meditate and enjoy, but it is a picture alphabet, such as hieroglyphic alphabet and other picture-based alphabets, which relied on drawings and images in their codification, which prevailed in ancient times and then destroyed, but what revived it again are two factors:
</p>

<ul>
<li>Speed: the need to express system’s procedures, objects and states in a faster way to read than the textual expression that depends on a string of characters, because seeing a drawing of a bird, for example is faster to receive and access the user’s brain than reading the word “bird”, a picture is worth a thousand words. Imagine how traffic would be on roads if the sidewalks were full of textual plates instead of traffic signs of the day!</li>
<li>Globalization (breaking the language barrier): the need to express in a global way beyond the language barrier, which varies from one geographical area to another around the world. The beginnings of the return to the illustrated alphabet may be traced back to the corridors of airports, where an urgent need for a unified language of communication was emerging in an environment full of people from different languages.</li>
</ul>

<figure>
<img src="https://richstyle.org/media/airport-signs.jpg"
	alt="A photo for a board of symbols in a corridor of an airport." />
<figcaption>The language of symbols in airports</figcaption>
</figure>

<p>
Otto Neurath of Vienna from 1920 to 1940 tried to develop a visual language called IsoTypes, in an attempt to revive pictographic symbols again, but it was not popular or successful, and perhaps the reason for its non-commonness at the time is that its use at the level of individuals requires considerable skills in manual drawing, at a time when digital platforms have not yet been emerged. These symbols will only serve then for mass communication, i.e. through traditional mass media of the time, such as road advertising, newspapers, print, television and cinema, since writing down character was then still faster for individuals than drawing.
</p>

<p>
Today, the attempt is repeated through <a href="#emoji">Emoji</a>, but with great success, because digital environment has turned the equation upside down: printing graphics on screen today is faster than writing words!
</p>

<p>
Although Unicode Consortium does not see Emoji as a new language, he pictographic alphabet today taught us that:
</p>

<ul>
<li>When I see a drawing of scissors on screen, I realize that I’m in front of a button performs <strong>Cut</strong> function.</li>
<li>When I see a drawing for two consecutive papers, I understand that I am in front of a button performs <strong>Copy</strong> function.</li>
<li>When I see a musical note, I understand that I am in front of an audio file.</li>
<li>When I see a video camera, I understand that I am in front of a video file.</li>
</ul>

<p>
And so on.
</p>

<p>
This is about UI icons, but does that apply to commercial logos and countries’ flags as well?
</p>

<p>
Initially no, this:
</p>

<ul>
<li>Due to the lack of multi-color feature in fonts until recently, as indicated at the beginning of our research, and therefore lack of tools to produce this type of fonts currently, which means —according to the criteria of this study— lack of <a href="#maintainability">maintainability</a>.</li>
<li>No Unicode support for commercial logos, as we indicated at the beginning of our research as well.</li>
</ul>

<p>
However, these two problems can be worked around in commercial logos as follows:
</p>

<h3 id="ligatures">Ligatures</h3>

<p>
Ligature is a character property within the font that allows that character to be called within a text using a set of other characters.
</p>

<p>

The simplest example would be to assign the value <code>:)</code> to the Ligatures property of the smiley character (☺ <code>U+263A WHITE SMILING FACE</code>) within a specific font; this will convert that string <code>:)</code>, once it is received in the context of a specific text uses that font, to smiley character automatically.
</p>

<figure>
<img src="https://richstyle.org/media/ligatures-smile.png"
	alt="COLON + RIGHT PARENTHESIS + WHITE SMILING FACE"
/>
<figcaption>The Ligatures feature can be used to replace the string :) with the smile symbol</figcaption>
</figure>

<p>
Ligatures are usually used to represent the special combinations of certain characters when they meet together, for example, the convergence of f and i characters in serif fonts, where they are connected as you see in the image below.
</p>

<figure>
<img src="https://richstyle.org/media/ligatures-fi.png"
	alt="LATIN SMALL LETTER F + LATIN SMALL LETTER I + LATIN SMALL LIGATURE FI" />
<figcaption>The character LATIN SMALL LIGATURE FI (its <a href="#code-point">code point</a> is: <code>U+FB01</code>) is used to join the letters f and i in a single glyph</figcaption>
</figure>

<figure>
<img src="https://richstyle.org/media/ligatures-in-fontforge.png"
	alt="A screenshot of FontForge for the LATIN SMALL LIGATURE FI character (code point: `U+FB01`) in Noto Serif font." />
<figcaption>Noto Serif font uses the ligatures feature to join the letters f and i in a single glyph</figcaption>
</figure>

<p>
Arabic fonts are very expansive in using this feature. These are examples of <a href="https://richstyle.org/?reviews/arabic-calligraphy-in-computing-era-ar#arabic-ligatures" title="Using Ligatures in Arabic Characters">using ligatures in Arabic characters</a>.
</p>

<p>
This technique is useful for commercial logos as follows:
</p>

<ul>
<li>Place the logo symbol you want, for example, the WordPress logo, under the <a href="#pua">Private Use Area</a> (range: <code>U+E000-F8FF</code>) so that it does not compete the systematically-reserved characters.</li>
<li>Set the value “wordpress” for the Ligature property of that character.</li>
</ul>

<!--<p>
[Fontforge Screenshot]
</p>-->

<p>
Then, when using the following CSS code:
</p>

<pre>
.wordpress-blog:before {
	content: &#39;wordpress&#39;;
}
</pre>

<p>
The phrase “wordpress” will not appear on the screen, but rather the WordPress logo.
</p>

<p>
Thus we have been able to represent a commercial logo that does not have a regular <a href="#code-point">code point</a> in Unicode blocks, without <em>robbing</em> the characters of others and causing a state of conflict between the characters first, and through a semantic string for people with special needs and for search engines secondly.
</p>

<p>
If the browser fails to load the font, the ligature (the phrase “wordpress” in our example) will appear instead of <a href="#replacement-glyph">blank-rectangles</a>.
</p>

<!--<p>
[صورة لحل التضارب]
</p>-->

<p>
However, the appearance of ligature phrases can also be circumvented by trying to match the logo and what may be corresponding or express with among symbols in Unicode tables. For example:
</p>

<ul>
<li>Inserting Apple™ logo into Apple’s <a href="#code-point">code point</a> (<code>U+1F34E RED APPLE</code> or <code>U+1F34F GREEN APPLE</code>).</li>
<li>Inserting Linux logo (penguin) into Penguin’s code point (<code>U+1F427 PENGUIN</code>).</li>
<li>Inserting Twitter logo into Bird’s code point (<code>U+1F426 BIRD</code>).</li>
</ul>

<p>
And so on.
</p>

<p>
You will then be able to use the ligature phrase or the original code in the CSS code. Either write:
</p>

<pre>
.twitter:before {
	content: &#39;twitter&#39;;
}
</pre>

<p>
Or write:
</p>

<pre>
.twitter:before {
	content: &#39;🐦&#39;;
}
</pre>

<p>
However, using the original code would mean to some extent a loss of the icon’s accessibility. Instead of a screen reader reading —for example— Twitter icon as “Twitter”, it would read it as “Bird”.
</p>

<p>
Generally, you have now —as a developer— a logo that can be called programmatically using a text that is easily readable and modifiable by the standard QWERTY keyboard instead of dealing with a unicode character that is not common nor accessible through that keyboard, with showing an expressive string (the ligature phrase) or a symbol similar to the original one and is expressive to some extent, as a fallback if the browser fails to load the font.
</p>

<p>
Finally, there are two very important notes with regard to Ligatures technique:
</p>

<ul>
<li>The characters you use in the ligature phrase should be available within the font itself. Of course, what is needed here is the character’s <a href="#code-point">code point</a> (its code and cell); not the glyph (its image). Yet it is also recommended to leave the character’s <a href="#code-point">code point</a> blank to save the font size as long as we speak of a font dedicated for icons only, and you will probably not need more than the basic Latin characters and numbers.</li>
<li>Ligatures are case-sensitive.</li>
</ul>

<h3>Flat Design</h3>

<p>
On the issue of multicolor, It’s noted that many commercial and non-commercial organizations behind these brands have proceeded to adopt the principle of Flat Design, in line with the current trending artistic taste these days, using one single flat (gradient-free) color in their logos, which also serves the interests of traditional-icon-fonts (non-colored) fans.
</p>

<p>
If there is at least one multicolored logo, there is no escape from using:
</p>

<ul>
<li>Color fonts,</li>
<li>Or <a href="#svg-container">SVG containers</a> to represent them, i.e. to represent colored logos, while the traditional (non-colored) font remains as a store for colorless icons.</li>
</ul>

<h2>SVG Containers: The Theory</h2>

<p>
<a href="#svg-container">SVG containers</a> include the following options:
</p>

<h3>SVGs in SVG Method</h3>


<ul>
<li>SVG <a href="#spritesheet">Spritesheet</a> (viewbox)
<pre>content: url(&#39;brands-sprite.svg#svgView(viewBox(100,0,100,100))&#39;);</pre>
</li>
<li>SVG Spritesheet (predefined views)
<pre>content: url(&#39;brands-sprite.svg#Linux-view&#39;);</pre>
</li>
<li>SVG Stack
<pre>content: url(&#39;brands-stack.svg#Linux&#39;);</pre>
</li>
</ul>

<p>
You can see live examples of this method on <a href="http://betravis.github.io/icon-methods/">Icon Methods</a> page.
</p>

<h3>SVGs in CSS Method (Using DataURL)</h3>

<ul>
<li>DataURL as base64:
<pre>content: url(data:image;base64, PD94bWwgdmVyc2lvbj…);</pre>
</li>
<li>DataURL as XML (as is):
<pre>content: url(&#39;data:image/svg+xml;charset=utf8, &lt;svg … /&gt;&lt;/svg&gt;&#39;);</pre>
</li>
</ul>

<h3>Comparison of The Two Methods</h3>

<p>
We exclude the first two spritesheet options; viewbox and predefined views in the first method, due to the difficulty of maintaining them, which due —in turn— to the difficulty of stacking icons in a single file. The SVG Stack option is worth a try, although the resulting SVG file will not be show-able through regular images viewers.
</p>

<p>
The main common disadvantage of all options of the first method, SVGs in SVG, is that the icon size can not be controlled using <code>height</code> and <code>width</code> properties through CSS directly, but you must dive into the SVG code for this purpose whenever you want to modify the icon size.
</p>

<p>
The second method, SVGs in CSS, relies on a technique called DataURL, which involves embedding the actual data of an image directly into the URL field instead of including a link to that image.
</p>

<p>
The SVG file can be stored in this case as:
</p>

<ul>
<li>Binary code called base64, which is not <a href="#maintainability">fit for maintenance and modification</a>.</li>
<li>In its original format: i.e. as an XML code.</li>
</ul>

<p>
There is no doubt that the second format is preferable, because of its <a href="#maintainability">maintainability</a> and <a href="#accessibility">accessibility</a>.
</p>

<h2>SVG Containers: The Practice</h2>

<p>
So, until now, we’ve opted —among SVG containers— the «DataURL as XML» method to be a haven:
</p>

<ul>
<li>For commercial logos if they are colored,</li>
<li>And for countries’ flags (in principle).</li>
</ul>

<h3>Colorful Commercial Logos</h3>

<p>
First, we point out that, when used, care should be taken to:
</p>

<ul>
<li>SVG code meets the following conditions:
<ul>
<li>Replace <code>#</code> character with the string <code>%23</code>. For example, the following text:
<pre>&lt;g fill="#fff"&gt;</pre>
 should be converted to the following formula:
<pre>&lt;g fill="%23fff"&gt;</pre>
</li>
<li>Preferably in one line, i.e., free of line breaks, as follows:
<pre>content: url(&#39;data:image/svg+xml;charset=utf8, &lt;svg … /&gt;&lt;/svg&gt;&#39;);</pre>
Or insert the escape character <kbd>\</kbd> before each transition to a new line, as follows:
<pre>content: url(&#39;data:image/svg+xml;charset=utf8,\
		&lt;svg … /&gt;\
		&lt;/svg&gt;&#39;);</pre>
</li>
<li>
Do not include tabs or line breaks (even with the escape character <kbd>\</kbd>) in a single tag, or Firefox will fail to display the SVG image.
</li>
<!--
<li>خالية من علامات الجدولة Tabs.</li>
<li>خالية من ترويسة XML.
<pre>
<del>&lt;?xml version=&#34;1.0&#34; encoding=&#34;UTF-8&#34; standalone=&#34;no&#34;?&gt;</del>
</pre>
</li>
-->
<!--<li>خالية من الخاصية <code>translate</code>.</li>-->
</li>
</ul>
</li>
<li>
Set the icon (say it’s represented by an <code>a:before</code> pseudo element) as an <code>inline-block</code> to display it in the correct size.
<pre>
a:before {
	display: inline-block;
}
</pre>
</li>
</ul>

<p>
We recommend storing these codes in a separate CSS file, as <code>svg-icons.css</code> for example. This procedure has two objectives:
</p>

<ul>
<li>Prevents the delay of loading the original CSS file, thus preventing the page rendering process in the desired format from being delayed.</li>
<li>Better <a href="#maintainability">maintainability</a> for the original CSS file, due to its free of SVG lines that might be long.</li>
</ul>

<p>
Again, we say: Despite these limitations, «DataURL as XML» method remains, according to our estimation, and looking at the latest table <a href="#solutions-according-to-available-techniques">Web Icons Solutions by Available Techniques</a>, the best solution among <a href="#svg-container">SVG containers</a>.
</p>

<p>
Two final points remain:
</p>

<ul>
<li>The issue of adding special effects to the icon when you hover over it (<code>a:hover</code> selector).</li>
<li>A comparison between the last solution, «DataURL as XML», and fonts, for non-colored commercial logos.</li>
</ul>

<h4>Mouseover Effects</h4>

<p>
The <code>color</code> property is typically used for this purpose in the case of fonts as follows:
</p>

<pre>
.wordpress-blog:before {
	content: &#39;wordpress&#39;;
	color: gray;			/* Effect: monochrome. */

}
.wordpress-blog:hover:before {
	color: #464646;			/* Formal color. */
}
</pre>

<p>
But this method will not work with SVG icons and color fonts, so what’s the solution then?
</p>

<p>
The solution is to use <code>mix-blend-mode</code> property that can be used to disable the colors of any image or object when applied to it. For example:
</p>

<pre>
.wordpress-blog:before {
	content: &#39;wordpress&#39;;
	mix-blend-mode: luminosity;	/* Effect: monochrome */

}

.wordpress-blog:hover:before {
	mix-blend-mode: normal;		/* Formal color */
}

</pre>

<h4>Non-Colored Commercial Logos: DataURL as XML or Fonts?</h4>

<p>
We can say that what distinguishes «DataURL as XML» method is the <a href="#maintainability">ease of maintenance and modification</a> comparing to fonts, since the process of generating fonts requires special software —especially if we are talking about color fonts— and involves what can be considered a compiling process, whilst updating icons stored using «DataURL as XML» method only requires <em>copy and paste</em> procedures inside the user’s CSS file with some minor modifications.
</p>

<p>
The font file is probably smaller in size than the total size of SVG codes stored inside a CSS file. In other words, the size of the resulting font file is usually less than the size of an SVG container uses «DataURL as XML» format.
</p>

<h3>Countries’ Flags</h3>

<p>
The list of countries’ flags can be viewed as a stable standard component that is not relatively subject to overnight change and modification like commercial logos. It can easily be linked to ISO-3166 country codes, whether using standard ASCII characters or using <a href="#regional-indicator-symbol-letters">Regional Indicator Symbol Letters</a>.
</p>

<p>
However, the question now is:
</p>

<ul>
<li>How effective is it to store more than 250 images of flags in a file with size not less than 5.5 MB?</li>
<li>How will the alphabet-symbols of countries be replaced with flags with sizes fit the size of those icons on screen?</li>
</ul>

<p>
The answer is that —as long as we are talking about a component with stable standards— it should be provided, with an automatic-replacement feature, in advance, within browsers.
</p>

<p>
That is, country flags and their linking to symbols should be a client-side built-in component rather than a server-side one, and «DataURL as XML» method will not be effective here.
</p>

<p>
Insert the smile symbol ☺ in <strong>Input</strong> field on
<a href="https://demos.emojione.com/latest/live-preview.html" title="Live Preview Box at EmojiOne">
Live Preview Box at EmojiOne
</a>.
<!-- emojione-master/demos/live-preview.html -->
</p>

<p>
Notice how the icon appears in the <strong>Output</strong> field as a color image.
</p>

<p>
What’s required for countries’ flags is to provide such a solution <em>in browsers or operating systems in advance</em>, so that inserting the symbol 🇺🇸 leads to emergence of the United States flag, and inserting the symbol 🇩🇪 leads to emergence of the flag of Germany, etc.
</p>

<p>
This solution has become available recently in new Linux distributions thanks to the availability of Google’s Noto Color Emoji font, but is, until the moment of writing these lines, limited to just a few flags. It’s also supported and available in modern Firefox versions.
</p>

<h2>Conclusion</h2>

<p>
Ideal solutions for different icon categories can be summarized in the following table:
</p>

<table class="fixedTable" id="solutions-according-to-icon-categories">
<caption>Web icons solutions by icon categories</caption>
<thead>
<tr>
	<th></th>
	<th>Standardization</th>
	<th>Multi-color</th>
	<th>Ideal solution</th>
</tr>
</thead>
<tbody>
<tr>
	<td>UI icons</td>
	<td>✓</td>
	<td>✕</td>
	<td>Font <a href="#emoji">emoji</a></td>
</tr>
<tr>
	<td>Monochrome logos</td>
	<td>✕</td>
	<td>✕</td>
	<td>Font <a href="#pua">PUA</a>+<a href="#ligatures">Ligatures</a></td>
</tr>
<tr>
	<td>Colorful logos</td>
	<td>✕</td>
	<td>✓</td>
	<td>DataURL as XML</td>
</tr>
<tr>
	<td>Countries’ flags</td>
	<td>✓</td>
	<td>✓</td>
	<td>Client-side (built in browsers or OSs)</td>
</tr>
</tbody>
</table>

<p>
The following table shows a simplified comparison between the various solutions of representing icons in web; including both the ideal and no-ideal (excluded from our research) ones:
</p>

<table id="solutions-according-to-available-techniques">
<caption>Web icons solutions by available techniques</caption>
<thead>
<tr>
	<th></th>
	<th><a href="#maintainability">Maintainability</a></th>
	<th><a href="#accessibility">Accessibility</a></th>
	<th><a href="#resizibility">Resizibility</a></th>
	<th>Multi-color</th>
	<th><a href="#performance">Performace</a></th>
</tr>
</thead>
<tbody>
<tr>
	<th>Single bitmaps</th>
	<td>✓</td>
	<td>✓</td>
	<td>✕</td>
	<td>✓</td>
	<td>✕</td>
</tr>
<tr>
	<th>Spritesheet bitmaps</th>
	<td>✕</td>
	<td>✕</td>
	<td>✕</td>
	<td>✓</td>
	<td>✓</td>
</tr>
<tr>
	<th>Traditional fonts (monochrome)</th>
	<td>✕</td>
	<td>✓</td>
	<td>✓</td>
	<td>✕</td>
	<td>✓</td>
</tr>
<tr>
	<th>Colored fonts</th>
	<td>✕</td>
	<td>✓</td>
	<td>✓</td>
	<td>✓</td>
	<td>✓</td>
</tr>
<tr>
	<th>SVG Spritesheet (viewbox)</th>
	<td>✕</td>
	<td>✕</td>
	<td>50%</td>
	<td>✓</td>
	<td>✓</td>
</tr>
<tr>
	<th>SVG Spritesheet (predefined views)</th>
	<td>✕</td>
	<td>✓</td>
	<td>50%</td>
	<td>✓</td>
	<td>✓</td>
</tr>
<tr>
	<th>SVG Stack</th>
	<td>50%</td>
	<td>✓</td>
	<td>50%</td>
	<td>✓</td>
	<td>✓</td>
</tr>
<!--
<tr>
	<th>SVG Symbol</th>
	<td></td>
	<td></td>
	<td>✓</td>
	<td>✓</td>
	<td>✓</td>
</tr>
-->
<tr>
	<th>SVGs in CSS (DataURL as base64)</th>
	<td>✕</td>
	<td>✕</td>
	<td>✓</td>
	<td>✓</td>
	<td>✓</td>
</tr>
<tr>
	<th>SVGs in CSS (DataURL as XML)</th>
	<td>✓</td>
	<td>✓</td>
	<td>✓</td>
	<td>✓</td>
	<td>✓</td>
</tr>
</tbody>
</table>

<h2>Final Words</h2>

<p>
I think that operating systems, over time, and over a few years, will be pre-equipped with <a href="#emoji">emoji</a> color fonts, as an authentic component. If the abundance of this type of fonts is accompanied by the support of different browsers for color fonts, it will most likely mean that, after the exception of commercial logos, web developers are freed from the burden of developing web icons and their problems definitively. It will be enough for developer to be able to use one of the two values: <code>monochrome</code> and <code>polychrome</code> that we propose as new values of the <code>&lt;generic-font-family&gt;</code> within web standards, to choose between the available colored icons (<a href="#emoji">emoji</a> presentation style) and the non-colored one (text presentation style, or <a href="#pictograph">pictographs</a> style), as an intermediate solution instead of resorting to manually switch between the two <em>variants selectors</em> responsible for controlling the <a title="Emoji versus Text Display" href="http://www.unicode.org/reports/tr51/#Emoji_vs_Text_Display">emoji presentation style (colorful or monochrome)</a>:
</p>

<ul>
<li><code>U+FE0F VARIATION SELECTOR-16</code> = emoji variation selector.</li>
<li><code>U+FE0E VARIATION SELECTOR-15</code> = text variation selector.</li>
</ul>

<pre>
font-family: [ serif | sans-serif | cursive | fantasy | monospace ] [ monochrome | polychrome ]?
</pre>

<p>This will allow an emergence of new uses for such symbols, including but not limited to:</p>

<ul>
<li>UI Icons in desktop and mobile environments. But the odd thing about this is that <a href="http://www.unicode.org/emoji/proposals.html#emoji_proposals_form">Unicode does not see UI icons as part of Unicode standard</a>, despite the fact that today’s Unicode standard is jammed with many Emoji that fit for this purpose!</li>
<li>Emblems for folders and files in desktop environment. It is a simple solution provided by Ubuntu Linux distribution and some of its derivatives, allowing user to put some colorful symbols (icons) on its files and folders to distinguish them visually.</li>
</ul>

---

###### This article is licensed under [Creative Commons License BY-NC-ND 3.0](https://creativecommons.org/licenses/by-nc-nd/3.0/deed.en).

###### This article is also available in Arabic as:<br/>[&#8235;‏بين خطوط الأيقونات ورسومات SVG: الدليل الكامل لأيقونات الويب القابلة للوصول](https://richstyle.org/?software-engineering/icon-fonts-vs-svgs-ar)