├── fa2cs ├── Models │ ├── Style.cs │ ├── Icon.cs │ └── SemanticVersion.cs ├── Resources │ ├── PropertyTemplate.txt │ ├── ClassTemplate.txt │ └── Readme.txt ├── Helpers │ ├── ResourcesHelper.cs │ ├── AssemblyHelper.cs │ ├── OpenFileHelper.cs │ ├── StringHelper.cs │ └── DotNetNameHelper.cs ├── ReadmeWriter.cs ├── fa2cs.csproj ├── CodeWriter.cs ├── Program.cs └── MetaDataParser.cs ├── LICENSE ├── fa2cs.sln ├── Readme.md └── .gitignore /fa2cs/Models/Style.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | namespace fa2cs.Models 3 | { 4 | public enum Style 5 | { 6 | Brands, 7 | Light, 8 | Regular, 9 | Solid, 10 | Duotone, 11 | Thin 12 | } 13 | } 14 | 15 | -------------------------------------------------------------------------------- /fa2cs/Resources/PropertyTemplate.txt: -------------------------------------------------------------------------------- 1 | /// 2 | /// fa-$name$ unicode value ("\u$code$"). 3 | /// 4 | /// This icon supports the following styles: $styles$ 5 | /// 6 | /// Introduced in '$introduced_version$', Last Modified in '$last_modified_version$'. 7 | /// 8 | /// See $link$ 9 | /// 10 | [Description("$name$")] 11 | public const string $dotnet_name$ = "\u$code$"; -------------------------------------------------------------------------------- /fa2cs/Resources/ClassTemplate.txt: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.ComponentModel; 3 | 4 | namespace FontAwesome 5 | { 6 | /// 7 | /// The unicode values for all FontAwesome v$version$ icons. 8 | /// 9 | /// See https://fontawesome.com/cheatsheet 10 | /// This code was automatically generated by FA2CS (https://github.com/matthewrdev/fa2cs). 11 | /// 12 | public static partial class FontAwesomeIcons 13 | { 14 | $properties$ 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /fa2cs/Helpers/ResourcesHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Diagnostics; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Reflection; 6 | 7 | namespace fa2cs.Helpers 8 | { 9 | public static class ResourcesHelper 10 | { 11 | public static string ReadResourceContent(string resourceName) 12 | { 13 | var assembly = typeof(ResourcesHelper).Assembly; 14 | using (var stream = assembly.GetManifestResourceStream(resourceName)) 15 | { 16 | using (var reader = new StreamReader(stream)) 17 | { 18 | return reader.ReadToEnd(); 19 | } 20 | } 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /fa2cs/ReadmeWriter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using fa2cs.Helpers; 4 | using fa2cs.Models; 5 | 6 | namespace fa2cs 7 | { 8 | public class ReadmeWriter 9 | { 10 | public string Write(string fontAwesomeVersion) 11 | { 12 | Console.Write("Generating repository readme..."); 13 | 14 | var readmeTemplate = ResourcesHelper.ReadResourceContent("Readme.txt"); 15 | 16 | var now = DateTimeOffset.UtcNow; 17 | 18 | return readmeTemplate.Replace("$latest_version$", fontAwesomeVersion) 19 | .Replace("$exported_date_time$", now.ToString("F")) 20 | .Replace("$exported_timezone$", "UTC"); 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2018 Matthew Robbins 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /fa2cs.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.810.20 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "fa2cs", "fa2cs\fa2cs.csproj", "{1F7EDAA7-ACF3-4C3C-91E0-9BFFA1055FDF}" 7 | EndProject 8 | Global 9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 10 | Debug|Any CPU = Debug|Any CPU 11 | Release|Any CPU = Release|Any CPU 12 | EndGlobalSection 13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 14 | {1F7EDAA7-ACF3-4C3C-91E0-9BFFA1055FDF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 15 | {1F7EDAA7-ACF3-4C3C-91E0-9BFFA1055FDF}.Debug|Any CPU.Build.0 = Debug|Any CPU 16 | {1F7EDAA7-ACF3-4C3C-91E0-9BFFA1055FDF}.Release|Any CPU.ActiveCfg = Release|Any CPU 17 | {1F7EDAA7-ACF3-4C3C-91E0-9BFFA1055FDF}.Release|Any CPU.Build.0 = Release|Any CPU 18 | EndGlobalSection 19 | GlobalSection(SolutionProperties) = preSolution 20 | HideSolutionNode = FALSE 21 | EndGlobalSection 22 | GlobalSection(ExtensibilityGlobals) = postSolution 23 | SolutionGuid = {2DDC1688-92CD-47E4-B223-8E3012DE4942} 24 | EndGlobalSection 25 | EndGlobal 26 | -------------------------------------------------------------------------------- /fa2cs/fa2cs.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Exe 5 | net9.0 6 | default 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | ClassTemplate.txt 21 | 22 | 23 | PropertyTemplate.txt 24 | 25 | 26 | Readme.txt 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | FontAwesomeIcons.cs 35 | 36 | 37 | -------------------------------------------------------------------------------- /fa2cs/Helpers/AssemblyHelper.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Reflection; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Collections.Generic; 6 | 7 | namespace fa2cs.Helpers 8 | { 9 | public static class AssemblyHelper 10 | { 11 | public static Assembly EntryAssembly => Assembly.GetEntryAssembly(); 12 | 13 | public static string EntryAssemblyDirectory => DirectoryForAssembly(EntryAssembly); 14 | 15 | public static string DirectoryForAssembly(Assembly assembly) 16 | { 17 | string codeBase = assembly.CodeBase; 18 | UriBuilder uri = new UriBuilder(codeBase); 19 | string path = Uri.UnescapeDataString(uri.Path); 20 | return Path.GetDirectoryName(path); 21 | } 22 | 23 | public static Assembly GetAssemblyByName(string name) 24 | { 25 | return AppDomain.CurrentDomain.GetAssemblies(). 26 | SingleOrDefault(assembly => assembly.GetName().Name == name); 27 | } 28 | 29 | public static IEnumerable GetLoadableTypes(this Assembly assembly) 30 | { 31 | if (assembly == null) throw new ArgumentNullException(nameof(assembly)); 32 | try 33 | { 34 | return assembly.GetTypes(); 35 | } 36 | catch (ReflectionTypeLoadException e) 37 | { 38 | return e.Types.Where(t => t != null); 39 | } 40 | } 41 | } 42 | } 43 | 44 | -------------------------------------------------------------------------------- /fa2cs/CodeWriter.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using fa2cs.Helpers; 4 | using fa2cs.Models; 5 | 6 | namespace fa2cs 7 | { 8 | public class CodeWriter 9 | { 10 | public string Write(IReadOnlyList icons, SemanticVersion version) 11 | { 12 | Console.Write("Generating C# code..."); 13 | 14 | var classTemplate = ResourcesHelper.ReadResourceContent("ClassTemplate.txt"); 15 | var propertyTemplate = ResourcesHelper.ReadResourceContent("PropertyTemplate.txt"); 16 | 17 | var properties = new List(); 18 | 19 | foreach (var icon in icons) 20 | { 21 | var property = propertyTemplate.Replace("$link$", icon.Url) 22 | .Replace("$name$", icon.Id) 23 | .Replace("$code$", icon.Unicode) 24 | .Replace("$dotnet_name$", icon.DotNetName) 25 | .Replace("$introduced_version$", icon.IntroducedVersion) 26 | .Replace("$last_modified_version$", icon.LastModifiedVersion) 27 | .Replace("$styles$", icon.StylesSummary); 28 | 29 | properties.Add(property); 30 | } 31 | 32 | var separator = Environment.NewLine + Environment.NewLine; 33 | var code = string.Join(separator, properties); 34 | 35 | return classTemplate.Replace("$properties$", code) 36 | .Replace("$version$", version.ToString()); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Readme.md: -------------------------------------------------------------------------------- 1 | # About 2 | 3 | **Last Generated for FontAwesome v7.1.0 on Thursday, 9 October 2025 06:46:42 (UTC)** 4 | 5 | Use `FontAwesomeIcons.cs` to replace confusing and arcane unicode strings with a clean and descriptive property. 6 | 7 | This: 8 | 9 | ``` 10 | // Huh? What icon is this? What font is it from? 😭 11 | submitButton.Text = "/uf00c"; 12 | ``` 13 | 14 | Becomes this: 15 | 16 | ``` 17 | // Obviously a check icon from FontAwesome! 😊👍 18 | submitButton.Text = FontAwesome.FontAwesomeIcons.Check; 19 | ``` 20 | 21 | The end result is cleaner, more readable and more maintainable code. 22 | 23 | **[Get FontAwesomeIcons.cs here](https://raw.githubusercontent.com/matthewrdev/fa2cs/master/FontAwesomeIcons.cs)** 24 | 25 | **[Download the FontAwesome font assets here](https://github.com/FortAwesome/Font-Awesome/tree/master/webfonts)** 26 | 27 | # Using FontAwesome To C# 28 | 29 | It's super easy to use FontAwesome To C#! 30 | 31 | Simply download [FontAwesomeIcons.cs](FontAwesomeIcons.cs) and place it into your project. 32 | 33 | **[Ensure that you have added the FontAwesome font files into your projects.](https://github.com/FortAwesome/Font-Awesome/tree/master/webfonts)** 34 | 35 | You can use an icon in C# like: 36 | 37 | ``` 38 | var checkIcon = FontAwesome.FontAwesomeIcons.Check; 39 | ``` 40 | 41 | You can use an icon in XAML by: 42 | 43 | * Adding a namespace reference to `FontAwesome`: `xmlns:fontAwesome="clr-namespace:FontAwesome"` 44 | * Referencing a icon using `x:Static`: `