andreinitescu / IconFont2Code

Generate C# class with constant fields for the icons in your font
277 stars 37 forks source link

Map css class name to symbol #1

Closed AlexHedley closed 5 years ago

AlexHedley commented 5 years ago

Might be too specific but for example I’m using Font Awesome in a web app.

I have a config page which allows you to select an icon via a picker. Icon Picker

This saves the class name (“star”) not the code (“\uf641”). When I use an api to retrieve this info and display in my Xam app I’d like to use the correct symbol based on the corresponding class name.

A list of Font Awesome icons and their CSS content values

Feature Request: Pick a font and a css file and the tool generates a KVP or Dict that stores the mapping.

andreinitescu commented 5 years ago

Sorry, it's indeed too specific for the scope of this tool. Since this tool is open source you can fork it and modify it any way you'd like.

AlexHedley commented 5 years ago

No problem at all, just thought I'd bring it up in case it was a roadmap item and didn't want to duplicate work, I'll let you know how I get on, thanks for a great tool.

andreinitescu commented 5 years ago

Reading again your description, I want to be sure I understand it correctly. The tool already can take a CSS file and generate the C# code based on the glyph name from the CSS. Isn't this what you want? I initially thought you are referring to the CSS support in Xamarin Forms.

Could you please provide a clear example of what you mean? Something like: Step 1: select a font file Step 2: ...

AlexHedley commented 5 years ago

I'd missed the css upload part, so apologies for that.

For instance, I upload FontAwesome.otf If I filter for a single item for a example:

Glass https://fontawesome.com/v4.7.0/icon/glass

static class IconFont
{
    public const string Glass = "\uF000";
}

Adding font-awesome.css produces

static class IconFont
{
    public const string FaGlass = "\uF000";
}

So that will work.

andreinitescu commented 5 years ago

Awesome!!! Let me know what if there's anything you think I can do in order to better communicate this important feature. It's described in the README and there's also a tool-tip on the "what's this for"

image

Someone else asked me about how the CSS feature works, so maybe there's something which I can improve.

andreinitescu commented 5 years ago

I (think) I improved the explanation for the CSS feature, check it out:

image

AlexHedley commented 5 years ago

I think the popup is a great addition