//, SizeF size) public static SizeF MeasureString (string inString, Font font) { /*NSTextStorage textStorage = new NSTextStorage(); textStorage. NSTextContainer textContainer = new NSTextContainer(size); NSLayoutManager layoutManager = new NSLayoutManager(); */ var tv = new NSText { Font = font.ToNsFont (), Value = inString }; tv.SizeToFit (); return tv.Frame.Size; }
//, SizeF size) public static SizeF MeasureString(string inString, Font font) { /*NSTextStorage textStorage = new NSTextStorage(); * textStorage. * NSTextContainer textContainer = new NSTextContainer(size); * NSLayoutManager layoutManager = new NSLayoutManager(); */ var tv = new NSText { Font = font.ToNsFont(), Value = inString }; tv.SizeToFit(); return(tv.Frame.Size); }
//, SizeF size) public static SizeF MeasureString(string inString, Font font) { /* * NSTextStorage textStorage = new NSTextStorage(); * textStorage. * NSTextContainer textContainer = new NSTextContainer(size); * NSLayoutManager layoutManager = new NSLayoutManager(); */ var tv = new NSText { Font = font.ToNsFont(), Value = inString }; tv.SizeToFit(); float w = (float)tv.Frame.Size.Width; float h = (float)tv.Frame.Size.Height; return(new SizeF(w, h)); }
internal virtual Size InternalGetPreferredSize(Size proposed) { Size size; if (Text == string.Empty) { size = new Size(0, Font.Height); } else { var txt = new NSText(); txt.Value = Text; txt.Font = Font.ToNsFont(); txt.SizeToFit(); size = Size.Round(txt.Frame.Size); } #if NET_2_0 size.Width += Padding.Horizontal; size.Height += Padding.Vertical; if (!use_compatible_text_rendering) { return(size); } #else size.Height = Font.Height; #endif if (border_style == BorderStyle.None) { size.Height += 3; } else { size.Height += 6; } return(size); }
internal virtual Size InternalGetPreferredSize (Size proposed) { Size size; if (Text == string.Empty) { size = new Size (0, Font.Height); } else { var txt = new NSText(); txt.Value = Text; txt.Font = Font.ToNsFont(); txt.SizeToFit(); size = Util.NSSizeToSize(txt.Frame.Size); } #if NET_2_0 size.Width += Padding.Horizontal; size.Height += Padding.Vertical; if (!use_compatible_text_rendering) return size; #else size.Height = Font.Height; #endif if (border_style == BorderStyle.None) size.Height += 3; else size.Height += 6; return size; }
//, SizeF size) public static SizeF MeasureString (string inString, Font font) { /* NSTextStorage textStorage = new NSTextStorage(); textStorage. NSTextContainer textContainer = new NSTextContainer(size); NSLayoutManager layoutManager = new NSLayoutManager(); */ var tv = new NSText { Font = font.ToNsFont (), Value = inString }; tv.SizeToFit (); float w = (float)tv.Frame.Size.Width; float h = (float)tv.Frame.Size.Height; return new SizeF (w, h); }