Beispiel #1
0
        /// <summary>
        /// Analyzes the text using each of the analyzers and returns
        /// their results as a series of runs.
        /// </summary>
        public void GenerateResults(TextAnalyzer textAnalyzer, out Run[] runs, out LineBreakpoint[] breakpoints)
        {
            // Initially start out with one result that covers the entire range.
            // This result will be subdivided by the analysis processes.
            LinkedRun initialRun = new LinkedRun()
            {
                nextRunIndex = 0,
                textStart    = 0,
                textLength   = text_.Length,
                bidiLevel    = (readingDirection_ == ReadingDirection.RightToLeft) ? 1 : 0
            };

            runs_ = new List <LinkedRun>();
            runs_.Add(initialRun);

            breakpoints_ = new List <LineBreakpoint>();

            textAnalyzer.AnalyzeLineBreakpoints(this, 0, text_.Length, this);
            textAnalyzer.AnalyzeBidi(this, 0, text_.Length, this);
            textAnalyzer.AnalyzeScript(this, 0, text_.Length, this);
            textAnalyzer.AnalyzeNumberSubstitution(this, 0, text_.Length, this);
            //Call each of the analyzers in sequence, recording their results.
            breakpoints = new LineBreakpoint[breakpoints_.Count];
            breakpoints_.CopyTo(breakpoints);

            // Resequence the resulting runs in order before returning to caller.
            runs = new Run[runs_.Count];
            int nextRunIndex = 0;

            for (int i = 0; i < runs_.Count; i++)
            {
                runs[i]      = runs_[nextRunIndex].AsRun;
                nextRunIndex = runs_[nextRunIndex].nextRunIndex;
            }
        }