Exemple #1
0
        /// <summary>
        /// Generate components for the paragraph.  fChars, fBidi should have been
        /// initialized already.
        /// </summary>
        private void GenerateComponents(int startingAt, int endingAt)
        {
            if (CollectStats)
            {
                FormattedChars += (endingAt - startingAt);
            }
            int layoutFlags          = 0;    // no extra info yet, bidi determines run and line direction
            TextLabelFactory factory = new TextLabelFactory(FFrc, FChars, FBidi, layoutFlags);

            int[] charsLtoV = null;

            if (FBidi != null)
            {
                FLevels = BidiUtils.getLevels(FBidi);
                int[] charsVtoL = BidiUtils.createVisualToLogicalMap(FLevels);
                charsLtoV       = BidiUtils.createInverseMap(charsVtoL);
                FIsDirectionLTR = FBidi.BaseIsLeftToRight();
            }
            else
            {
                FLevels         = null;
                FIsDirectionLTR = true;
            }

            try
            {
                FComponents = TextLine.GetComponents(FParagraph, FChars, startingAt, endingAt, charsLtoV, FLevels, factory);
            }
            catch (IllegalArgumentException e)
            {
                System.Console.WriteLine("startingAt=" + startingAt + "; endingAt=" + endingAt);
                System.Console.WriteLine("fComponentLimit=" + FComponentLimit);
                throw e;
            }

            FComponentStart = startingAt;
            FComponentLimit = endingAt;
            //debugFormatCount += (endingAt-startingAt);
        }
