Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 58056

set Custom Font in correct way

$
0
0

I've achieved the purpose of setting Custom Font to each platform by official doc : http://developer.xamarin.com/guides/cross-platform/xamarin-forms/working-with/fonts/

what I want to do:I need set custom font to every element for my app, not only label but button text and etc.

1.On Android Platform, I modified the [assembly: ExportRenderer(typeof(Label), typeof(MyLabelRenderer))] so that default label font would be custom font.It works.

2.On WinPhone Platform,by the code below, it will work for WinPhone but not for Android(after option1 above), anything can I modify the Argument Font(Android) for the function Device.OnPlatform() so Android would works like option1 above???

new Label {
    Text = "Hello, Forms!",
    Font = Device.OnPlatform (
        Font.SystemFontOfSize (NamedSize.Small),
        Font.SystemFontOfSize (NamedSize.Medium),
        Font.OfSize (@"\Assets\Fonts\SF Hollywood Hills.ttf#SF Hollywood Hills",
             NamedSize.Large) // Windows Phone will use this custom font
    )
}

last : about option2 above, must I set Font for every label if I use the custom font??? Any better way to do this???


Viewing all articles
Browse latest Browse all 58056

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>