Weirdly I can create the font correctly, but the uiFont is null on the first file below, I get a font and a uiFont for the second file. Both files are in a folder called Resources with a Build Action of BundleResources. Any idea why this is happening?
Fonts were downloaded from here: https://github.com/google/fonts/tree/master/apache/opensans
This doesn't work:
var data = NSData.FromFile("OpenSans-Light.ttf");
var provider = new CGDataProvider(data);
var font = CGFont.CreateFromProvider(provider);
var uiFont = UIFont.FromName(font.PostScriptName, 44f);
This works:
var data = NSData.FromFile("OpenSans-Regular.ttf");
var provider = new CGDataProvider(data);
var font = CGFont.CreateFromProvider(provider);
var uiFont = UIFont.FromName(font.PostScriptName, 44f);
It was because I didn't add the light font to the info.plist