Click here to Skip to main content
13,861,876 members
Click here to Skip to main content
Add your own
alternative version

Tagged as


31 bookmarked
Posted 11 Nov 2016
Licenced CPOL

FontAwesome image/icon generator for WinForms

, 14 Feb 2018
Rate this:
Please Sign up or sign in to vote.
Usage of my FontAwesome Image/Icon generator for WinForms


First: many thanks for the font to Font Awesome by Dave Gandy -

This is a simple class to create images and icons from FontAwesome TTF.


There are some articles describing usage of FontAwesome in WPF. Here is something for good old WinForms.

(Optional) Preset the class with default properties.

//Sample default properties
FontAwesome.DefaultProperties.Size = 32;
FontAwesome.DefaultProperties.ShowBorder = true;

Now, we can start creating images and icons:

//create image using default properties
var image1 = FontAwesome.Type.Crosshairs.AsImage();

//create icon using default properties
var icon = FontAwesome.Type.Crosshairs.AsIcon();

//create image with custom properties
var image2 = new FontAwesome.Properties(FontAwesome.Type.Square) 
{ ForeColor = Color.White }.AsImage();

Sometimes, something more is needed, so I added some simple support for stacking images together:

//sample of stacking images together to create colored unique icons
var stackedImage = 
    new FontAwesome.Properties(FontAwesome.Type.Square) { ForeColor = Color.White }.AsImage()
        .StackWith(new FontAwesome.Properties(FontAwesome.Type.FileO) 
         { Size = 20, Location = new Point(5, 5), ShowBorder = false })
        .StackWith(new FontAwesome.Properties(FontAwesome.Type.Close) 
         { ForeColor = Color.Red, Size = 14, Location = new Point(13, 13), ShowBorder = false });

The FontAwesome class will even download the TTF file:

FontAwesome.Initialize(); //(optional) initiates TTF check and download

You can disable this behaviour by setting:


To use the class with C# 2.0, simply remove the FontAwesomeExtensions class.

//C# 2.0 usage sample
var image1 = FontAwesome.Instance.GetImage(FontAwesome.Type.Save);
var image2 = FontAwesome.Instance.GetImage(new FontAwesome.Properties(FontAwesome.Type.TimesCircle) 
             { ForeColor = Color.Red });
var icon = FontAwesome.Instance.GetIcon(new FontAwesome.Properties(FontAwesome.Type.Home) 
           { ForeColor = Color.Blue, BorderColor = Color.Blue, BackColor = Color.White });

Note: GetIcon() generates a GDI object, which is not automatically released. This can cause exceptions if heavily used. See MSDN article for details.


You can use Nuget to add the library to your project:

PM> Install-Package Fkosoft.FontAwesome

For the new FontAwesome5, there is a new nuget package:

PM> Install-Package Fkosoft.FontAwesome5

Points of Interest

  • C# 4.0, WinForms


  • 1.0.0 - First version
  • 1.0.1 - FontAwesome5 nuget added


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Frantisek Ruzicka
Software Developer
Slovakia Slovakia
No Biography provided

You may also be interested in...

Comments and Discussions

QuestionFontAwsome 5 - Initialisation Method missing Pin
Member 1161272425-Jul-18 20:27
memberMember 1161272425-Jul-18 20:27 
AnswerRe: FontAwsome 5 - Initialisation Method missing Pin
Frantisek Ruzicka2-Oct-18 0:26
professionalFrantisek Ruzicka2-Oct-18 0:26 
QuestionGithub Pin
SpArtA17-Feb-18 1:21
memberSpArtA17-Feb-18 1:21 
AnswerRe: Github Pin
Frantisek Ruzicka19-Feb-18 13:47
professionalFrantisek Ruzicka19-Feb-18 13:47 
GeneralMy vote of 5 Pin
Member 1339763814-Feb-18 6:02
memberMember 1339763814-Feb-18 6:02 
Questionunless you are the creator of the FontAwesome font Pin
BillWoodruff13-Feb-18 5:43
mveBillWoodruff13-Feb-18 5:43 
AnswerRe: unless you are the creator of the FontAwesome font Pin
Frantisek Ruzicka14-Feb-18 7:21
professionalFrantisek Ruzicka14-Feb-18 7:21 
QuestionMy vote of 4 ... Pin
DSAlCoda16-Nov-16 8:03
memberDSAlCoda16-Nov-16 8:03 
AnswerRe: My vote of 4 ... Pin
Frantisek Ruzicka16-Nov-16 10:22
professionalFrantisek Ruzicka16-Nov-16 10:22 
GeneralRe: My vote of 4 ... Pin
DSAlCoda17-Nov-16 9:59
memberDSAlCoda17-Nov-16 9:59 
GeneralRe: My vote of 4 ... Pin
Frantisek Ruzicka17-Nov-16 11:12
professionalFrantisek Ruzicka17-Nov-16 11:12 
General... and ...... 5 Pin
DSAlCoda17-Nov-16 11:23
memberDSAlCoda17-Nov-16 11:23 
GeneralRe: ... and ...... 5 Pin
Frantisek Ruzicka17-Nov-16 11:39
professionalFrantisek Ruzicka17-Nov-16 11:39 
GeneralMy vote of 5 Pin
Forhad Reza15-Nov-16 2:17
memberForhad Reza15-Nov-16 2:17 
GeneralRe: My vote of 5 Pin
Frantisek Ruzicka15-Nov-16 3:07
professionalFrantisek Ruzicka15-Nov-16 3:07 
GeneralMy vote of 5 Pin
wmjordan11-Nov-16 15:42
professionalwmjordan11-Nov-16 15:42 
GeneralRe: My vote of 5 Pin
Frantisek Ruzicka12-Nov-16 11:58
professionalFrantisek Ruzicka12-Nov-16 11:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web01 | 2.8.190214.1 | Last Updated 14 Feb 2018
Article Copyright 2016 by Frantisek Ruzicka
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid