Giter VIP home page Giter VIP logo

font-awesome-wpf's Introduction

Font-Awesome-WPF/UWP

WPF & UWP controls for the iconic font and CSS toolkit Font Awesome.

Font Awesome: http://fortawesome.github.io/Font-Awesome/

  • Current Version: v4.7.0

WPF

Font-Awesome-WPF README

UWP

Font-Awesome-UWP README

License

The MIT License (MIT)

Copyright (c) 2014-2016 charri

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

font-awesome-wpf's People

Contributors

charri avatar drewnoakes avatar giuseppepiscopo avatar krzysztofdul avatar mendelmonteiro avatar mihamarkic avatar punker76 avatar robertmuehsig avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

font-awesome-wpf's Issues

How to add additional images to FontAwesome.WPF

I would like I have the capability to add more images to this library to be used as default. Is there an easy way to do this? Moreover, suppose I have a pro license of font awesome. then is it easy to attach this library to my license

Get Icon By ID

Would it be possible to generate a function that receives string representing the ID of the icon, as can be found on https://fortawesome.github.io/Font-Awesome/icons/ , and returns the enum that can be bound in a fa:ImageAwesome tag?
If the string does not match with any valid icon, I'd imagine the function returning 'question', though maybe a second parameter could accept the preferred "error" icon, in the form of the enum.

Scaling down image messes with icon weights

