I am trying to render a CATextLayer with a string with kerning and a specific font. If I set the font using the CATextLayer, the font does not render correctly. If I set the font in the CTStringAttributes then I get the following error:
Unhandled Exception:
MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown.
Name: NSInvalidArgumentException
Reason: -[__NSCFType screenFontWithRenderingMode:]: unrecognized selector sent to instance 0x13dba570
Here is the code I am trying to use:
CTStringAttributes ctsa = new CTStringAttributes();
//This method returns what out kerning should be loosely based on the
//tracking number our UI designer uses in Adobe Illustrator
var trackingSize = MyFonts.IllustratorTracking(200f * 0.8f,
MyFonts.CardHeader.PointSize);
ctsa.KerningAdjustment = trackingSize;
ctsa.ForegroundColor = MyColors.CardHeaderText.CGColor;
ctsa.Font = MyFonts.CardHeaderCT;
NSAttributedString someString = new NSAttributedString(title, ctsa);
titleLayer = new CATextLayer();
titleLayer.Frame = new RectangleF(19, ((20 - someString.Size.Height) / 2.0f),
someString.Size.Width,
someString.Size.Height);
titleLayer.ForegroundColor = MyColors.CardHeaderText.CGColor;
titleLayer.BackgroundColor = UIColor.Clear.CGColor;
titleLayer.AttributedString = someString;
headerView.Layer.AddSublayer(titleLayer);