awesome-inc / FontAwesome.Sharp

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

How to use with Awesome Pro? #99

Closed SkySpiritDev closed 1 year ago

SkySpiritDev commented 2 years ago

I have an Pro account, and download .otf and .svg files.

Also i install FontAwesome.Sharp.Pro package.

I adeed xmlns:fapro="clr-namespace:FontAwesome.Sharp.Pro;assembly=FontAwesome.Sharp.Pro" to xaml.

But i cannot understand how use it.

in TestWpf app i dont see any examples.

Thanks for your help

mkoertgen commented 2 years ago

Hi @SkySpiritDev ,

Have a look at https://github.com/awesome-inc/FontAwesome.Sharp#using-fontawesome-pro Does this help?

SkySpiritDev commented 2 years ago

Hi @SkySpiritDev ,

Have a look at https://github.com/awesome-inc/FontAwesome.Sharp#using-fontawesome-pro Does this help?

Yes, but I'm probably doing something wrong. I will describe below my actions and give the code.

  1. I install packages FontAwesome.Sharp and FontAwesome.Sharp.Pro

  2. Create folder "Icons" and add "fa-regular-400.ttf" file

  3. In App.xaml add code:

    <Application x:Class="WpfApp1.App"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:local="clr-namespace:WpfApp1"
             StartupUri="MainWindow.xaml">
    <Application.Resources>
        <FontFamily x:Key="FontAwesomePro">/WpfApp1;component/Icons/#Font Awesome 6 Pro Regular</FontFamily>
    </Application.Resources>
    </Application>
  4. Code in Window XAML file:

<Window x:Class="WpfApp1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
        xmlns:fa="http://schemas.awesome.incremented/wpf/xaml/fontawesome.sharp"
        xmlns:faPro="http://schemas.awesome.incremented/wpf/xaml/fontawesome.sharp.pro"
        Title="MainWindow" Height="450" Width="800">
    <Grid>
        <faPro:IconBlock Icon="Album" FontFamily="{StaticResource FontAwesomePro}"></faPro:IconBlock>
    </Grid>
</Window>
  1. But i receive an error on line "<faPro:IconBlock...."

"Severity Code Description Project File Line Suppression State Error XDG0062 Value cannot be null. Parameter name: fontFamily WpfApp1"

Screenshots: Screenshot_1

Screenshot_2

SkySpiritDev commented 2 years ago

I also cloned the repository and tried to run the TestWpf project from the Pro branch. Previously, I added the font in the same way, but got the same errors.

Could you please describe step by step how to use Pro Icons in readme, because I have been trying to do this for the third day, but without results.

Thanks!

mkoertgen commented 2 years ago

The "pro"-Branch should provide a working example

However, I did this a while ago (pro version <6). Maybe the icons did change so much that some are breaking. Please check back again. If it doesn't work for you I would offer to update the example with current font-files. Just send me a copy of the ttf-files to marcel.koertgen@gmail.com

mkoertgen commented 2 years ago

Hi @SkySpiritDev ,

I verified the code is working using the current pro fonts (current branches main / pro). I also added support for explicitly switching the font style for the pro fonts as well (regular, solid, light, thin). I did not yet add support for duotone since icons have a separate css/enum but it is straight forward to add.

mkoertgen commented 1 year ago

Closed due to inactivity

toristorii commented 1 year ago

@SkySpiritDev I got it to work with the latest pro TTF fonts (once I realized the ttf fonts are in the web zip and not the desktop zip).

What I had to do was put the TTF fonts in the fonts folder with the build action Resource not Embedded Resource.

That got me a little further, but then I received new exceptions: "ArgumentException: Default value type does not match type of property 'IconFont'."

A little more fiddling and I found what I believe are typos with the dependency properties in IconBlock.cs and IconImage.cs. With those fixed I discovered that it appears the Zhihu icon that the TestWPF app was trying to display is now in a brands font and not in the primary Font Awesome ttf fonts.

I have been unable to get DuoTone/SolidSharp/Brand fonts working correctly, but I figured I'd share what work I got done this morning.

I've forked the repo to make my changes (https://github.com/toristorii/FontAwesome.Sharp/tree/pro) and will be submitting a pull request for @mkoertgen to accept or reject but it's there if anyone else wants it.

mkoertgen commented 1 year ago

Looks good, thanks @toristorii.