ImageAwesome internally renders the glyph at 100x100 px, then scales it down to the target size (assuming it's less than 100px).

However this messes with the font weights. Consider this example (from here):

image

At small sizes, the typeface designer provides hints on how to map lines and details to pixels. At larger sizes, the icon feels heavier. When you scale it down, it ends up looking bold, fuzzy and without sharp detail.

Instead, ImageAwesome should render at the required size, so no scaling occurs. The underlying Image.StretchDirection should have its metadata overridden, setting the default to StretchDirection.None.

Crisp icons at 96 DPI due to typeface hinting is one of the reasons to use fonts over the equivalent paths/geometry. By rendering the glyph at the wrong size, this benefit goes away.

Changing icon color in XAML

I want to use the refresh spinning icon but I want to set its color to white.
I tried editing the code around but failed to implement it. here's my code it would be awesome if there was a color attribute.
<fa:ImageAwesome Icon="Refresh" Spin="True" Height="48" Width="48" />

FontAwesome 4.7/4.6

Hi

I noticed that there are a bunch of nice new icons added in FontAwesome 4.6/4.7 and I would like to help to update this project to the most recent fontawesome version.

Are these the correct steps?

  • Update the FontAwesome submodule to the most recent version
  • Use FontAwesome.Generate with the src\icons.yml
  • Update the FotnAwesomeIcon.cs files with the generated one
  • Update the nuspec files
  • make pull request

Regarding the NuGet version - did you align the version number to the FontAwesome version number or was there semver in mind?

Strange error on windows server 2012

I've faced with strange error I get on windows server 2012.
System.Windows.Markup.XamlParseException: Задание свойства "FontAwesome.WPF.ImageAwesome.Icon" вызвало исключение. ---> System.Reflection.TargetInvocationException: Адресат вызова создал исключение. в System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo) в System.Runtime.InteropServices.Marshal.ThrowExceptionForHR(Int32 errorCode, IntPtr errorInfo) в MS.Internal.Text.TextInterface.Native.Util.ConvertHresultToException(Int32 hr) в MS.Internal.Text.TextInterface.Factory.GetFontCollection(Uri uri) в MS.Internal.FontCache.DWriteFactory.GetFontCollectionFromFileOrFolder(Uri fontCollectionUri, Boolean isFolder) в MS.Internal.FontCache.FamilyCollection.FromUri(Uri folderUri) в System.Windows.Media.FontFamily.LookupFontFamilyAndFace(CanonicalFontFamilyReference canonicalFamilyReference, FontStyle& style, FontWeight& weight, FontStretch& stretch) в System.Windows.Media.FontFamily.FindFirstFontFamilyAndFace(FontStyle& style, FontWeight& weight, FontStretch& stretch) в System.Windows.Media.Typeface.ConstructCachedTypeface() в System.Windows.Media.Typeface.get_CachedTypeface() в System.Windows.Media.Typeface.CheckFastPathNominalGlyphs(CharacterBufferRange charBufferRange, Double emSize, Single pixelsPerDip, Double scalingFactor, Double widthMax, Boolean keepAWord, Boolean numberSubstitution, CultureInfo cultureInfo, TextFormattingMode textFormattingMode, Boolean isSideways, Boolean breakOnTabs, Int32& stringLengthFit) в MS.Internal.TextFormatting.SimpleRun.CreateSimpleTextRun(CharacterBufferRange charBufferRange, TextRun textRun, TextFormatterImp formatter, Int32 widthLeft, Boolean emergencyWrap, Boolean breakOnTabs, Double pixelsPerDip) в MS.Internal.TextFormatting.SimpleRun.Create(FormatSettings settings, CharacterBufferRange charString, TextRun textRun, Int32 cp, Int32 cpFirst, Int32 runLength, Int32 widthLeft, Int32 idealRunOffsetUnRounded, Double pixelsPerDip) в MS.Internal.TextFormatting.SimpleTextLine.Create(FormatSettings settings, Int32 cpFirst, Int32 paragraphWidth, Double pixelsPerDip) в MS.Internal.TextFormatting.TextFormatterImp.FormatLineInternal(TextSource textSource, Int32 firstCharIndex, Int32 lineLength, Double paragraphWidth, TextParagraphProperties paragraphProperties, TextLineBreak previousLineBreak, TextRunCache textRunCache) в MS.Internal.TextFormatting.TextFormatterImp.FormatLine(TextSource textSource, Int32 firstCharIndex, Double paragraphWidth, TextParagraphProperties paragraphProperties, TextLineBreak previousLineBreak) в System.Windows.Media.FormattedText.LineEnumerator.FormatLine(TextSource textSource, Int32 textSourcePosition, Double maxLineLength, TextParagraphProperties paraProps, TextLineBreak lineBreak) в System.Windows.Media.FormattedText.LineEnumerator.MoveNext() в System.Windows.Media.FormattedText.DrawAndCalculateMetrics(DrawingContext dc, Point drawingOffset, Boolean getBlackBoxMetrics) в System.Windows.Media.FormattedText.Draw(DrawingContext dc, Point origin) в System.Windows.Media.DrawingContext.DrawText(FormattedText formattedText, Point origin) в FontAwesome.WPF.ImageAwesome.CreateImageSource(FontAwesomeIcon icon, Brush foregroundBrush, Double emSize) в FontAwesome.WPF.ImageAwesome.OnIconPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) в System.Windows.DependencyObject.OnPropertyChanged(DependencyPropertyChangedEventArgs e) в System.Windows.FrameworkElement.OnPropertyChanged(DependencyPropertyChangedEventArgs e) в System.Windows.DependencyObject.NotifyPropertyChange(DependencyPropertyChangedEventArgs args) в System.Windows.DependencyObject.UpdateEffectiveValue(EntryIndex entryIndex, DependencyProperty dp, PropertyMetadata metadata, EffectiveValueEntry oldEntry, EffectiveValueEntry& newEntry, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType) в System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal) в System.Windows.Baml2006.WpfMemberInvoker.SetValue(Object instance, Object value) в MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(XamlMember member, Object obj, Object value) в MS.Internal.Xaml.Runtime.ClrObjectRuntime.SetValue(Object inst, XamlMember property, Object value) --- Конец трассировки внутреннего стека исключений --- в System.Windows.Markup.WpfXamlLoader.Load(XamlReader xamlReader, IXamlObjectWriterFactory writerFactory, Boolean skipJournaledProperties, Object rootObject, XamlObjectWriterSettings settings, Uri baseUri) в System.Windows.Markup.WpfXamlLoader.LoadBaml(XamlReader xamlReader, Boolean skipJournaledProperties, Object rootObject, XamlAccessLevel accessLevel, Uri baseUri) в System.Windows.Markup.XamlReader.LoadBaml(Stream stream, ParserContext parserContext, Object parent, Boolean closeStream) в System.Windows.Application.LoadComponent(Object component, Uri resourceLocator) в KX.CharterMaster.Diag2.zmKlOtQD67C43y0SSdO(Object , Object ) в KX.CharterMaster.Diag2.InitializeComponent() в F:\projects\mt\CharterMaster\CharterMaster.App\CharterMaster45\Diag2.xaml:строка 1 в KX.CharterMaster.Diag2..ctor() в KX.CharterMaster.Application.nHfG9eduq(Object , StartupEventArgs ) в F:\projects\mt\CharterMaster\CharterMaster.App\CharterMaster45\Application.xaml.vb:строка 241 в System.Windows.Application.OnStartup(StartupEventArgs e) в System.Windows.Application.<.ctor>b__1_0(Object unused) в System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs) в System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)

