protected internal virtual TextString convertToCharacters(string text, Graphics2D g, FontFactory fontFactory, ColorFactory colorFactory) { TextString characters = new TextString(); FontRenderContext frc = g.getFontRenderContext(); double lastx = 0; for (int i = 0; i < text.Length; i++) { Font font = fontFactory.getFont(i); char c = text[i]; FontMetrics fm = g.getFontMetrics(font); Rectangle2D bounds = font.getStringBounds(Convert.ToString(c), frc); TextCharacter tc = new TextCharacter(); tc.Character = c; tc.Font = font; tc.Width = fm.charWidth(c); tc.Height = fm.getAscent() + fm.getDescent(); tc.Ascent = fm.getAscent(); tc.Descent = fm.getDescent(); tc.X = lastx; tc.Y = 0; tc.Font = font; tc.Color = colorFactory.getColor(i); lastx += bounds.getWidth(); characters.addCharacter(tc); } return(characters); }
public virtual void addCharacter(TextCharacter tc) { characters.Add(tc); }