Today's programming challenge - How's your Range-Fu ?
Shachar Shemesh via Digitalmars-d
digitalmars-d at puremagic.com
Fri Apr 17 21:44:25 PDT 2015
On 17/04/15 19:59, H. S. Teoh via Digitalmars-d wrote:
> There's also the question of what to do with bidi markings: how do you
> handle counting the columns in that case?
>
Which BiDi marking are you referring to? LRM/RLM and friends? If so,
don't worry: the interface, as described, is incapable of properly
handling BiDi anyways.
The proper way to handle BiDi line wrapping is this. First you assign a
BiDi level to each character (at which point the markings are,
effectively, removed from the input, so there goes your problem). Then
you calculate the glyph's width until the line limit is reached, and
then you reorder each line according to the BiDi levels you calculated
earlier.
As can be easily seen, this requires transitioning BiDi information that
is per-paragraph across the line break logic, pretty much mandating
multiple passes on the input. Since the requested interface does not
allow that, proper BiDi line breaking is impossible with that interface.
I'll mention that not everyone take that as a serious problem. Window's
text control, for example, calculates line breaks on the text, and then
runs the BiDi algorithm on each line individually. Few people notice
this. Then again, people have already grown used to BiDi text being
scrambled.
Shachar
More information about the Digitalmars-d
mailing list