Skip to content

Instantly share code, notes, and snippets.

@Char0394
Created June 28, 2017 03:04
Show Gist options
  • Select an option

  • Save Char0394/9838f3b2a8dac2a06e4438b10f7e2fcb to your computer and use it in GitHub Desktop.

Select an option

Save Char0394/9838f3b2a8dac2a06e4438b10f7e2fcb to your computer and use it in GitHub Desktop.
using System;
using Android.Graphics;
using FontSample.Droid;
using Xamarin.Forms;
using Xamarin.Forms.Platform.Android;
[assembly: ExportRenderer(typeof(Label), typeof(CustomLabelRenderer))]
namespace FontSample.Droid
{
public class CustomLabelRenderer: LabelRenderer
{
protected override void OnElementChanged(ElementChangedEventArgs<Label> e)
{
base.OnElementChanged(e);
if (Control == null)
return;
if (!String.IsNullOrEmpty(Element.FontFamily))
Control.Typeface = Typeface.CreateFromAsset(Forms.Context.Assets, Element.FontFamily + ".ttf");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment