Ejemplo n.º 1
0
  private TextLine makeTextLineOnRange(int startPos, int limitPos) {

    int[] charsLtoV = null;
    byte[] 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);
  }
Ejemplo n.º 2
0
 public void testIncompatibleLineAlgorithm() {
   // ICU treat a new line as in the same run, however RI does not
   bd =
       new Bidi(
           "aaaaa".toCharArray(),
           0,
           new byte[] {-2, -1, -3, -3, -2},
           0,
           5,
           Bidi.DIRECTION_RIGHT_TO_LEFT);
   Bidi line = bd.createLineBidi(1, 4);
   assertFalse(line.baseIsLeftToRight());
   assertEquals(1, line.getBaseLevel());
   assertEquals(3, line.getLength());
   assertEquals(1, line.getLevelAt(0));
   assertEquals(1, line.getLevelAt(1));
   assertEquals(1, line.getLevelAt(2));
   assertEquals(1, line.getLevelAt(1000));
   assertEquals(1, line.getRunCount());
   assertRunArrayEquals(
       new int[][] {
         {0, 3, 1},
       },
       line);
   assertFalse(line.isLeftToRight());
   assertFalse(line.isMixed());
   assertTrue(line.isRightToLeft());
 }
Ejemplo n.º 3
0
 public void testCreateLineBidi() {
   bd =
       new Bidi(
           "a\u05D0a\u05D0a\u05D0\"\u05D0a".toCharArray(),
           0,
           new byte[] {0, 0, 0, -3, -3, 2, 2, 0, 3},
           0,
           9,
           Bidi.DIRECTION_RIGHT_TO_LEFT);
   Bidi line = bd.createLineBidi(2, 7);
   assertFalse(line.baseIsLeftToRight());
   assertEquals(1, line.getBaseLevel());
   assertEquals(5, line.getLength());
   assertEquals(2, line.getLevelAt(0));
   assertEquals(3, line.getLevelAt(1));
   assertEquals(3, line.getLevelAt(2));
   assertEquals(3, line.getLevelAt(3));
   assertEquals(2, line.getLevelAt(4));
   assertEquals(1, line.getLevelAt(1000));
   assertEquals(3, line.getRunCount());
   assertRunArrayEquals(
       new int[][] {
         {0, 1, 2}, {1, 4, 3}, {4, 5, 2},
       },
       line);
   assertFalse(line.isLeftToRight());
   assertTrue(line.isMixed());
   assertFalse(line.isRightToLeft());
 }
Ejemplo n.º 4
0
  public void testCreateLineBidiInvalid() {
    // regression for HARMONY-1050
    Bidi bidi = new Bidi("str", 1);
    try {
      bidi.createLineBidi(-1, 1);
      fail("Expected IAE");
    } catch (IllegalArgumentException e) {
      // Expected
    }

    try {
      bidi.createLineBidi(1, -1);
      fail("Expected IAE");
    } catch (IllegalArgumentException e) {
      // Expected
    }

    try {
      bidi.createLineBidi(-1, -1);
      fail("Expected IAE");
    } catch (IllegalArgumentException e) {
      // Expected
    }

    try {
      bidi.createLineBidi(2, 1);
      fail("Expected IAE");
    } catch (IllegalArgumentException e) {
      // Expected
    }

    try {
      bidi.createLineBidi(2, 2);
    } catch (IllegalArgumentException e) {
      // Expected
    }

    try {
      bidi.createLineBidi(2, 4);
      fail("Expected IAE");
    } catch (IllegalArgumentException e) {
      // Expected
    }
  }