Created
June 14, 2014 12:19
-
-
Save atheken/1feda1fcd3aad4346fdc to your computer and use it in GitHub Desktop.
Xamarin iOS FontLoader for more fluent font creation/management.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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