awesome-inc / FontAwesome.Sharp

A library for using Font Awesome in WPF & Windows Forms applications
Apache License 2.0
384 stars 89 forks source link

Solid icons for WinForms? #49

Closed fogskum closed 3 years ago

fogskum commented 3 years ago

All icons seem to be rendered with Regular style. How to I render Solid icons?

mkoertgen commented 3 years ago

Hi @fogskum, Sorry for responding late. I missed the notification.

In fontawesome, regular and solid icons use different font/ttf-files. As of now, we have a hard-coded heuristic that tries finding the specified icon in the fonts and the match wins, cf.:

Since regular/solid have overlapping icons and regular is the first in the list, the glyphs in the regular-font will be preferred.

For WPF there would exist some workarounds by specifying the font explicitly but not yet in WinForms

As of now, we are short of spare time to address this issue but it sounds like a valuable feature to add to the libray. Nevertheless, it should not be too hard to add it. As an example, here would be an intersection point where to hook into:

You are more than welcome to submit a pull request.

I would suggest an approach like this: For all font-awesome classes (using "IconChar" as type parameter) implement an interface like

public interface IHaveFontStyle
{
   FontStyle FontStyle { get; }
}

public enum FontStyle { Auto, Regular, Solid, ... }

and override FontFor correspondingly.

mkoertgen commented 3 years ago

Fontstyle can now be explicitly set, documented in FAQ.