()
| 22 | } |
| 23 | |
| 24 | public void testAbc() { |
| 25 | try (TextLine line = TextLine.make("abc", inter36);) { |
| 26 | assertArrayEquals(new short[] {503, 574, 581}, line.getGlyphs()); |
| 27 | assertArrayEquals(new int[] {0, 1, 2, 3}, TextLine._nGetBreakOffsets(line._ptr)); |
| 28 | assertArrayEquals(new float[] {0f, 20f, 42f, 62f}, TextLine._nGetBreakPositions(line._ptr)); |
| 29 | |
| 30 | pushStack("getOffsetAtCoord"); |
| 31 | assertEquals(0, line.getOffsetAtCoord(-10f)); // before “a” |
| 32 | |
| 33 | assertEquals(0, line.getOffsetAtCoord(0f)); // beginning of “a” |
| 34 | assertEquals(0, line.getOffsetAtCoord(5f)); // left half of “a” |
| 35 | assertEquals(1, line.getOffsetAtCoord(10f)); // center of “a” |
| 36 | assertEquals(1, line.getOffsetAtCoord(15f)); // right half of “a” |
| 37 | |
| 38 | assertEquals(1, line.getOffsetAtCoord(20f)); // between “a” and “b” |
| 39 | assertEquals(1, line.getOffsetAtCoord(25f)); // left half of “b” |
| 40 | assertEquals(2, line.getOffsetAtCoord(31f)); // center of “b” |
| 41 | assertEquals(2, line.getOffsetAtCoord(36f)); // right half of “b” |
| 42 | |
| 43 | assertEquals(2, line.getOffsetAtCoord(42f)); // between “b” and “c” |
| 44 | assertEquals(2, line.getOffsetAtCoord(47f)); // left half of “c” |
| 45 | assertEquals(3, line.getOffsetAtCoord(52f)); // center of “c” |
| 46 | assertEquals(3, line.getOffsetAtCoord(57f)); // right half of “c” |
| 47 | |
| 48 | assertEquals(3, line.getOffsetAtCoord(62f)); // end of “c” |
| 49 | assertEquals(3, line.getOffsetAtCoord(100f)); // after “c” |
| 50 | popStack(); |
| 51 | |
| 52 | pushStack("getLeftOffsetAtCoord"); |
| 53 | assertEquals(0, line.getLeftOffsetAtCoord(-10f)); // before “a” |
| 54 | |
| 55 | assertEquals(0, line.getLeftOffsetAtCoord(0f)); // beginning of “a” |
| 56 | assertEquals(0, line.getLeftOffsetAtCoord(5f)); // left half of “a” |
| 57 | assertEquals(0, line.getLeftOffsetAtCoord(10f)); // center of “a” |
| 58 | assertEquals(0, line.getLeftOffsetAtCoord(15f)); // right half of “a” |
| 59 | |
| 60 | assertEquals(1, line.getLeftOffsetAtCoord(20f)); // between “a” and “b” |
| 61 | assertEquals(1, line.getLeftOffsetAtCoord(25f)); // left half of “b” |
| 62 | assertEquals(1, line.getLeftOffsetAtCoord(31f)); // center of “b” |
| 63 | assertEquals(1, line.getLeftOffsetAtCoord(36f)); // right half of “b” |
| 64 | |
| 65 | assertEquals(2, line.getLeftOffsetAtCoord(42f)); // between “b” and “c” |
| 66 | assertEquals(2, line.getLeftOffsetAtCoord(47f)); // left half of “c” |
| 67 | assertEquals(2, line.getLeftOffsetAtCoord(52f)); // center of “c” |
| 68 | assertEquals(2, line.getLeftOffsetAtCoord(57f)); // right half of “c” |
| 69 | |
| 70 | assertEquals(3, line.getLeftOffsetAtCoord(62f)); // end of “c” |
| 71 | assertEquals(3, line.getLeftOffsetAtCoord(100f)); // after “c” |
| 72 | popStack(); |
| 73 | |
| 74 | pushStack("getCoordAtOffset"); |
| 75 | assertClose(0f, line.getCoordAtOffset(0)); |
| 76 | assertClose(20f, line.getCoordAtOffset(1)); |
| 77 | assertClose(42f, line.getCoordAtOffset(2)); |
| 78 | assertClose(62f, line.getCoordAtOffset(3)); |
| 79 | popStack(); |
| 80 | } |
| 81 | } |
no test coverage detected