java.text.Bidi Java Examples
The following examples show how to use
java.text.Bidi.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BidiUtils.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
/** * Return the level of each character into the levels array starting at start. * This is a convenience method for clients who prefer to use an explicit levels * array instead of iterating over the runs. * * @param levels the array to receive the character levels * @param start the starting offset into the the array * @throws IndexOutOfBoundsException if <code>start</code> is less than 0 or * <code>start + getLength()</code> is greater than <code>levels.length</code>. */ public static void getLevels(Bidi bidi, byte[] levels, int start) { int limit = start + bidi.getLength(); if (start < 0 || limit > levels.length) { throw new IndexOutOfBoundsException("levels.length = " + levels.length + " start: " + start + " limit: " + limit); } int runCount = bidi.getRunCount(); int p = start; for (int i = 0; i < runCount; ++i) { int rlimit = start + bidi.getRunLimit(i); byte rlevel = (byte)bidi.getRunLevel(i); while (p < rlimit) { levels[p++] = rlevel; } } }
Example #2
Source File: TextMeasurer.java From Java8CN with Apache License 2.0 | 6 votes |
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); }
Example #3
Source File: TextMeasurer.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
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); }
Example #4
Source File: TextMeasurer.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
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); }
Example #5
Source File: TextLine.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * Create a TextLine from the Font and character data over the * range. The range is relative to both the StyledParagraph and the * character array. */ public static TextLine createLineFromText(char[] chars, StyledParagraph styledParagraph, TextLabelFactory factory, boolean isDirectionLTR, float[] baselineOffsets) { factory.setLineContext(0, chars.length); Bidi lineBidi = factory.getLineBidi(); int[] charsLtoV = null; byte[] levels = null; if (lineBidi != null) { levels = BidiUtils.getLevels(lineBidi); int[] charsVtoL = BidiUtils.createVisualToLogicalMap(levels); charsLtoV = BidiUtils.createInverseMap(charsVtoL); } TextLineComponent[] components = getComponents(styledParagraph, chars, 0, chars.length, charsLtoV, levels, factory); return new TextLine(factory.getFontRenderContext(), components, baselineOffsets, chars, 0, chars.length, charsLtoV, levels, isDirectionLTR); }
Example #6
Source File: TextMeasurer.java From jdk-1.7-annotated with Apache License 2.0 | 6 votes |
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); }
Example #7
Source File: TextLine.java From hottub with GNU General Public License v2.0 | 6 votes |
/** * Create a TextLine from the Font and character data over the * range. The range is relative to both the StyledParagraph and the * character array. */ public static TextLine createLineFromText(char[] chars, StyledParagraph styledParagraph, TextLabelFactory factory, boolean isDirectionLTR, float[] baselineOffsets) { factory.setLineContext(0, chars.length); Bidi lineBidi = factory.getLineBidi(); int[] charsLtoV = null; byte[] levels = null; if (lineBidi != null) { levels = BidiUtils.getLevels(lineBidi); int[] charsVtoL = BidiUtils.createVisualToLogicalMap(levels); charsLtoV = BidiUtils.createInverseMap(charsVtoL); } TextLineComponent[] components = getComponents(styledParagraph, chars, 0, chars.length, charsLtoV, levels, factory); return new TextLine(factory.getFontRenderContext(), components, baselineOffsets, chars, 0, chars.length, charsLtoV, levels, isDirectionLTR); }
Example #8
Source File: TextLine.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
/** * Create a TextLine from the Font and character data over the * range. The range is relative to both the StyledParagraph and the * character array. */ public static TextLine createLineFromText(char[] chars, StyledParagraph styledParagraph, TextLabelFactory factory, boolean isDirectionLTR, float[] baselineOffsets) { factory.setLineContext(0, chars.length); Bidi lineBidi = factory.getLineBidi(); int[] charsLtoV = null; byte[] levels = null; if (lineBidi != null) { levels = BidiUtils.getLevels(lineBidi); int[] charsVtoL = BidiUtils.createVisualToLogicalMap(levels); charsLtoV = BidiUtils.createInverseMap(charsVtoL); } TextLineComponent[] components = getComponents(styledParagraph, chars, 0, chars.length, charsLtoV, levels, factory); return new TextLine(factory.getFontRenderContext(), components, baselineOffsets, chars, 0, chars.length, charsLtoV, levels, isDirectionLTR); }
Example #9
Source File: TextLine.java From Java8CN with Apache License 2.0 | 6 votes |
/** * Create a TextLine from the Font and character data over the * range. The range is relative to both the StyledParagraph and the * character array. */ public static TextLine createLineFromText(char[] chars, StyledParagraph styledParagraph, TextLabelFactory factory, boolean isDirectionLTR, float[] baselineOffsets) { factory.setLineContext(0, chars.length); Bidi lineBidi = factory.getLineBidi(); int[] charsLtoV = null; byte[] levels = null; if (lineBidi != null) { levels = BidiUtils.getLevels(lineBidi); int[] charsVtoL = BidiUtils.createVisualToLogicalMap(levels); charsLtoV = BidiUtils.createInverseMap(charsVtoL); } TextLineComponent[] components = getComponents(styledParagraph, chars, 0, chars.length, charsLtoV, levels, factory); return new TextLine(factory.getFontRenderContext(), components, baselineOffsets, chars, 0, chars.length, charsLtoV, levels, isDirectionLTR); }
Example #10
Source File: BidiUtils.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
/** * Return the level of each character into the levels array starting at start. * This is a convenience method for clients who prefer to use an explicit levels * array instead of iterating over the runs. * * @param levels the array to receive the character levels * @param start the starting offset into the the array * @throws IndexOutOfBoundsException if <code>start</code> is less than 0 or * <code>start + getLength()</code> is greater than <code>levels.length</code>. */ public static void getLevels(Bidi bidi, byte[] levels, int start) { int limit = start + bidi.getLength(); if (start < 0 || limit > levels.length) { throw new IndexOutOfBoundsException("levels.length = " + levels.length + " start: " + start + " limit: " + limit); } int runCount = bidi.getRunCount(); int p = start; for (int i = 0; i < runCount; ++i) { int rlimit = start + bidi.getRunLimit(i); byte rlevel = (byte)bidi.getRunLevel(i); while (p < rlimit) { levels[p++] = rlevel; } } }
Example #11
Source File: BidiUtils.java From Bytecoder with Apache License 2.0 | 6 votes |
/** * Return the level of each character into the levels array starting at start. * This is a convenience method for clients who prefer to use an explicit levels * array instead of iterating over the runs. * * @param levels the array to receive the character levels * @param start the starting offset into the array * @throws IndexOutOfBoundsException if {@code start} is less than 0 or * {@code start + getLength()} is greater than {@code levels.length}. */ public static void getLevels(Bidi bidi, byte[] levels, int start) { int limit = start + bidi.getLength(); if (start < 0 || limit > levels.length) { throw new IndexOutOfBoundsException("levels.length = " + levels.length + " start: " + start + " limit: " + limit); } int runCount = bidi.getRunCount(); int p = start; for (int i = 0; i < runCount; ++i) { int rlimit = start + bidi.getRunLimit(i); byte rlevel = (byte)bidi.getRunLevel(i); while (p < rlimit) { levels[p++] = rlevel; } } }
Example #12
Source File: TextLine.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
/** * Create a TextLine from the Font and character data over the * range. The range is relative to both the StyledParagraph and the * character array. */ public static TextLine createLineFromText(char[] chars, StyledParagraph styledParagraph, TextLabelFactory factory, boolean isDirectionLTR, float[] baselineOffsets) { factory.setLineContext(0, chars.length); Bidi lineBidi = factory.getLineBidi(); int[] charsLtoV = null; byte[] levels = null; if (lineBidi != null) { levels = BidiUtils.getLevels(lineBidi); int[] charsVtoL = BidiUtils.createVisualToLogicalMap(levels); charsLtoV = BidiUtils.createInverseMap(charsVtoL); } TextLineComponent[] components = getComponents(styledParagraph, chars, 0, chars.length, charsLtoV, levels, factory); return new TextLine(factory.getFontRenderContext(), components, baselineOffsets, chars, 0, chars.length, charsLtoV, levels, isDirectionLTR); }
Example #13
Source File: TextLine.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
/** * Create a TextLine from the Font and character data over the * range. The range is relative to both the StyledParagraph and the * character array. */ public static TextLine createLineFromText(char[] chars, StyledParagraph styledParagraph, TextLabelFactory factory, boolean isDirectionLTR, float[] baselineOffsets) { factory.setLineContext(0, chars.length); Bidi lineBidi = factory.getLineBidi(); int[] charsLtoV = null; byte[] levels = null; if (lineBidi != null) { levels = BidiUtils.getLevels(lineBidi); int[] charsVtoL = BidiUtils.createVisualToLogicalMap(levels); charsLtoV = BidiUtils.createInverseMap(charsVtoL); } TextLineComponent[] components = getComponents(styledParagraph, chars, 0, chars.length, charsLtoV, levels, factory); return new TextLine(factory.getFontRenderContext(), components, baselineOffsets, chars, 0, chars.length, charsLtoV, levels, isDirectionLTR); }
Example #14
Source File: TextLine.java From JDKSourceCode1.8 with MIT License | 6 votes |
/** * Create a TextLine from the Font and character data over the * range. The range is relative to both the StyledParagraph and the * character array. */ public static TextLine createLineFromText(char[] chars, StyledParagraph styledParagraph, TextLabelFactory factory, boolean isDirectionLTR, float[] baselineOffsets) { factory.setLineContext(0, chars.length); Bidi lineBidi = factory.getLineBidi(); int[] charsLtoV = null; byte[] levels = null; if (lineBidi != null) { levels = BidiUtils.getLevels(lineBidi); int[] charsVtoL = BidiUtils.createVisualToLogicalMap(levels); charsLtoV = BidiUtils.createInverseMap(charsVtoL); } TextLineComponent[] components = getComponents(styledParagraph, chars, 0, chars.length, charsLtoV, levels, factory); return new TextLine(factory.getFontRenderContext(), components, baselineOffsets, chars, 0, chars.length, charsLtoV, levels, isDirectionLTR); }
Example #15
Source File: Helper.java From memoir with Apache License 2.0 | 6 votes |
/** * This method determines if the direction of a substring is right-to-left. * If the string is empty that determination is based on the default system language * Locale.getDefault(). * The method can handle invalid substring definitions (start > end etc.), in which case the * method returns False. * * @return True if the text direction is right-to-left, false otherwise. */ public static boolean isRTL(CharSequence s, int start, int end) { if (s == null || s.length() == 0) { // empty string --> determine the direction from the default language return isRTL(Locale.getDefault()); } if (start == end) { // if no character is selected we need to expand the selection start = Math.max(0, --start); if (start == end) { end = Math.min(s.length(), ++end); } } try { Bidi bidi = new Bidi(s.subSequence(start, end).toString(), Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT); return ! bidi.baseIsLeftToRight(); } catch (IndexOutOfBoundsException e) { return false; } }
Example #16
Source File: TextMeasurer.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
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); }
Example #17
Source File: TextLine.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
/** * Create a TextLine from the Font and character data over the * range. The range is relative to both the StyledParagraph and the * character array. */ public static TextLine createLineFromText(char[] chars, StyledParagraph styledParagraph, TextLabelFactory factory, boolean isDirectionLTR, float[] baselineOffsets) { factory.setLineContext(0, chars.length); Bidi lineBidi = factory.getLineBidi(); int[] charsLtoV = null; byte[] levels = null; if (lineBidi != null) { levels = BidiUtils.getLevels(lineBidi); int[] charsVtoL = BidiUtils.createVisualToLogicalMap(levels); charsLtoV = BidiUtils.createInverseMap(charsVtoL); } TextLineComponent[] components = getComponents(styledParagraph, chars, 0, chars.length, charsLtoV, levels, factory); return new TextLine(factory.getFontRenderContext(), components, baselineOffsets, chars, 0, chars.length, charsLtoV, levels, isDirectionLTR); }
Example #18
Source File: TextMeasurer.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
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); }
Example #19
Source File: TextLine.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
/** * Create a TextLine from the Font and character data over the * range. The range is relative to both the StyledParagraph and the * character array. */ public static TextLine createLineFromText(char[] chars, StyledParagraph styledParagraph, TextLabelFactory factory, boolean isDirectionLTR, float[] baselineOffsets) { factory.setLineContext(0, chars.length); Bidi lineBidi = factory.getLineBidi(); int[] charsLtoV = null; byte[] levels = null; if (lineBidi != null) { levels = BidiUtils.getLevels(lineBidi); int[] charsVtoL = BidiUtils.createVisualToLogicalMap(levels); charsLtoV = BidiUtils.createInverseMap(charsVtoL); } TextLineComponent[] components = getComponents(styledParagraph, chars, 0, chars.length, charsLtoV, levels, factory); return new TextLine(factory.getFontRenderContext(), components, baselineOffsets, chars, 0, chars.length, charsLtoV, levels, isDirectionLTR); }
Example #20
Source File: TextLine.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
/** * Create a TextLine from the text. chars is just the text in the iterator. */ public static TextLine standardCreateTextLine(FontRenderContext frc, AttributedCharacterIterator text, char[] chars, float[] baselineOffsets) { StyledParagraph styledParagraph = new StyledParagraph(text, chars); Bidi bidi = new Bidi(text); if (bidi.isLeftToRight()) { bidi = null; } int layoutFlags = 0; // no extra info yet, bidi determines run and line direction TextLabelFactory factory = new TextLabelFactory(frc, chars, bidi, layoutFlags); boolean isDirectionLTR = true; if (bidi != null) { isDirectionLTR = bidi.baseIsLeftToRight(); } return createLineFromText(chars, styledParagraph, factory, isDirectionLTR, baselineOffsets); }
Example #21
Source File: TextLine.java From jdk1.8-source-analysis with Apache License 2.0 | 6 votes |
/** * Create a TextLine from the text. chars is just the text in the iterator. */ public static TextLine standardCreateTextLine(FontRenderContext frc, AttributedCharacterIterator text, char[] chars, float[] baselineOffsets) { StyledParagraph styledParagraph = new StyledParagraph(text, chars); Bidi bidi = new Bidi(text); if (bidi.isLeftToRight()) { bidi = null; } int layoutFlags = 0; // no extra info yet, bidi determines run and line direction TextLabelFactory factory = new TextLabelFactory(frc, chars, bidi, layoutFlags); boolean isDirectionLTR = true; if (bidi != null) { isDirectionLTR = bidi.baseIsLeftToRight(); } return createLineFromText(chars, styledParagraph, factory, isDirectionLTR, baselineOffsets); }
Example #22
Source File: BidiConformance.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private void testMethod_createLineBidi1() { System.out.println("*** Test createLineBidi() 1"); String str = " ABC 123. " + HebrewABC + " " + NKo123 + ". ABC 123"; int lineStart = str.indexOf('.') + 2; int lineLimit = str.lastIndexOf('.') + 2; Bidi bidi = new Bidi(str, FLAGS[0]); Bidi lineBidi = bidi.createLineBidi(lineStart, lineLimit); checkResult("getBaseLevel()", bidi.getBaseLevel(), lineBidi.getBaseLevel()); checkResult("getLevelAt(5)", bidi.getLevelAt(lineStart+5), lineBidi.getLevelAt(5)); }
Example #23
Source File: BidiConformance.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
private void callTestEachMethod4Constructor3(int textNo, int dataNo, Bidi bidi) { testEachMethod(bidi, data4Constructor3[textNo][0], data4Constructor3[textNo][dataNo+1], baseIsLTR4Constructor3[textNo][dataNo], isLTR_isRTL4Constructor3[textNo][0][dataNo], isLTR_isRTL4Constructor3[textNo][1][dataNo]); }
Example #24
Source File: LineLayout.java From consulo with Apache License 2.0 | 5 votes |
private static void addRunsNoTabs(List<BidiRun> runs, char[] text, int start, int end, int flags) { if (start >= end) return; Bidi bidi = new Bidi(text, start, null, 0, end - start, flags); int runCount = bidi.getRunCount(); for (int i = 0; i < runCount; i++) { addOrMergeRun(runs, new BidiRun((byte)bidi.getRunLevel(i), start + bidi.getRunStart(i), start + bidi.getRunLimit(i))); } }
Example #25
Source File: BidiSurrogateTest.java From jdk8u_jdk with GNU General Public License v2.0 | 5 votes |
void testBidi(String string, int rtlstart, int rtllength) { Bidi bidi = new Bidi(string, Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT); for (int i = 0; i < bidi.getRunCount(); ++i) { if ((bidi.getRunLevel(i) & 1) != 0) { if (bidi.getRunStart(i) != rtlstart || bidi.getRunLimit(i) != rtlstart + rtllength) { throw new RuntimeException("first rtl run didn't match " + rtlstart + ", " + rtllength); } break; } } }
Example #26
Source File: TextLabelFactory.java From Bytecoder with Apache License 2.0 | 5 votes |
/** * Initialize a factory to produce glyph arrays. * @param frc the FontRenderContext to use for the arrays to be produced. * @param text the text of the paragraph. * @param bidi the bidi information for the paragraph text, or null if the * entire text is left-to-right text. */ public TextLabelFactory(FontRenderContext frc, char[] text, Bidi bidi, int flags) { this.frc = frc; this.text = text.clone(); this.bidi = bidi; this.flags = flags; this.lineBidi = bidi; this.lineStart = 0; this.lineLimit = text.length; }
Example #27
Source File: BidiConformance.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 5 votes |
private void callTestEachMethod4Constructor3(int textNo, int dataNo, Bidi bidi) { testEachMethod(bidi, data4Constructor3[textNo][0], data4Constructor3[textNo][dataNo+1], baseIsLTR4Constructor3[textNo][dataNo], isLTR_isRTL4Constructor3[textNo][0][dataNo], isLTR_isRTL4Constructor3[textNo][1][dataNo]); }
Example #28
Source File: BidiEmbeddingTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
static void test2() { String target = "BACK WARDS"; String str = "If this text is >" + target + "< the test passed."; int length = str.length(); int start = str.indexOf(target); int limit = start + target.length(); System.out.println("start: " + start + " limit: " + limit); AttributedString astr = new AttributedString(str); astr.addAttribute(TextAttribute.RUN_DIRECTION, TextAttribute.RUN_DIRECTION_RTL); astr.addAttribute(TextAttribute.BIDI_EMBEDDING, new Integer(-3), start, limit); Bidi bidi = new Bidi(astr.getIterator()); for (int i = 0; i < bidi.getRunCount(); ++i) { System.out.println("run " + i + " from " + bidi.getRunStart(i) + " to " + bidi.getRunLimit(i) + " at level " + bidi.getRunLevel(i)); } System.out.println(bidi + "\n"); if (bidi.getRunCount() != 6) { // runs of spaces and angles at embedding bound,s and final period, each get level 1 throw new Error("Bidi embedding processing failed"); } else { System.out.println("test2() passed.\n"); } }
Example #29
Source File: BidiEmbeddingTest.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
static void test2() { String target = "BACK WARDS"; String str = "If this text is >" + target + "< the test passed."; int length = str.length(); int start = str.indexOf(target); int limit = start + target.length(); System.out.println("start: " + start + " limit: " + limit); AttributedString astr = new AttributedString(str); astr.addAttribute(TextAttribute.RUN_DIRECTION, TextAttribute.RUN_DIRECTION_RTL); astr.addAttribute(TextAttribute.BIDI_EMBEDDING, new Integer(-3), start, limit); Bidi bidi = new Bidi(astr.getIterator()); for (int i = 0; i < bidi.getRunCount(); ++i) { System.out.println("run " + i + " from " + bidi.getRunStart(i) + " to " + bidi.getRunLimit(i) + " at level " + bidi.getRunLevel(i)); } System.out.println(bidi + "\n"); if (bidi.getRunCount() != 6) { // runs of spaces and angles at embedding bound,s and final period, each get level 1 throw new Error("Bidi embedding processing failed"); } else { System.out.println("test2() passed.\n"); } }
Example #30
Source File: BidiSurrogateTest.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
void testBidi(String string, boolean directionIsRTL) { Bidi bidi = new Bidi(string, Bidi.DIRECTION_DEFAULT_LEFT_TO_RIGHT); if (bidi.isMixed()) { throw new RuntimeException("bidi is mixed"); } if (bidi.isRightToLeft() != directionIsRTL) { throw new RuntimeException("bidi is not " + (directionIsRTL ? "rtl" : "ltr")); } }