private static int DoFullGetRowHeight(TFlxFont Fx) { using (Font MyFont = ExcelFont.CreateFont(Fx.Name, (Fx.Size20 / 20F), ExcelFont.ConvertFontStyle(Fx))) { #if (MONOTOUCH) real h = MyFont.LineHeight; #else real h = MyFont.GetHeight(75); #endif return((int)(h * 20.87 + 5)); } }
private static real DoFullGetFont0Width(TFlxFont Fx) { #if (MONOTOUCH) using (Font MyFont = ExcelFont.CreateFont(Fx.Name, (Fx.Size20 / 20F), ExcelFont.ConvertFontStyle(Fx))) { using (MonoTouch.Foundation.NSString o = new MonoTouch.Foundation.NSString("0")) { return(o.StringSize(MyFont).Width); } } #else using (Font MyFont = ExcelFont.CreateFont(Fx.Name, (Fx.Size20 / 20F), ExcelFont.ConvertFontStyle(Fx))) { using (Bitmap bm = new Bitmap(1, 1)) { using (Graphics gr = Graphics.FromImage(bm)) using (StringFormat sfTemplate = StringFormat.GenericTypographic) //GenericTypographic returns a NEW instance. It has to be disposed. { using (StringFormat sf = (StringFormat)sfTemplate.Clone()) //Even when sfTemplate is a new instance, changing directly on it will change the standard generic typographic :( { //sf.SetMeasurableCharacterRanges was causing a deadlock here. //DONT DO!! /*CharacterRange[] r = {new CharacterRange(0,1)}; * sf.SetMeasurableCharacterRanges(r);*/ sf.Alignment = StringAlignment.Near; //this should be set, but just in case someone changed it. sf.LineAlignment = StringAlignment.Far; //this should be set, but just in case someone changed it. sf.FormatFlags = 0; gr.PageUnit = GraphicsUnit.Pixel; SizeF sz = gr.MeasureString("0", MyFont, 1000, sf); return((real)Math.Round(sz.Width)); } } } } #endif }