Exemple #2
0
        internal void CompareBidi(Bidi bidi, Bidi jbidi)
        {
            sbyte paraLevel = bidi.GetParaLevel();

            if (bidi.BaseIsLeftToRight() != jbidi.BaseIsLeftToRight())
            {
                Errln("Discrepancy in baseIsLeftToRight for case " + "(level="
                      + paraLevel + "): " + IBM.ICU.Charset.BidiTest.U16ToPseudo(bidi.GetTextAsString())
                      + "\n    bidi: " + bidi.BaseIsLeftToRight()
                      + "\n   jbidi: " + jbidi.BaseIsLeftToRight());
            }
            if (bidi.GetBaseLevel() != jbidi.GetBaseLevel())
            {
                Errln("Discrepancy in getBaseLevel for case " + "(level="
                      + paraLevel + "): " + IBM.ICU.Charset.BidiTest.U16ToPseudo(bidi.GetTextAsString())
                      + "\n    bidi: " + bidi.GetBaseLevel() + "\n   jbidi: "
                      + jbidi.GetBaseLevel());
            }
            if (bidi.GetLength() != jbidi.GetLength())
            {
                Errln("Discrepancy in getLength for case " + "(level=" + paraLevel
                      + "): " + IBM.ICU.Charset.BidiTest.U16ToPseudo(bidi.GetTextAsString())
                      + "\n    bidi: " + bidi.GetLength() + "\n   jbidi: "
                      + jbidi.GetLength());
            }
            int len = bidi.GetLength();

            for (int i = 0; i < len; i++)
            {
                if (bidi.GetLevelAt(i) != jbidi.GetLevelAt(i))
                {
                    Errln("Discrepancy in getLevelAt for offset " + i + " of case "
                          + "(level=" + paraLevel + "): "
                          + IBM.ICU.Charset.BidiTest.U16ToPseudo(bidi.GetTextAsString()) + "\n    bidi: "
                          + bidi.GetLevelAt(i) + "\n   jbidi: "
                          + jbidi.GetLevelAt(i));
                }
            }
            if (bidi.GetRunCount() != jbidi.GetRunCount())
            {
                if (!(len == 0 && jbidi.GetRunCount() == 1))
                {
                    Errln("Discrepancy in getRunCount for case " + "(level="
                          + paraLevel + "): "
                          + IBM.ICU.Charset.BidiTest.U16ToPseudo(bidi.GetTextAsString()) + "\n    bidi: "
                          + bidi.GetRunCount() + "\n   jbidi: "
                          + jbidi.GetRunCount());
                }
            }
            int runCount = bidi.GetRunCount();

            for (int i_0 = 0; i_0 < runCount; i_0++)
            {
                if (bidi.GetRunLevel(i_0) != jbidi.GetRunLevel(i_0))
                {
                    Errln("Discrepancy in getRunLevel for run " + i_0 + " of case "
                          + "(level=" + paraLevel + "): "
                          + IBM.ICU.Charset.BidiTest.U16ToPseudo(bidi.GetTextAsString()) + "\n    bidi: "
                          + bidi.GetRunLevel(i_0) + "\n   jbidi: "
                          + jbidi.GetRunLevel(i_0));
                }
                if (bidi.GetRunLimit(i_0) != jbidi.GetRunLimit(i_0))
                {
                    Errln("Discrepancy in getRunLimit for run " + i_0 + " of case "
                          + "(level=" + paraLevel + "): "
                          + IBM.ICU.Charset.BidiTest.U16ToPseudo(bidi.GetTextAsString()) + "\n    bidi: "
                          + bidi.GetRunLimit(i_0) + "\n   jbidi: "
                          + jbidi.GetRunLimit(i_0));
                }
                if (bidi.GetRunStart(i_0) != jbidi.GetRunStart(i_0))
                {
                    Errln("Discrepancy in getRunStart for run " + i_0 + " of case "
                          + "(level=" + paraLevel + "): "
                          + IBM.ICU.Charset.BidiTest.U16ToPseudo(bidi.GetTextAsString()) + "\n    bidi: "
                          + bidi.GetRunStart(i_0) + "\n   jbidi: "
                          + jbidi.GetRunStart(i_0));
                }
            }
            if (bidi.IsLeftToRight() != jbidi.IsLeftToRight())
            {
                Errln("Discrepancy in isLeftToRight for case " + "(level="
                      + paraLevel + "): " + IBM.ICU.Charset.BidiTest.U16ToPseudo(bidi.GetTextAsString())
                      + "\n    bidi: " + bidi.IsLeftToRight() + "\n   jbidi: "
                      + jbidi.IsLeftToRight());
            }
            if (bidi.IsMixed() != jbidi.IsMixed())
            {
                Errln("Discrepancy in isMixed for case " + "(level=" + paraLevel
                      + "): " + IBM.ICU.Charset.BidiTest.U16ToPseudo(bidi.GetTextAsString())
                      + "\n    bidi: " + bidi.IsMixed() + "\n   jbidi: "
                      + jbidi.IsMixed());
            }
            if (bidi.IsRightToLeft() != jbidi.IsRightToLeft())
            {
                Errln("Discrepancy in isRightToLeft for case " + "(level="
                      + paraLevel + "): " + IBM.ICU.Charset.BidiTest.U16ToPseudo(bidi.GetTextAsString())
                      + "\n    bidi: " + bidi.IsRightToLeft() + "\n   jbidi: "
                      + jbidi.IsRightToLeft());
            }
            char[] text = bidi.GetText();
            if (IBM.ICU.Text.Bidi.RequiresBidi(text, 0, text.Length) != Bidi
                .RequiresBidi(text, 0, text.Length))
            {
                Errln("Discrepancy in requiresBidi for case "
                      + IBM.ICU.Charset.BidiTest.U16ToPseudo(bidi.GetTextAsString()) + "\n    bidi: "
                      + IBM.ICU.Text.Bidi.RequiresBidi(text, 0, text.Length) + "\n   jbidi: "
                      + Bidi.RequiresBidi(text, 0, text.Length));
            }

            /*
             * skip the next test, since the toString implementation are not
             * compatible if (!bidi.toString().equals(jbidi.toString())) {
             * errln("Discrepancy in toString for case " + "(level=" + paraLevel +
             * "): " + u16ToPseudo(bidi.getTextAsString() + "\n    bidi: " +
             * bidi.toString() + "\n   jbidi: " + jbidi.toString())); }
             */
        }