Skip to content

C, C++ headers and C# classes for icon fonts: Font Awesome, Fork Awesome, Material Design, Kenney game icons and Fontaudio

License

Notifications You must be signed in to change notification settings

rulr/IconFontCppHeaders

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Support development of IconFontCppHeaders through GitHub Sponsors or Patreon

Become a Patron

IconFontCppHeaders

https://github.com/juliettef/IconFontCppHeaders

C, C++ headers and C# classes for icon fonts Font Awesome, Fork Awesome, Google Material Design icons, Kenney game icons and Fontaudio.

A set of header files and classes for using icon fonts in C, C++ and C#, along with the python generator used to create the files.

Each header contains defines for one font, with each icon code point defined as ICON_*, along with the min and max code points for font loading purposes.

In addition the python script can be used to convert ttf font files to C and C++ headers. Each ttf icon font file is converted to a C and C++ header file containing a single array of bytes. To enable conversion, run the GenerateIconFontCppHeaders.py script with 'ttf2headerC = True'.

Icon Fonts

Font Awesome 4

Font Awesome 5 - see notes below

Font Awesome 5 Pro - this is a paid product, see notes below

Files downloaded from fontawesome.com

  • ..\fontawesome-pro-n.n.n-web\metadata\icons.yml
  • ..\fontawesome-pro-n.n.n-web\webfonts\fa-brands-400.ttf
  • ..\fontawesome-pro-n.n.n-web\webfonts\fa-light-300.ttf
  • ..\fontawesome-pro-n.n.n-web\webfonts\fa-regular-400.ttf
  • ..\fontawesome-pro-n.n.n-web\webfonts\fa-solid-900.ttf

Notes about Font Awesome 5

Codepoints grouping

Font Awesome 5 splits the different styles of icons into different font files with identical codepoints for light, regular and solid styles, and a different set of codepoints for brands. We have put the brands into a separate header file.

Generating Pro header files

Download the Font Awesome Pro Web package. To generate the headers, drop icons.yml in the same directory as GenerateIconFontCppHeaders.py before running the script. The file icons.yml is under ..\fontawesome-pro-n.n.n-web\metadata\icons.yml where n.n.n is the version number.

Ionicons and webfont Material Design Icons

Unsupported as of 29 Apr 2020. See Issue #16.

Example Code

Using Dear ImGui as an example UI library:

#include "IconsFontAwesome5.h"

ImGuiIO& io = ImGui::GetIO();
io.Fonts->AddFontDefault();
 
// merge in icons from Font Awesome
static const ImWchar icons_ranges[] = { ICON_MIN_FA, ICON_MAX_FA, 0 };
ImFontConfig icons_config; icons_config.MergeMode = true; icons_config.PixelSnapH = true;
io.Fonts->AddFontFromFileTTF( FONT_ICON_FILE_NAME_FAS, 16.0f, &icons_config, icons_ranges );
// use FONT_ICON_FILE_NAME_FAR if you want regular instead of solid

// in an imgui window somewhere...
ImGui::Text( ICON_FA_PAINT_BRUSH "  Paint" );    // use string literal concatenation
// outputs a paint brush icon and 'Paint' as a string.

Projects using the font icon header files

Avoyd is a 6 degrees of freedom voxel game that includes a voxel editor tool.
www.avoyd.com

The voxel editor's UI uses Dear ImGui with Font Awesome icon fonts.

Screenshot of the the game Avoyd's Voxel Editor UI using an IconFontCppHeaders header file for Font Awesome with Dear ImGui

Cross-platform rendering library.
bkaradzic.github.io/bgfx/overview

Real time 3D strange attractors scout.
www.michelemorrone.eu/glchaosp

Screenshot of glChAoS.P UI using IconFontCppHeaders header file for Font Awesome with Dear ImGui

Cross platform C++ audio plug-in framework
iplug2.github.io

3D C++ open source game engine

Screenshot of Lumix Engine editor using IconFontCppHeaders header file for Font Awesome with Dear ImGui

Real time, nanosecond resolution, remote telemetry frame profiler for games and other applications.

New features in Tracy Profiler v0.6

Transistor level 6502 Hardware Simulation
floooh.github.io/visual6502remix

Related Tools

ImGuiFontStudio - Create font subsets

Credits

Development - Juliette Foucaut - @juliettef
Requirements - Doug Binks - @dougbinks
None language implementation and refactoring - Leonard Ritter - @paniq
Suggestion to add a define for the ttf file name - Sean Barrett - @nothings
Initial Font Awesome 5 implementation - Codecat - @codecat
Suggestion to add Fork Awesome - Julien Deswaef - @xuv
Suggestion to add Ionicons - Omar Cornut - @ocornut
C# language implementation - Rokas Kupstys - @rokups
Suggestion to add Material Design Icons - Gustav Madeso - @madeso
Fontaudio implementation - Oli Larkin - @olilarkin
Initial ttf to C and C++ headers conversion implementation - Charles Mailly - @Caerind

About

C, C++ headers and C# classes for icon fonts: Font Awesome, Fork Awesome, Material Design, Kenney game icons and Fontaudio

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C 53.0%
  • C# 43.7%
  • Python 3.3%