Must address this in the TextLayout and Swing bidi algorithms.
The problem is that the clients want to continue using the ascii numerals and not convert to the Hindi numerals themselves. The arguments are 1) client data from external sources, while nominally 'unicode', stores numeric data as ascii because their software can't handle the other numerals in unicode; 2) keyboards for Arabic don't generate the numerals in the Hindi block, but instead generate the numerals in the roman block, making it difficult to enter the correct text using 'off the shelf' components such as the swing text components. The second problem really shouldn't be the client's responsibility. While unicode includes codes to turn on 'national' digit shapes' these are deprecated (because they are stateful) and we don't support them. Since we rely on the OS for keyboard support, changing the keyboard handling for all platforms is rather error-prone, though iy is an option. And we still face client reluctance to convert their numeric data.
Some form of Attribute support could handle this. There are lots of numerals, and even in the Arabic block there are different sets of numerals for different languages (the Persian digits at 06f0), so it could be argued (I would) that the numeric shaping should be language-dependent, and that instead of having explicit attributes for each number type as well as a bidi-contextual form, there should be only 'explicit' and 'language dependent', where 'language dependent' depends on either explicit language tagging (more attributes) or language analysis. 'Explicit' is the default and how unicode prefers to handle things. 'Language dependent' would trigger examining an attribute for language. If it is not present we synthesize a language based on paragraph context (we do script analysis for OpenType anyway). If the result is 'arabic' we use the numerals in the standard arabic block, if it is 'persian' we use the numerals from the extended arabic block, etc.
Unfortunately some writing systems write numbers differently-- not just with different numerals-- though many just use variant character forms. This wouldn't handle that, though it might lead to the expectation that it would-- for instance, that roman numbers embedded in Chinese would use a traditional Chinese representation (X 100 Y 10 Z) instead of X Y Z.
So I think this needs a bit more investigation.
The reporter is incorrect in stating that "Shaping the numbers is the responsibility of the BIDI algorithm as specified by the Unicode standard." This is not the case, the Bidi algorithm only deals with character positioning and not shaping. Shaping is the responsibility of the rendering system and is outside Unicode's domain per se. That said, we do perform shaping of Arabic text, and also lam-alef ligature substitution.
See the suggested fix.
The simplest thing to do is to add a new attribute and perform contextual shaping based on a small set of fixed values. If other people want contextual shaping, we can expand the set of values. Clients want contextual shaping and a generic implementation is probably overkill, and if not carefully designed could be easily abused.
The most direct solution is to provide an attribute, NumericConversion, that causes the ASCII values from 0-9 to be converted to some other range, the base of which is the unicode character corresponding to the integer value of the attribute. It would be the caller's responsibility to apply this attribute with the desired value for those ranges of text they cared about. It would only affect ASCII digits, so it could be applied 'indiscriminately' to entire ranges of text.
My understanding is that some locales that use Arabic (Morocco) do not use the digits from the Arabic block, but prefer that they remain ASCII. Other locales might prefer the Persian digits (a different range of the Arabic block). Rather than introduce locale-sensitive operations, and the requirement that the locale of the text be identified and the appropriate operations associated with that locale, it is more straightforward to provide a direct mechanism. We can use negative values for the attribute in the future if we want to provide other semantics similar to the ones requested.
The attribute will do a simple text substitution before bidi analysis is performed on the text. Thus applying this style will be equivalent to rendering text on which the character substitutions had been performed. Nothing prevents users from performing this conversion directly if they desire.
Swing text components could implement the desired semantic when in the proper locale by applying this style on the appropriate ranges of text. That would be a separate bug to file against swing. I believe there is already a request for swing text to do this.
At this point I recommend against implementing the Unicode control codes that affect numeric shaping, since Unicode doesn't actually define what range of codes to map the ASCII digits to, or any mechanism to select that range.
After talking with Brian Beck we determined that being able to shape to other decimal ranges would be useful too, even though the initial request was for Arabic. We also determined that options for contextual shaping and initial context (in effect before the start of the text) were required. This leads to many possible options, too many to comfortably express via a fixed set of constants. So we recommend making the NumericShaper class and its operations public.