GithubHelp home page GithubHelp logo

fa2cs's Introduction

About

Last Generated for FontAwesome v6.5.1 on Sunday, January 28, 2024 8:35:22PM (UTC)

Use FontAwesomeIcons.cs to replace confusing and arcane unicode strings with a clean and descriptive property.

This:

// Huh? What icon is this? What font is it from? ๐Ÿ˜ญ
submitButton.Text = "/uf00c";

Becomes this:

// Obviously a check icon from FontAwesome! ๐Ÿ˜Š๐Ÿ‘
submitButton.Text = FontAwesome.FontAwesomeIcons.Check;

The end result is cleaner, more readable and more maintainable code.

Get FontAwesomeIcons.cs here

Download the FontAwesome font assets here

Using FontAwesome To C#

It's super easy to use FontAwesome To C#!

Simply download FontAwesomeIcons.cs and place it into your project.

Ensure that you have added the FontAwesome font files into your projects.

You can use an icon in C# like:

var checkIcon = FontAwesome.FontAwesomeIcons.Check;

You can use an icon in XAML by:

  • Adding a namespace reference to FontAwesome: xmlns:fontAwesome="clr-namespace:FontAwesome"
  • Referencing a icon using x:Static: <Label Text="{x:Static fontAwesome:FontAwesomeIcons.Check}"/>

Voila! All done!

Using Material Design Icons?

If you're using the Material Design icon set, check out md2cs, a static class file containing string constants for all Material Design icon codes.

fa2cs's People

Contributors

kfrancis avatar matthewrdev avatar sebfrie avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fa2cs's Issues

Equals icon causes code analysis warning

First, thanks for the great work on providing this simple class, it makes the XAML code much more readable.

In our projects we are leveraging the Microsoft.CodeAnalysis.FxCopAnalyzers in our projects. When I brought the FontAwesomeIcons.cs class into our project, the analyzers raised a warning:

warning CS0108: 'FontAwesomeIcons.Equals' hides inherited member 'object.Equals(object)'. Use the new keyword if hiding was intended.

To fix, I simply changed the Equals string to Equal (removing the trailing s). Very minor issue, but would be nice to have this in the source instead of updating it on each iteration.

Font Awesome 6 Support

Is there a tool that generates this?

I have access to the FA 6.0 beta and would like to use the new icons.

I am willing to do the work and make a PR.

Glyphs don't match font

Using the FontAwesomeIcons.cs, I've had issues matching the glyphs to the fonts.

I recommend having separate classes for each font (solid, regular, brands).

That way, instead of:
<FontImageSource FontFamily="FARegular" Glyph="{x:Static fa:FontAwesomeIcons.AddressBook}" />

You can do:
<FontImageSource FontFamily="FARegular" Glyph="{x:Static fa:FontAwesomeRegular.AddressBook}" />

With the assistance of IntelliSense, having the font match the glyph class gives a clear indicator whether or not the icon exists in the selected font.

I've gone ahead and created these 3 classes for my own projects, please feel free to take them, and maybe pretty them up.
FontAwesomeBrands.cs
FontAwesomeRegular.cs
FontAwesomeSolid.cs

Using it in Xaml

I tried using it in XAML as your demo but it doesn't work (setting the text in code behind does work)

<Label Text="{x:Static fontAwesome:FontAwesomeIcons.AmazonPay}"/>

How can we run this locally

I'm interested in running this tool locally because I want to enhance the code generated by adding an attribute (that i've defined) for the supported fonts, updating the generated code to look something like:

[Description("arrow-right")]
[SupportedFonts(FontAwesome.Regular, ...)]
public const string ArrowRight = "\uf061";

[Description("apple")]
[SupportedFonts(FontAwesome.Brands)]
public const string Apple = "\uf179";

Looking at the tool, it requires an icons.json file on the desktop. How do I acquire this file, is it something publicly available or is it private?

Thanks

Different files for Free and Pro version

Hi @matthewrdev,

I want to know if there is a secondary file which only contains the free availble Icons, because currently also Icons which are only available in the Pro Version are in the file FontAwesomeIcons.cs. The problem is that if you are using an icon which is only available in the Pro Version you will see Nothing withtin the app and don't get any error message.

So it would be great if there are two versions of the file one for the Free fonts and one for the Pro fonts.

Thanks.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.