Here is the xaml
<Window x:Class="Diag2" 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:local="clr-namespace:KX.CharterMaster" mc:Ignorable="d" Title="Diag2" Height="300" Width="300" xmlns:fa="http://schemas.fontawesome.io/icons/" > <Grid Margin="20"> <fa:ImageAwesome Icon="Flag" VerticalAlignment="Center" HorizontalAlignment="Center" /> </Grid> </Window>

If I comment
<fa:ImageAwesome Icon="Flag" VerticalAlignment="Center" HorizontalAlignment="Center" />
program starts nurmaly.

Misnamed Icon

Icon fa-folder-open-o is listed under FolderOutlinepenOutline. Note the missing "O" in "Open."

Universal Windows Platform Support

Even if the project is named and targets WPF - are you planning to support UWP projects as well?

When I try to install the package it fails:
FontAwesome.WPF 4.5.0.7 is not compatible with UAP,Version=v10.0.
Some packages are not compatible with UAP,Version=v10.0.

Maybe the code could "just work" on UWP and just the NuGet Package needs some updated targets.

ImageSourceConverter not usable as MarkupExtension ?

Hi @charri
Maybe I used it wrong but to my understanding the FontAwesome.WPF.Converters.ImageSourceConverter which inherits from MarkupExtension cannot be used as such since its ProvideValue Function returns a this refrence.

Would it be possible to adapt it a little bit so it would be usable as a MarkupExtension ?

Right now I use this as a MarkupExtension :

`
public class ImageSourceFromFont : MarkupExtension
{
private FontAwesomeIcon _icon;
private Brush _brush = new SolidColorBrush(Colors.Black);

    public FontAwesomeIcon Icon
    {
        get { return _icon; }
        set { _icon = value; }
    }

    public Brush IconBrush
    {
        get { return _brush; }
        set { _brush = value; }
    }


    public override object ProvideValue(IServiceProvider serviceProvider)
    {
        return ImageAwesome.CreateImageSource(Icon, IconBrush);
    }

`

TextBlock font overlap bug

TextBlock icons are sometimes placed outside of actual UIElement (apparent when clipping), probably something to do with LineHeight.

Example doesn't build

In the newer version (4.2.0.2) the example doesn't build. The Spin property is missing, and the references are incorrect in the xaml files.

image

Visual Studio 2013 Ultimate

Cannot resolve schemas.fontawesome.io

I have added FontAwesome.WPF via Nuget (version 4.4.0.5). I'm getting the following errors when trying to use it inside my XAML:

The type 'fa:FontAwesome' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.
Unknown type 'FontAwesome' in XML namespace 'http://schemas.fontawesome.io/icons/'

When I try to ping schemas.fontawesome.io it fails to resolve the name.

Does not get a style

I tried the FontAwesome.UWP.
Unfortunately it does not get a style:

<Style x:Name="stlFontAwesome" TargetType="fa:FontAwesome">
                <Setter Property="FontSize" Value="40"/>
                <Setter Property="Foreground" Value="White"/>
                <Setter Property="HorizontalAlignment" Value="Center"/>
                <Setter Property="VerticalAlignment" Value="Center"/>
