public SizeF MeasureString(string text, Font font, int width, StringFormat format) { using (var p = new droid.Paint(this.paint)) using (var bounds = new droid.Rect()) using (var fm = p.GetFontMetrics()) { p.TextSize = font.Size; p.SetTypeface(font.FontFamily.Typeface); p.SetStyle(droid.Paint.Style.Stroke); p.GetTextBounds(text, 0, text.Length, bounds); var height = -fm.Top + fm.Bottom; return(new SizeF(width, height)); } }
public Region[] MeasureCharacterRanges(string text, Font font, RectangleF layoutRect, StringFormat stringFormat) { using (var _p = new droid.Paint(this.paint)) using (var _path = new droid.Path()) using (var _fm = _p.GetFontMetrics()) { _p.TextSize = font.Size; _p.SetTypeface(font.FontFamily.Typeface); _p.SetStyle(droid.Paint.Style.Stroke); _p.GetTextPath(text, 0, text.Length, 0, 0, _path); var _rectf = new droid.RectF(); _path.ComputeBounds(_rectf, true); return(new Region[] { new Region(_rectf) }); } }
public Region[] MeasureCharacterRanges(string text, Font font, RectangleF layoutRect, StringFormat stringFormat) { using (var _p = new droid.Paint(this.paint)) using (var _path = new droid.Path()) using (var _fm = _p.GetFontMetrics()) { _p.TextSize = font.Size; _p.SetTypeface(font.FontFamily.Typeface); _p.SetStyle(droid.Paint.Style.Stroke); _p.GetTextPath(text, 0, text.Length, 0, 0, _path); var _rectf = new droid.RectF(); _path.ComputeBounds(_rectf, true); return new Region[] { new Region(_rectf) }; } }
public SizeF MeasureString(string text, Font font, int width, StringFormat format) { using (var p = new droid.Paint(this.paint)) using (var bounds = new droid.Rect()) using (var fm = p.GetFontMetrics()) { p.TextSize = font.Size; p.SetTypeface(font.FontFamily.Typeface); p.SetStyle(droid.Paint.Style.Stroke); p.GetTextBounds(text, 0, text.Length, bounds); var height = -fm.Top + fm.Bottom; return new SizeF(width, height); } }