[Culture("en")] // fails for some cultures, e.g. ar-AE public void StringSize_5() { nfloat actualFontSize = 12; var f = UIFont.BoldSystemFontOfSize(actualFontSize); try { using (NSString s = new NSString("s")) { var size = s.StringSize(f, 6, ref actualFontSize, 10, UILineBreakMode.MiddleTruncation); Assert.That(actualFontSize, Is.EqualTo((nfloat)12), "actualFontSize"); Assert.That(size.Width, Is.InRange((nfloat)6f, (nfloat)7f), "Width"); Assert.That(size.Height, Is.InRange((nfloat)14f, (nfloat)15f), "Height"); } using (NSString s = new NSString("saterlipopette")) { var size = s.StringSize(f, 6, ref actualFontSize, 10, UILineBreakMode.MiddleTruncation); Assert.That(actualFontSize, Is.EqualTo((nfloat)6), "actualFontSize-2"); Assert.That(size.Width, Is.InRange((nfloat)5f, (nfloat)10f), "Width-2"); Assert.That(size.Height, Is.InRange((nfloat)14f, (nfloat)15f), "Height-2"); } } catch { Console.WriteLine("StringSize_5: actualFontSize: {0} font: {1}", actualFontSize, f); throw; } }
[Culture("en")] // fails for some cultures, e.g. ar-AE public void DrawString_7() { nfloat actualFontSize = 12; var f = UIFont.BoldSystemFontOfSize(actualFontSize); try { using (NSString s = new NSString("s")) { var size = s.DrawString(CGPoint.Empty, 20, f, 6, ref actualFontSize, UILineBreakMode.MiddleTruncation, UIBaselineAdjustment.None); Assert.That(actualFontSize, Is.EqualTo((nfloat)12), "actualFontSize"); Assert.That(size.Width, Is.InRange((nfloat)6f, (nfloat)7f), "Width"); Assert.That(size.Height, Is.InRange((nfloat)14f, (nfloat)15f), "Height"); } using (NSString s = new NSString("saterlipopette")) { var size = s.DrawString(CGPoint.Empty, 20, f, 6, ref actualFontSize, UILineBreakMode.MiddleTruncation, UIBaselineAdjustment.None); Assert.That(actualFontSize, Is.EqualTo((nfloat)6), "actualFontSize-2"); Assert.That(size.Width, Is.InRange((nfloat)17f, (nfloat)19f), "Width-2"); Assert.That(size.Height, Is.InRange((nfloat)7f, (nfloat)8f), "Height-2"); } } catch { Console.WriteLine("DrawString_7: actualFontSize: {0} font: {1}", actualFontSize, f); throw; } }