Giter Site home page Giter Site logo

Comments (4)

MartinTopfstedt avatar MartinTopfstedt commented on May 27, 2024

Hi, if you use LoadFromResource the Resource Name is the Namespace + fileName, it is not a path.
e.x. Svg.FontAwesomeSvg.LoadFromResource("FontAwesome6.Example.WPF.Svg.FontAwesomeSvg.all.json", Assembly.GetExecutingAssembly());
"FontAwesome6.Example.WPF" < this is the default Namespace from the "FontAwesome6.Example.WPF.NetCore" project.
Inside the project there is a "Svg" Folder which contains the "FontAwesomeSvg.all.json" file as embedded resource.
-> "{Namespace}.{Path inside Project with . instead of /}.{FileName}"

Hope this helps. I will try to make the README complete.

from fontawesome6.

MartinTopfstedt avatar MartinTopfstedt commented on May 27, 2024

Ok, i played a little bit around and the problem here is that the json file needs to be loaded, directory or embedded resource doesn't matter. I could get it working by adding the Svg.FontAwesomeSvg.LoadFromResource inside the constructor of the ViewModel of a Window and set the ViewModel as DataContext inside the Window,xaml. But this is not really a good solution

from fontawesome6.

MartinTopfstedt avatar MartinTopfstedt commented on May 27, 2024

Hi, i found a way to load the icons, but it is very hacky :).
You can add a DesignTimeResourceDictionary and load a dedicated Loading UserControl which calls the load method.
I added a tutorial to the README and modified the Example Projects.

from fontawesome6.

gakera avatar gakera commented on May 27, 2024

I would say that the Readme could be updated with better instructions for how to do the runtime setup to get things working.

For example, to get FontAwesome6.Pro.Svg working in my WinUI 3 project, I have to:

  1. (follow the instructions on https://github.com/MartinTopfstedt/FontAwesome6#fontawesome6prosvg as written to install the nuget package and generate the json file)
  2. In csproj file, make sure json file is included as embedded resource (I include it as linked since it's shared between a couple of projects) <EmbeddedResource Include="..\Shared\Assets\FontAwesomeSvg.json" Link="SharedAssets\FontAwesomeSvg.json"/>. I included the "all.json" file from the generator, just renamed.
  3. In startup App constructor, after configuring services, with using FontAwesome6.Svg;, run FontAwesomeSvg.LoadFromResource with the appropriate resource string. To find the appropriate resource string I used System.Reflection.Assembly.GetCallingAssembly().GetManifestResourceNames() to see the name and then FontAwesomeSvg.LoadFromResource("MyProjectName.SharedAssets.FontAwesomeSvg.json", System.Reflection.Assembly.GetCallingAssembly());
  4. In XAML, include xmlns:fas="using:FontAwesome6.Svg" (not xmlns:fas="http://schemas.fontawesome.com/icons/svg, that doesn't work) and then use <fas:SvgAwesome Icon="Light_Eject" PrimaryColor="HotPink" Width="50"/> for the icon as needed.

This seems to be sufficient to get FontAwesome6.Pro.Svg working in my WinUI 3 project.

from fontawesome6.

Related Issues (19)

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.