Skip to content

Instantly share code, notes, and snippets.

@atheken
Created June 14, 2014 12:19
Show Gist options
  • Save atheken/1feda1fcd3aad4346fdc to your computer and use it in GitHub Desktop.
Save atheken/1feda1fcd3aad4346fdc to your computer and use it in GitHub Desktop.
Xamarin iOS FontLoader for more fluent font creation/management.
public class FontCreator
{
private string _fontName;
private Dictionary<float, UIFont> _lookup = new Dictionary<float, UIFont> ();
public FontCreator (string fontName)
{
_fontName = fontName;
}
public UIFont this [float size] {
get {
UIFont retval;
if (!_lookup.TryGetValue (size, out retval)) {
retval = UIFont.FromName (_fontName, size);
_lookup [size] = retval;
}
return retval;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment