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 Style with nuget? #38

Closed foreachthing closed 4 years ago

foreachthing commented 4 years ago

How can I change the lookup-order of chars with the nuget package? I very much like the left char (solid) over the one on the right (regular): image

mkoertgen commented 4 years ago

Hi @foreachthing,

As of now the lookup order is hard-coded, cf.:

We did not add the style-concept yet. That would probably a good extension. The way i would go about is to add style-property in xaml, e.g.

<fa:IconBlock Icon="Home" Foreground="Blue" Style="<Regular> or <Solid>" />

As a workaround you can always use the font explicitly in a TextBlock (see Readme) like this

<TextBlock Grid.Column="1" Text="&#xf042;"   <----- Use hex-code of "IconChar.FolderOpen" here
    FontFamily="/FontAwesome.Sharp;component/fonts/#Font Awesome 5 Free Solid"
    Foreground="Chartreuse"
    TextAlignment="Center" />

But of course then you lose most of the goodness FontAwesome.Sharp brings to the table ;-)

foreachthing commented 4 years ago

Thanks for your answer @mkoertgen I guess I should have mentioned that I am using Windows Forms (somehow I can't get used to wpf). Any chance of using solids with c#?

mkoertgen commented 4 years ago

Hi @foreachthing,

You can always sub-class the component you want to use and override the FontFor-method.

For example the IconButton:

public class MyIconButton : IconButton
{
   public override FontFor(IconChar icon)
   {
        if (UseSolid)
           return ....
   }
}

As of now access to the internally loaded fonts is private/internal in FormsIconHelper.cs but it should be no problem to make this public.

foreachthing commented 4 years ago

Yeah ... ! I'm fairly new to c# and could not get it to work.

So, I adjusted the code according issue https://github.com/awesome-inc/FontAwesome.Sharp/issues/33, and that was it! :-)

Thanks for your patience and hard work.