private static TextLineRun CreateRunForTab(TextRun textRun, TextParagraphProperties paragraphProperties) { var tabRun = new TextCharacters(TabString, textRun.Properties); var stringRange = tabRun.StringRange; var run = new TextLineRun(1, tabRun) { IsTab = true, StringRange = stringRange, Width = paragraphProperties.DefaultIncrementalTab }; run._glyphWidths = new double[] { run.Width }; return(run); }
private static TextLineRun CreateRunForTab(TextRun textRun) { var spaceRun = new TextCharacters(" ", textRun.Properties); var stringRange = spaceRun.StringRange; var run = new TextLineRun(1, spaceRun) { IsTab = true, StringRange = stringRange, // TODO: get from para props Width = 40 }; run.SetGlyphWidths(); return(run); }
private static TextLineRun CreateRunForSpecialChars(TextSource textSource, StringRange stringRange, TextRun textRun, int index, TextParagraphProperties paragraphProperties) { switch (stringRange[0]) { case '\r': var runLength = 1; if (stringRange.Length > 1 && stringRange[1] == '\n') { runLength = 2; } else if (stringRange.Length == 1) { var nextRun = textSource.GetTextRun(index + 1); var range = nextRun.GetStringRange(); if (range.Length > 0 && range[0] == '\n') { var eolRun = new TextCharacters(NewlineString, textRun.Properties); return(new TextLineRun(eolRun.Length, eolRun) { IsEnd = true }); } } return(new TextLineRun(runLength, textRun) { IsEnd = true }); case '\n': return(new TextLineRun(1, textRun) { IsEnd = true }); case '\t': return(CreateRunForTab(textRun, paragraphProperties)); default: return(null); } }