Пример #1
0
        private void DoTests(Bidi bidi, Bidi bidiLine, bool countRunsFirst)
        {
            int    testNumber;
            String str0;
            int    lineStart;
            sbyte  paraLevel;
            int    bidiTestCount = IBM.ICU.Charset.TestData.TestCount();

            for (testNumber = 0; testNumber < bidiTestCount; ++testNumber)
            {
                TestData test = IBM.ICU.Charset.TestData.GetTestData(testNumber);
                str0      = GetStringFromDirProps(test.dirProps);
                paraLevel = test.paraLevel;
                try {
                    bidi.SetPara(str0, paraLevel, null);
                    Logln("Bidi.setPara(tests[" + testNumber + "] OK, direction "
                          + bidi.GetDirection() + " paraLevel " + paraLevel);
                } catch (Exception e) {
                    Errln("Bidi.setPara(tests[" + testNumber
                          + "] failed, direction " + bidi.GetDirection()
                          + " paraLevel " + paraLevel);
                }
                lineStart = test.lineStart;
                if (lineStart == -1)
                {
                    DoTest(bidi, testNumber, test, 0, countRunsFirst);
                }
                else
                {
                    try {
                        bidiLine = bidi.SetLine(lineStart, test.lineLimit);
                        Logln("Bidi.setLine(" + lineStart + ", " + test.lineLimit
                              + "), in tests[" + testNumber + "] OK, direction "
                              + bidiLine.GetDirection() + " paraLevel "
                              + bidiLine.GetBaseLevel());
                        DoTest(bidiLine, testNumber, test, lineStart,
                               countRunsFirst);
                    } catch (Exception e_0) {
                        Errln("Bidi.setLine(" + lineStart + ", " + test.lineLimit
                              + "), in runAll test[" + testNumber + "] failed");
                    }
                    /* do it again using createLineBidi instead of setLine */
                    try {
                        bidiLine = bidi.CreateLineBidi(lineStart, test.lineLimit);
                        Logln("Bidi.createLineBidi(" + lineStart + ", "
                              + test.lineLimit + "), in tests[" + testNumber
                              + "] OK, direction " + bidiLine.GetDirection()
                              + " paraLevel " + bidiLine.GetBaseLevel());
                        DoTest(bidiLine, testNumber, test, lineStart,
                               countRunsFirst);
                    } catch (Exception e_1) {
                        Errln("Bidi.createLineBidi(" + lineStart + ", "
                              + test.lineLimit + "), in runAll test["
                              + testNumber + "] failed");
                    }
                }
            }
        }
Пример #2
0
        private TextLine MakeTextLineOnRange(int startPos, int limitPos)
        {
            int[]   charsLtoV  = null;
            sbyte[] charLevels = null;

            if (FBidi != null)
            {
                Bidi lineBidi = FBidi.CreateLineBidi(startPos, limitPos);
                charLevels = BidiUtils.getLevels(lineBidi);
                int[] charsVtoL = BidiUtils.createVisualToLogicalMap(charLevels);
                charsLtoV = BidiUtils.createInverseMap(charsVtoL);
            }

            TextLineComponent[] components = MakeComponentsOnRange(startPos, limitPos);

            return(new TextLine(FFrc, components, FBaselineOffsets, FChars, startPos, limitPos, charsLtoV, charLevels, FIsDirectionLTR));
        }