git-svn-id: https://svn.apache.org/repos/asf/xmlgraphics/fop/trunk@1633759 13f79535-47bb-0310-9956-ffa450edef68pull/28/head
@@ -91,7 +91,7 @@ public class TextArea extends AbstractTextArea { | |||
public void addWord( | |||
String word, int ipd, int[] letterAdjust, int[] levels, | |||
int[][] gposAdjustments, int blockProgressionOffset) { | |||
int minWordLevel = findMinLevel(levels); | |||
int minWordLevel = findMinLevel(levels, getBidiLevel()); | |||
WordArea wordArea = new WordArea( | |||
blockProgressionOffset, minWordLevel, word, letterAdjust, levels, gposAdjustments); | |||
wordArea.setIPD(ipd); | |||
@@ -167,7 +167,7 @@ public class TextArea extends AbstractTextArea { | |||
return sb.toString(); | |||
} | |||
private void updateLevel(int newLevel) { | |||
public void updateLevel(int newLevel) { | |||
if (newLevel >= 0) { | |||
int curLevel = getBidiLevel(); | |||
if (curLevel >= 0) { | |||
@@ -180,7 +180,7 @@ public class TextArea extends AbstractTextArea { | |||
} | |||
} | |||
private static int findMinLevel(int[] levels) { | |||
private static int findMinLevel(int[] levels, int defaultLevel) { | |||
if (levels != null) { | |||
int lMin = Integer.MAX_VALUE; | |||
for (int i = 0, n = levels.length; i < n; i++) { | |||
@@ -195,7 +195,7 @@ public class TextArea extends AbstractTextArea { | |||
return lMin; | |||
} | |||
} else { | |||
return -1; | |||
return defaultLevel; | |||
} | |||
} | |||
@@ -155,10 +155,11 @@ public class WordArea extends InlineArea { | |||
public List collectInlineRuns(List runs) { | |||
assert runs != null; | |||
InlineRun r; | |||
if (getBidiLevels() != null) { | |||
r = new InlineRun(this, getBidiLevels()); | |||
int[] levels = getBidiLevels(); | |||
if ((levels != null) && (levels.length > 0)) { | |||
r = new InlineRun(this, levels); | |||
} else { | |||
r = new InlineRun(this, -1, word.length()); | |||
r = new InlineRun(this, getBidiLevel(), word.length()); | |||
} | |||
runs.add(r); | |||
return runs; |
@@ -293,7 +293,7 @@ public class InlineRun { | |||
return lb.toString(); | |||
} | |||
private static int[] makeLevels(int level, int count) { | |||
int[] levels = new int [ count ]; | |||
int[] levels = new int [ count > 0 ? count : 1 ]; | |||
Arrays.fill(levels, level); | |||
return levels; | |||
} |
@@ -443,6 +443,7 @@ public class TextLayoutManager extends LeafNodeLayoutManager { | |||
int wordCharLength = 0; | |||
for (int wordIndex = firstIndex; wordIndex <= lastIndex; wordIndex++) { | |||
mapping = getGlyphMapping(wordIndex); | |||
textArea.updateLevel(mapping.level); | |||
if (mapping.isSpace) { | |||
addSpaces(); | |||
} else { |