public static WordToPrint Get(int index, Graphics g, PointF pos, RichTextBox rtb) { WordToPrint nextWord = new WordToPrint(); // match the words for same font / color Match m; CharToPrint nextChar = CharToPrint.Get(index, g, pos, rtb); m = wordSeparator.Match(nextChar.Text.ToString()); if (m.Success) { while (m.Success) { nextWord.Append(nextChar); index++; if (index >= rtb.Text.Length) { break; } nextChar = CharToPrint.Get(index, g, pos, rtb); m = wordSeparator.Match(nextChar.Text.ToString()); } // TODO: do what with .,/: and other punctuation at the end of a word. } else { nextWord.Append(nextChar); } return(nextWord); }
public static CharToPrint Get(int index, Graphics g, PointF pos, RichTextBox rtb) { CharToPrint nextChar = new CharToPrint(); rtb.Select(index, 1); nextChar.Text = rtb.Text[index]; //Debug.WriteIf (showchars, nextChar); nextChar.Font = rtb.SelectionFont; if (nextChar.Font == null) { //Debug.WriteLine ("Null font, using a default"); nextChar.Font = new Font(FontFamily.GenericSansSerif, 12); } if (nextChar.Text == ' ') { nextChar.Size = GetSpaceSize(g, nextChar.Font); } else if (nextChar.Text == '\t') { nextChar.Size = GetSpaceSize(g, nextChar.Font); nextChar.Size.Width *= SpacesInTab; } else { nextChar.Color = rtb.SelectionColor; nextChar.Size = g.MeasureString(nextChar.Text.ToString(), nextChar.Font, pos, StringFormat.GenericTypographic); } return(nextChar); }
/// <summary> /// Appends a CharToPrint to the end of the word /// </summary> /// <param name="aChar">The CharToPrint</param> public void Append(CharToPrint aChar) { charsToPrint.Add(aChar); Size.Width += aChar.Size.Width; Size.Height = Math.Max(Size.Height, aChar.Size.Height); }
/// <summary> /// Appends a CharToPrint to the end of the word /// </summary> /// <param name="aChar">The CharToPrint</param> public void Append(CharToPrint aChar) { charsToPrint.Add (aChar); Size.Width += aChar.Size.Width; Size.Height = Math.Max (Size.Height, aChar.Size.Height); }
public static CharToPrint Get(int index, Graphics g, PointF pos, RichTextBox rtb) { CharToPrint nextChar = new CharToPrint(); rtb.Select (index, 1); nextChar.Text = rtb.Text[index]; //Debug.WriteIf (showchars, nextChar); nextChar.Font = rtb.SelectionFont; if (nextChar.Font == null) { //Debug.WriteLine ("Null font, using a default"); nextChar.Font = new Font (FontFamily.GenericSansSerif, 12); } if (nextChar.Text == ' ') { nextChar.Size = GetSpaceSize (g, nextChar.Font); } else if (nextChar.Text == '\t') { nextChar.Size = GetSpaceSize (g, nextChar.Font); nextChar.Size.Width *= SpacesInTab; } else { nextChar.Color = rtb.SelectionColor; nextChar.Size = g.MeasureString (nextChar.Text.ToString(), nextChar.Font, pos, StringFormat.GenericTypographic); } return nextChar; }