Re: Line breaking

From: Asmus Freytag (asmusf@ix.netcom.com)
Date: Mon Mar 22 2010 - 22:28:22 CST

  • Next message: Charlie Ruland ☘: "Fwd: canIPA"

    On 3/22/2010 7:03 PM, Russell Shaw wrote:
    > Hi,
    > I read http://unicode.org/reports/tr9/#Reordering_Resolved_Levels
    > but am still unsure about line-breaking across text that has LTR
    > and RTL runs.

    Russel,

    the simple answer is that you want to be able to read the text without
    having to skip lines. So if you mix longer sections of RTL text in the
    middle of LTR text, as in your example, you proceed as follows: First,
    you lay out the LTR text. That leaves some space at the end of the line.
    Then you collect the logical start of the RTL text (i.e. the part that a
    reader would read first) and then fit as much of that into the remaining
    space on the line as will fit.

    In other words, you get your display-order 2.

    Not only is that the easiest for the reader, it's also really the
    easiest for the computer, because the text, when stored in memory, is in
    logical order. (Your "typing-order"). Notice how the stuff that ends up
    staying together on a line in your display-order 2 is contiguous in the
    "typing-order".

    This is all taken care of by the bidi algorithm.

    First, it has a number or rules, the purpose of which are to nail down
    what is LTR and what is RTL for an entire paragraph, and whether the LTR
    sections are nested in the RTL text or vice versa. (That's a rather
    simplified description of the essential action of these rules).

    Next, you get to talk to your layout engine and find out how much text
    fits on a line. (As discussed, that always corresponds to a contiguous
    section of memory).

    Finally, following the bidi algorithm again, you use the results from
    the first phase to reorder the text - within that line only.

    When you are done, you repeat the last two steps for all remaining lines
    in order.

    Anyway, that's the high-level picture, leaving out all sorts of twisty
    details that are built into the actual rules. So this description is
    only good to help you visualize what happens. For an actual
    implementation you just crank the rules.

    A./
    >
    > line line
    > start end
    > | |
    > V V
    > He said THIS IS A CAR <- typing-order
    >
    > He said RAC A SI | <- display-order 1
    > SIHT
    >
    > He said A SI SIHT | <- display-order 2
    > RAC
    >
    >
    > Lower-case: LTR text
    > Upper-case: RTL text
    >
    >
    > Is case 1 the correct way, or case 2?
    >



    This archive was generated by hypermail 2.1.5 : Mon Mar 22 2010 - 22:30:28 CST