private RectangleF[] MeasureStringParts(CharacterRange[] range, Graphics g, string str, Style style) { UpdateTabStop(str, style); stringFormat.SetMeasurableCharacterRanges(range); Region[] regn = g.MeasureCharacterRanges(str, FontCache.get(style), RectangleF.Empty, stringFormat); return(Array.ConvertAll(regn, rgn => rgn.GetBounds(g))); }
private void UpdateTabStop(string str, Style style) { var tabCount = countTabs(str); if (tabCount <= 0) { return; } var tabString = new string(' ', ViewStyle.TabSize); var tabSize = surface.Graphics.MeasureString(tabString, FontCache.get(style), 0, stringFormat); stringFormat.SetTabStops(0, new[] { tabSize.Width }); }
private RectangleF DrawStringPart(CharacterRange range, Graphics g, string str, Style style, float offset) { string part = str.Substring(range.First, range.Length); UpdateTabStop(part, style); RectangleF size = MeasureStringPart(range, g, str, style); if (!style.Background.IsEmpty) { RectangleF textRect = size; textRect.X = 0; textRect.Offset(offset, 0); g.FillRectangle(BrushCache.getSolid(style.Background), textRect); } g.DrawString(part, FontCache.get(style), BrushCache.getForeground(style), offset, 0, stringFormat); return(size); }