</Style>

And then:

<fa:FontAwesome x:Name="iPause" 
                Icon="Pause"
                Grid.Column="0"
                Style="{StaticResource stlFontAwesome}"
                Visibility="Collapsed"
                />

Nor alignment or a font size.
In addition, it's invisible in design mode, before program running.

Image = FontAwesome Image?

Hey, great work on this.

I have recently added this to my app and have removed quite a lot of images I designed myself in favor of this. I'm wanting to use this in collaboration with Material Menu, which can set an Image in the MenuButton Control ie:

<materialMenu:MenuButton Text="Settings" Image=""/>

I was wondering if there was a way in the xaml to have it use a fontAwesome image? Or would this have to be set in the code behind?

Many thanks.

Icons not visible in design time (UWP)

The icons works fine when in runtime. But at design time they're not visible, making the design pretty annoying. I'm using VS2017 Community Edition.

Here's my Xaml
<fa:FontAwesome Icon="Backward" Foreground="Black" />

CssClassNameConverter should also accept "fa-" prefixed class names

For example, from http://fontawesome.io/icon/wpforms/:

image

The string used on the site is fa-wpforms, but CssClassNameConverter expects wpforms.

I worked around this with code such as:

var faConverter = new CssClassNameConverter();

var converter = LambdaConverter.Create<string>(s =>
{
    if (s.StartsWith("fa-"))
        s = s.Substring(3);
    return faConverter.Convert(s, typeof(FontAwesomeIcon), null, null);
});

But it would be better if the library did this.

Is this still being managed and updated?

Good Day!

