diff --git a/org.eclipse.draw2d/src/org/eclipse/draw2d/text/TextFlow.java b/org.eclipse.draw2d/src/org/eclipse/draw2d/text/TextFlow.java index a0415fd..aac9294 100644 --- a/org.eclipse.draw2d/src/org/eclipse/draw2d/text/TextFlow.java +++ b/org.eclipse.draw2d/src/org/eclipse/draw2d/text/TextFlow.java @@ -11,6 +11,7 @@ package org.eclipse.draw2d.text; import java.util.List; +import java.util.Locale; import org.eclipse.swt.SWT; import org.eclipse.swt.graphics.Color; @@ -223,14 +224,32 @@ return getText().substring(box.offset, box.offset + box.length); StringBuffer buffer = new StringBuffer(box.length + 3); - buffer.append(box.isRightToLeft() ? BidiChars.RLO : BidiChars.LRO); + // Added to fix bug Bug 274567 + // flag for Arabic numbers + boolean isAN = false; + String overridingChar = ""; //$NON-NLS-1$ + if (Locale.getDefault().toString().toLowerCase().contains("ar_") + && box.getBidiLevel() == Character.DIRECTIONALITY_ARABIC_NUMBER) { + // set the bidi level to any odd number so numbers are rendered as + // hindic shapes + box.setBidiLevel(Character.DIRECTIONALITY_ARABIC_NUMBER + 1); + isAN = true; + } + // Store the preceding character to be concatenated with the resulting + // string + overridingChar += (box.isRightToLeft() ? BidiChars.RLO : BidiChars.LRO); if (index == 0 && bidiInfo.leadingJoiner) buffer.append(BidiChars.ZWJ); buffer.append(getText().substring(box.offset, box.offset + box.length)); if (index == getFragmentsWithoutBorder().size() - 1 && bidiInfo.trailingJoiner) buffer.append(BidiChars.ZWJ); - return buffer.toString(); + if (isAN) { + // in Arabic number need to reverse the returned string + return buffer.reverse().insert(0, overridingChar).toString(); + } + + return buffer.insert(0, overridingChar).toString(); } /** @@ -574,6 +593,9 @@ if (frag.isTruncated()) draw += ELLIPSIS; + revalidateBidi(this); // to enforce evaluation every time the text + // is painted + if (!isEnabled()) { Color fgColor = g.getForegroundColor(); g.setForegroundColor(ColorConstants.buttonLightest);