public static void Run() { GlyphFactory fac = new GlyphFactory(); //Position & character Dictionary <int, Character> document = new Dictionary <int, Character>(); document.Add(1, fac.GetGlyph('A')); document.Add(2, fac.GetGlyph('B')); document.Add(3, fac.GetGlyph('A')); GlyphContext context = new GlyphContext(); context.SetFont(1, "Calibri"); context.SetFont(2, "Times New Roman"); context.SetFont(3, "Comic Sans"); context.SetIndex(1); foreach (var item in document) { item.Value.Draw(context); context.Next(); } }
public void GenerateText() { // ===== Generated Fonts to Use ===== Font times24 = new Font("Times New Roman", 24); Font times12 = new Font("Times New Roman", 12); Font timesItalic12 = new Font("Times New Roman", 12, FontStyle.Italic); Font timesBold12 = new Font("Times New Roman", 12, FontStyle.Bold); Font courier12 = new Font("Courier", 12); // ===== Add Text ===== // Add single character, as if from keypress. AddText('O', times24); // Add bulk of text, as if from copy/paste _currentFont = times12; AddText("bject-oriented programming ...", _currentFont); AddText("people ", _currentFont); string text = "expect"; int rewindCursor = text.Length; AddText(text, timesItalic12); text = " to change ..."; rewindCursor += text.Length; AddText(text, _currentFont); text = "an "; rewindCursor += text.Length; AddText(text, _currentFont); text = "iterator"; rewindCursor += text.Length; AddText(text, timesBold12); rewindCursor++; AddText(' ', _currentFont); text = "Foo"; rewindCursor += text.Length; AddText(text, courier12); text = " can do ..."; rewindCursor += text.Length; AddText(text, _currentFont); // ===== Modify Text ===== // Move cursor to just before 'expect' extrinsicState.Next(-1 * rewindCursor); // Change font of the word based on the current location and length extrinsicState.SetFont(times12, 6); // ===== Insert Text ===== // Text is added at current position, which is always inserted. // Pure adding only occurs at the last index position. AddText("don't ", timesItalic12); }