This looks incredible, but I'm concerned that it isn't updated to 5.x (won't worry about beta 6.X). I would like to use this going forward, but with additional icons being added, I wonder.

Support .NET Standard

With .NET Core 3.1, WPF is now supported on the much lighter CoreFx runtime. This is still limited to running on Windows, though this support will be maintained for the forseeable future.

We have two options for implementation:

NetFx 4.5.0 is compatible with NetStandard 1.1. NetFx 3.x is not compatible with NetStandard at all. As such, to maintain current support, we could multi-target 4.5.0 and NetStandard 1.1. This change should theoretically be a one-line change.

Option two is to add a new project targeting NetStandard 2.1, as this is compatible with CoreFx 3.1 and future releases (.NET 5+), however we lose all support for NetFx.

I understand that with the numerous legacy WPF apps, maintaining backwards compatibility is a priority, and as such I would personally recommend option one. This would allow us to target NetFx 4.5.0 and later, including all past, present, and future versions of CoreFx.

The most ideal situation is to do both - NetStandard 1.1 to maintain backwards compatibility and NetStandard 2.1 to support newer releases and even eventually .NET 5, but if this is decided upon it's likely best to split this into two issues.

I do not know the state of UWP on NetCore, since it's not a technology that I am familiar with using, though it may be worth looking into implementation there as well.

nuget: Assembly not inside a framework folder.

Description: The assembly 'lib\FontAwesome.WPF.dll' is placed directly under 'lib' folder. It is recommended that assemblies be placed inside a framework-specific folder.
Solution: Move it into a framework-specific folder. If this assembly is targeted for multiple frameworks, ignore this warning.

TextBlock code-behind

There's an example of setting an icon, but none of TextBlock purely in code-behind, how would I do that? so far in my attempts the binding error is FontAwesomeIcon property not found on 'object'.

Problem with multiple views in UWP

On using the FontAwesome controls in XAML in multiple views, I am getting crashes. I looked at the code, and I believe the problem to be the use of a static FontFamily object which is getting shared across multiple dispatcher threads.

I tried replacing this shared FontFamily object with a ConcurrentDictionary with the dispatcher as key, and FontFamily as value, which means each dispatcher thread gets it's own FontFamily. This resolved my problem, and I'd be happy to commit the fix.

Conditional Icon Binding on DataGrid

I am trying to conditionally display icons using the below code.

<DataGridTemplateColumn Header="Level">
    <DataGridTemplateColumn.CellTemplate>
        <DataTemplate>
            <fa:FontAwesome Icon="Warning"></fa:FontAwesome>
            <DataTemplate.Triggers>
                <DataTrigger Binding="{Binding Path=IsError}" Value="True">
                    <Setter Property="Icon" Value="Stop" />
                </DataTrigger>
            </DataTemplate.Triggers>
        </DataTemplate>
    </DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>

I am not even able to compile this due to the error
The member "Icon" is not recognized or is not accessible.

Can someone suggest a way to do this?

unable to reset spinning icon

While data Loading process, by making iconObj.spin = true and providing spin duration, Icon starts spinning.
later at completion i am trying to replace spinning icon by check icon and making iconObj.spin = false. But check icon is getting displayed in random angles. and i am not able to reset that angle.

Attached images for reference, anyone can validate this, if there is a way to reset the angle please let me know.
1 (consider this as a spinning icon)

2

Adapting parent foreground

When using in other control (like ContentControl) ImageAwesome does not use the foreground provided by the parent.

Example:

    <ContentControl Foreground="Red">
        <TextBlock Text="FontAwesome" />
    </ContentControl>`

This gives you a red TextBlock.

    <ContentControl Foreground="Red">
        <fa:ImageAwesome Icon="FontAwesome" />
    </ContentControl>`

This gves you a black image, which should be red.

I'm using FontAwesome.WPF in version 4.7.0.9

Changing button background on hover (WPF)

Hello fellow Font-Awesome fans:

I am using the WPF for my buttons in the following way:

<StackPanel Grid.Row="1" Grid.Column="2" VerticalAlignment="Center">
            <Button Style="{StaticResource DefaultIcon}" fa:Awesome.Content="AngleDoubleRight" Command="{Binding SelectHeaderCommand}"></Button>
            <Button Style="{StaticResource DefaultIcon}" fa:Awesome.Content="AngleDoubleLeft" Command="{Binding RevertSelectHeaderCommand}"></Button>
        </StackPanel>

Now I would like to have the default hover change, since i have a transparent background already and only want the icon to change color, not the background:

I do not know what i need to fill in here, and how i could make the Content from the button filled in xaml pass through all the way to my template.

<Style TargetType="{x:Type Button}" BasedOn="{StaticResource MenuIcon}" x:Key="DefaultIcon">
        <Setter Property="FontSize" Value="25"></Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <Border Padding="{TemplateBinding Padding}" Background="{TemplateBinding Background}">
                        <!-- What should be filled in here? -->
   <fa:FontAwesome Icon="{TemplateBinding fa:Awesome.Content}"></fa:FontAwesome>
                    </Border>
                   
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="Red"></Setter>
                <Setter Property="Foreground" Value="{StaticResource ForegroundBlueBrush}"></Setter>
            </Trigger>
        </Style.Triggers>
    </Style>`
``

Use grayscale antialiasing

Hi!

I notice that it uses ClearType (colored) antialiasing to render icons. Which is good for text, but bad for icons. Is there a way to use grayscale antialiasing?
cleartype

How to use FontAwesome.WPF when image source URI is required

I have a situation where I need a URI as an IconSource. How can I use FontAwesom.WPF in this situation?

Details:
"Extended WPF Toolkit" AvalonDock LayoutAnchorable has a property to set the panel icon ("IconSource") which requires a URI. The property does not allow binding. I want to use a FontAwesom icon as the panel icon.

<xcad:DockingManager>
    <xcad:LayoutRoot x:Name="LayoutRoot">
        <xcad:LayoutPanel Orientation="Horizontal">
            <xcad:LayoutAnchorablePane DockMinWidth="200">
                <xcad:LayoutAnchorable ContentId="Properties" Title="Properties" IconSource=" ??? ">
                    . . .
                </xcad:LayoutAnchorable>
            </xcad:LayoutAnchorablePane>
        </xcad:LayoutPanel>
    </xcad:LayoutRoot>
</xcad:DockingManager>

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.