Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for Icon Fonts #1

Open
robinmanuelthiel opened this issue Dec 17, 2017 · 9 comments
Open

Support for Icon Fonts #1

robinmanuelthiel opened this issue Dec 17, 2017 · 9 comments

Comments

@robinmanuelthiel
Copy link
Owner

No description provided.

@acaliaro
Copy link

acaliaro commented Mar 9, 2018

this should be a dream!

@acaliaro
Copy link

acaliaro commented Mar 9, 2018

I try for this... can I?

@robinmanuelthiel
Copy link
Owner Author

Yeah, please feel free do. Would love to see a PR on this. I was looking at font-awesome. Ping me here if you need any help or code explanations!

@acaliaro
Copy link

acaliaro commented Mar 9, 2018

do you think is it possible to use https://github.com/jsmarcus/Iconize

@robinmanuelthiel
Copy link
Owner Author

It would be possible to leverage Jeremy's work for sure. But I want to keep the dependencies of this library as few as possible. So I would prefer to implement it as shown here: https://forums.xamarin.com/discussion/31530/fontawesome-label-heres-how

@acaliaro
Copy link

@robinmanuelthiel is it now possible to use Icon Fonts?

@julianpaulozzi
Copy link

If you want to display only the icon with Iconize this behavior should work:

    public class FlexButtonFontIcon
    {
        public static readonly BindableProperty IconProperty =
            BindableProperty.Create(
                @"Icon",
                typeof(string), 
                typeof(FlexButtonFontIcon), 
                default(string),
                propertyChanged: IconPropertyChanged);
        
        public static void SetIcon(BindableObject view, string value)
        {
            view.SetValue(IconProperty, value);
        }

        public static string GetIcon(BindableObject view)
        {
            return (string)view.GetValue(IconProperty);
        }

        private static void IconPropertyChanged(BindableObject bindable, object oldvalue, object newvalue)
        {
            var iconKey = newvalue as string;
            if (!(bindable is FlexButton view) || string.IsNullOrWhiteSpace(iconKey))
                return;
            
            var icon = Iconize.FindIconForKey(iconKey);
            if (icon != null)
            {
                var iconModule = Iconize.FindModuleOf(icon);
                view.FontFamily = $"{iconModule.FontPath}#{iconModule.FontName}";
                view.Text = $"{icon.Character}";
            }
        }
    }

Then just add on button:

<flex:FlexButton local:FlexButtonFontIcon.Icon="icon-name" FontSize="26"/>

@acaliaro
Copy link

WoW

@hellyab
Copy link

hellyab commented Sep 6, 2020

I am setting the Icon using FontImageSource and it works just fine.
Followed this article by @jamesmontemagno to add the Font Icons to my project.
<flex:FlexButton.Icon> <FontImageSource Glyph="&#xe902;" FontFamily="{StaticResource MaterialFontFamily}"/> </flex:FlexButton.Icon>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants