martintopfstedt / fontawesome5 Goto Github PK
View Code? Open in Web Editor NEWWPF controls for the iconic SVG, font, and CSS toolkit Font Awesome 5.
License: MIT License
WPF controls for the iconic SVG, font, and CSS toolkit Font Awesome 5.
License: MIT License
Hello,
I'd like to use the spin property on my icon but couldn't find any way nor documentation.
How can I do that?
Kind regards,
Matt.
public static readonly FontFamily SolidFontFamily = new FontFamily("ms-appx:///FontAwesome5.UWP/Fonts/Font Awesome 5 Free-Solid-900.otf#Font Awesome 5 Free Solid");
need to be changed to:
public static readonly FontFamily SolidFontFamily = new FontFamily("ms-appx:///FontAwesome5.UWP/Fonts/Font Awesome 5 Free-Solid-900.otf#Font Awesome 5 Free");
Is the compiled dll in the nuget package signed?
The readme states that the use is the same as for the Charri version (which is linked). however if you follow that link and copy the namespace reference from the Readme:
xmlns:fa="http://schemas.fontawesome.io/icons/"
It doesn't work because the namespare for this package is xmlns:fa="http://schemas.fontawesome.com/icons/"
(Note the .com instead of .io). This was a bit of a gotcha for me.
I think it would be easier for new users if you made a note of this, or directly re-wrote Charri's usage notes directly into your readme.
Is there a way to reduce the output bundle size? Most of the people would use only a handful of the icons, maybe 10-20 icons. Would it be feasible to invent a way to include only those icons in the output?
I updated the dlls with FA 5.5 Pro by using your tools and also added the light style. This working fine, but if I tried to use the ImageAwesome.CreateImageSource then this is not working.
// set image source of a RibbonApplicationMenuItem
amiRecentDocuments.ImageSource = ImageAwesome.CreateImageSource(FontAwesome5.EFontAwesomeIcon.Light_FolderOpen, Brushes.Black, 24);
Results:
Do I need to add the TTF fonts files?
It seems, the package doesn't support .net core yet ๐.
We came across a memory issue when using the FontAwesome5.Pro library for our WPF application where by loading a control that contained a lot of references to Glyph-icons through using the ImageSourceConverter MarkupExtenson:
<dxb:BarButtonItem Content="{x:Static toolBar:ToolBarMessages.New}"
BarItemDisplayMode="ContentAndGlyph"
Glyph="{Binding Source={x:Static fontAwesome5:EFontAwesomeIcon.Light_FilePlus}, Converter={fa5:ImageSourceConverter}, ConverterParameter={StaticResource DefaultIcon}}"
Command="{Binding NewCommand}"
KeyGesture="Ctrl+N"
IsEnabled="{Binding CanNew}"
Style="{StaticResource PulseBarButtonItemStyle}"/>
When we perform a trace on this, we can see 83 icons being loaded that are taking up 92MB in allocation, which seems a bit excessive.
After some searching online, I found some pointers to a known WPF issue with loading font resources from within Libraries as resources:
wpf textblock memory leak when using font
There is also an in-depth look at this issue here.
With this, i implemented an alternative ImageSourceConverter and FontAwesome map to the otfs using a file path, to see if the absolute path to the resource worked:
public static class Fonts
{
public static readonly FontFamily RegularFontFamily = new FontFamily(new Uri("file:///C:/command/fonts/", UriKind.Absolute), "./#Font Awesome 5 Pro Regular");
}
Testing with this, I was able to confirm a large reduction (~97%) in allocations on the Convert function:
Is it feasible to have this static class derive an ITypefaceProvider or potentially remove the readonly attribute to allow us to change to point to a resource using a file path on the startup of an application?
Restored version 2.0.8 which works as expected. Restore version 2.1.0 and the project builds but does not run, with UWP.
In the designer within Visual Studio a white square is shown in place of font awesome element. When running the exception is:
After doing some more testing, it appears version 2.1.0 works when the target Windows Version is 16299. When the Target Windows version is any higher then FontAwesome no longer works and the above issues are experienced.
For now, I can keep the target version at 16299 but I was hoping to increase the target/min Windows versions.
I cannot build projects without commenting out the <DocumentationFile>$(OutDir)/...</DocumentationFile>
. It seems the OutDir
macro is not defined, so I receive access denied errors, since VS is attempting to create documentation of C:\FontAwesome5.dll
.
Is there a reason the property <GenerateDocumentationFile>True</GenerateDocumentationFile>
is not set instead? This property would just use the default, assembly name, for the documentation file.
Any plans for WinUI 3 support? Open for contributions to add support?
Per this discussion here UWP is being deprecated.
Is there a way to locally create similar package for PRO icons? I have following file structure downloaded:
~/Desktop/fontawesome-pro-5.5.0-desktop $ ls -lt *
-rw-r--r-- 1 kub1x 197121 735 Nov 7 09:48 LICENSE.txt
svgs:
total 1664
drwxr-xr-x 1 kub1x 197121 0 Nov 7 09:49 solid/
drwxr-xr-x 1 kub1x 197121 0 Nov 7 09:48 regular/
drwxr-xr-x 1 kub1x 197121 0 Nov 7 09:48 light/
drwxr-xr-x 1 kub1x 197121 0 Nov 7 09:48 brands/
otfs:
total 3776
-rw-r--r-- 1 kub1x 197121 995584 Nov 7 09:48 'Font Awesome 5 Pro-Solid-900.otf'
-rw-r--r-- 1 kub1x 197121 1156496 Nov 7 09:48 'Font Awesome 5 Pro-Regular-400.otf'
-rw-r--r-- 1 kub1x 197121 1247952 Nov 7 09:48 'Font Awesome 5 Pro-Light-300.otf'
-rw-r--r-- 1 kub1x 197121 456172 Nov 7 09:48 'Font Awesome 5 Brands-Regular-400.otf'
metadata:
total 8856
-rw-r--r-- 1 kub1x 197121 13209 Nov 7 09:48 sponsors.yml
-rw-r--r-- 1 kub1x 197121 4606 Nov 7 09:48 shims.yml
-rw-r--r-- 1 kub1x 197121 23577 Nov 7 09:48 shims.json
-rw-r--r-- 1 kub1x 197121 316851 Nov 7 09:48 icons.yml
-rw-r--r-- 1 kub1x 197121 8656388 Nov 7 09:48 icons.json
-rw-r--r-- 1 kub1x 197121 40932 Nov 7 09:48 categories.yml
Guess the generator can be used for it, but I didn't see it documented, so I'd rather ask, before I'd have to dive into the source code. Thanks in advance
I implemented the pulse animation on the original charri repository. That pull request is here. Unfortunately, I'm not sure if that repository is actually still active.
At first glance, it appears there is 3x the code here due to full support for UWP and .NET Core. I'm not sure why some of the code is not shared (eg. ISpinable, IRotatable), but it all seems possible to add the pulse animation. The animation is just a rotation with 8 descrete steps instead of a continuous rotation. For both UWP and WPF, it's done with the same code as the spin animation, but using a DoubleAnimationWithKeyframes and DiscreteDoubleKeyFrame.
Would there be any interest to implement that functionality here?
Hi. Toggling Visibility property either by trigger in style or by converter doesn't work. The image is always present on the UI. For now I'm using opacity but I need to switch visibility as well. Thanks
WPF 4.7.2
Nuget FontAwesome5 2.0.0
How can I get FontAwesome5.Generator.exe for 64bits platform?
For pull request #4 my intention was to create NuGet package that is not platform specific. This allows reference from cross-platform assemblies (i.e. MyApp.Mobile.ViewModels). Within an assembly like this, EFontAwesomeIcon can be a binding rather than entirely relying on views to determine an icon.
This also allows for testing logic. For example using a specific icon for each company type which can be verifying used tests.
[ This is probably an issue from the upstream FontAwesome.WPF project; I'm not sure if you'd rather I file it there. ]
I'm trying to port some old Windows Forms FontAwesome code to hook into FontAwesome5's CreateImageSource
instead. My hope is to throw away a lot of legacy code. Ultimately, the public method that gets called looks like this:
public static WinFormsImage GetImage(EFontAwesomeIcon icon, int size, int padding,
WinFormsColor foreColor, WinFormsColor backColor);
So the goal is to render a bitmap using CreateImageSource
, then convert that into a Windows Forms / System.Drawing bitmap.
However, I'm running into a few issues with the way CreateImageSource
renders the icon. As an example, here are three icons rendered by my old code:
And here's how the same icons are rendered by FontAwesome5:
Some of it I probably need to adjust on my end, but the big issue I haven't figured out is that the stroke has become way too thick. I think I would need to adjust two things:
The above image was produced by the following code:
var drawingVisual = new DrawingVisual();
// seems to have no effect
TextOptions.SetTextFormattingMode(drawingVisual, TextFormattingMode.Display);
TextOptions.SetTextHintingMode(drawingVisual, TextHintingMode.Fixed);
TextOptions.SetTextRenderingMode(drawingVisual, TextRenderingMode.Grayscale);
using (var drawingContext = drawingVisual.RenderOpen())
{
drawingContext.DrawRectangle(Brushes.Transparent, null, new Rect(0, 0, 16, 64));
int i = 0;
foreach (var item in new[] { EFontAwesomeIcon.Solid_Broom, EFontAwesomeIcon.Solid_Calculator,
EFontAwesomeIcon.Regular_Calendar, EFontAwesomeIcon.Solid_EllipsisH })
{
var iconImageSource = ImageAwesome.CreateImageSource(item, Brushes.Black, imageSize);
drawingContext.DrawImage(iconImageSource, new Rect(0, 16 * i, 16, 16));
i++;
}
}
var someBitmap = new RenderTargetBitmap(16, 64, 96, 96, PixelFormats.Default);
someBitmap.Render(drawingVisual);
using (var fs = File.OpenWrite($"fontawesome-test.png"))
{
var encoder = new PngBitmapEncoder();
encoder.Frames.Add(BitmapFrame.Create(someBitmap));
encoder.Save(fs);
}
As you can see, I tried to configure text rendering, but this appears to have no effect. I'm also not sure how to pass a virtual size. Setting higher DPIs on RenderTargetBitmap
doesn't appear to have the desired effect.
I think this needs to be fixed / made adjustable inside the CreateImageSource
() implementation. There is a FormattedText
constructor that allows setting the TextFormattingMode
, and this might help.
Do you have any guidance to produce a 'thinner', higher-quality stroke from CreateImageSource
? Am I better off implementing this by myself?
Hi,
I was using version "2.1.4" in an application "net6.0-windows10.0.19041.0" and it was working normally, but when I update the version to "2.1.5 or 2.1.6" the application starts to show a error:
I tried to update the framework version to "net 6.0-windows 10.0.22000.0", but it didn't work.
Were any changes made to versions "2.1.5" or "2.1.6" to cause this error to occur?
Regards
Here's the Style:
<Style x:Key="CopyButton" TargetType="{x:Type Button}"> <Setter Property="Background" Value="Transparent" /> <Setter Property="BorderBrush" Value="Transparent" /> <Setter Property="Content"> <Setter.Value> <fa:FontAwesome FontSize="10" Foreground="{StaticResource ButtonBackground}" Icon="Solid_Copy" /> </Setter.Value> </Setter> <Setter Property="HorizontalAlignment" Value="Left" /> <Setter Property="VerticalAlignment" Value="Top" /> </Style>
<Grid HorizontalAlignment="Stretch" Margin="8"> <Grid.ColumnDefinitions> <ColumnDefinition MinWidth="400" Width="Auto" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="Auto" /> <ColumnDefinition Width="*" /> </Grid.ColumnDefinitions> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> <RowDefinition Height="Auto" /> </Grid.RowDefinitions> <StackPanel Orientation="Horizontal"> <TextBlock x:Name="tEmail" FontSize="16" FontWeight="Bold" Text="{Binding EmailAddress, Mode=OneTime}" /> <Button Command="{Binding CopyCommand, Mode=OneTime}" CommandParameter="{Binding ElementName=tEmail, Path=Text}" Style="{DynamicResource CopyButton}" /> </StackPanel> <StackPanel Grid.Column="1" Orientation="Horizontal"> <TextBlock FontWeight="Bold" Text="{Binding CustomerID, Mode=OneTime, StringFormat=Customer ID: {0:}}" /> <Button Command="{Binding CopyCommand, Mode=OneTime}" CommandParameter="{Binding CustomerID, Mode=OneTime}" Style="{DynamicResource CopyButton}" /> </StackPanel> <StackPanel Grid.ColumnSpan="2" Grid.Row="2" Orientation="Horizontal"> <TextBlock Text="{Binding FirstName, Mode=OneTime}" /> <Button Command="{Binding CopyCommand, Mode=OneTime}" CommandParameter="{Binding FirstName, Mode=OneTime}" Style="{DynamicResource CopyButton}" /> <TextBlock Text="{Binding LastName, Mode=OneTime}" /> <Button Command="{Binding CopyCommand, Mode=OneTime}" CommandParameter="{Binding LastName, Mode=OneTime}" Style="{DynamicResource CopyButton}" /> </StackPanel> </Grid>
This is the ItemTemplate for a ListView. When it renders, only the last Icon in each ListViewItem renders.
Duotone icons have multiple paths;
"path": [
"M192 440h-32v-48h32zM160 72v48h32V72zm96 160v48h32v-48zm-96 0v48h32v-48zm96 208h160v-48H256zm96-160h128v-48H352zM544 0a32 32 0 0 0-32 32v464a16 16 0 0 0 16 16h32a16 16 0 0 0 16-16V32a32 32 0 0 0-32-32zM416 72H256v48h160zM32 0A32 32 0 0 0 0 32v464a16 16 0 0 0 16 16h32a16 16 0 0 0 16-16V32A32 32 0 0 0 32 0z",
"M144 32h-32a16 16 0 0 0-16 16v96a16 16 0 0 0 16 16h32a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16zm96 0h-32a16 16 0 0 0-16 16v96a16 16 0 0 0 16 16h32a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16zm-96 160h-32a16 16 0 0 0-16 16v96a16 16 0 0 0 16 16h32a16 16 0 0 0 16-16v-96a16 16 0 0 0-16-16zm192 0h-32a16 16 0 0 0-16 16v96a16 16 0 0 0 16 16h32a16 16 0 0 0 16-16v-96a16 16 0 0 0-16-16zm-96 0h-32a16 16 0 0 0-16 16v96a16 16 0 0 0 16 16h32a16 16 0 0 0 16-16v-96a16 16 0 0 0-16-16zM464 32h-32a16 16 0 0 0-16 16v96a16 16 0 0 0 16 16h32a16 16 0 0 0 16-16V48a16 16 0 0 0-16-16zM144 352h-32a16 16 0 0 0-16 16v96a16 16 0 0 0 16 16h32a16 16 0 0 0 16-16v-96a16 16 0 0 0-16-16zm96 0h-32a16 16 0 0 0-16 16v96a16 16 0 0 0 16 16h32a16 16 0 0 0 16-16v-96a16 16 0 0 0-16-16zm224 0h-32a16 16 0 0 0-16 16v96a16 16 0 0 0 16 16h32a16 16 0 0 0 16-16v-96a16 16 0 0 0-16-16z"
]
Regular icons just singular
"path": "M103.3 344.3c-6.5-14.2-6.9-18.3 7.4-23.1 25.6-8 8 9.2 43.2 49.2h.3v-93.9c1.2-50.2 44-92.2 97.7-92.2 53.9 0 97.7 43.5 97.7 96.8 0 63.4-60.8 113.2-128.5 93.3-10.5-4.2-2.1-31.7 8.5-28.6 53 0 89.4-10.1 89.4-64.4 0-61-77.1-89.6-116.9-44.6-23.5 26.4-17.6 42.1-17.6 157.6 50.7 31 118.3 22 160.4-20.1 24.8-24.8 38.5-58 38.5-93 0-35.2-13.8-68.2-38.8-93.3-24.8-24.8-57.8-38.5-93.3-38.5s-68.8 13.8-93.5 38.5c-.3.3-16 16.5-21.2 23.9l-.5.6c-3.3 4.7-6.3 9.1-20.1 6.1-6.9-1.7-14.3-5.8-14.3-11.8V20c0-5 3.9-10.5 10.5-10.5h241.3c8.3 0 8.3 11.6 8.3 15.1 0 3.9 0 15.1-8.3 15.1H130.3v132.9h.3c104.2-109.8 282.8-36 282.8 108.9 0 178.1-244.8 220.3-310.1 62.8zm63.3-260.8c-.5 4.2 4.6 24.5 14.6 20.6C306 56.6 384 144.5 390.6 144.5c4.8 0 22.8-15.3 14.3-22.8-93.2-89-234.5-57-238.3-38.2zM393 414.7C283 524.6 94 475.5 61 310.5c0-12.2-30.4-7.4-28.9 3.3 24 173.4 246 256.9 381.6 121.3 6.9-7.8-12.6-28.4-20.7-20.4zM213.6 306.6c0 4 4.3 7.3 5.5 8.5 3 3 6.1 4.4 8.5 4.4 3.8 0 2.6.2 22.3-19.5 19.6 19.3 19.1 19.5 22.3 19.5 5.4 0 18.5-10.4 10.7-18.2L265.6 284l18.2-18.2c6.3-6.8-10.1-21.8-16.2-15.7L249.7 268c-18.6-18.8-18.4-19.5-21.5-19.5-5 0-18 11.7-12.4 17.3L234 284c-18.1 17.9-20.4 19.2-20.4 22.6z"
}
This causes deserialisation errors as the SVG path doesn't accomodate this.
public class SVG
{
public string[] viewBox { get; set; }
public int width { get; set; }
public int height { get; set; }
public string path { get; set; }
}
I tried to use the ImageSourceConverter in my application but it doesn't work.
I tried with Source:
<Style x:Key="FormFieldInformationIcon" TargetType="{x:Type Image}">
<Setter Property="Source" Value="{Binding Path=EFontAwesomeIcon, Source=Solid_InfoCircle, Converter={fa5:ImageSourceConverter}}" />
</Style>
And also with Path:
<Style x:Key="FormFieldInformationIcon" TargetType="{x:Type Image}">
<Setter Property="Source" Value="{Binding Path=EFontAwesomeIcon.Solid_InfoCircle, Converter={fa5:ImageSourceConverter}}" />
</Style>
Currently FA5 has the icons cart-plus and cart-arrow-down. But oddly enough, their opposites - cart-minus and cart-arrow-up, seem to be missing.
Is it a good idea to create these two new icons?
If there is a basic tutorial on how to do it, I am happy to do it.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.