[HarfBuzz] How to solve shaping after BiDi

Eduardo Castineyra eduardo at brainstorm.es
Mon Nov 18 09:36:09 PST 2013


Hi Behdad,

I already implemented a solution and it seems to be working. This is 
basically what I do:

1) Use fribidi to extract the v2l and dir tables (get_bidi_types).

2) Re-order the string using the v2l table:
For every character:
   strOut[i] = strIn[v2l[i]]

((( Now strOut is ordered but not shaped )))

3) Split the string in direction runs using the criteria:
dir[ v2l[i] ] != dir[ v2l[i-1] ]

4) Shape each run separately telling harfbuzz everything is LTR.

5) For every glyph
g->cluster = v2l[g->cluster]

6) profit!

But I have two questions:

1) Splitting by BiDi type looks like a bad idea because the spaces are 
WS while arabic and english text are AL and LTR respectively. So it is 
forcing algorithm to shape every word separately, creating and 
destroying the hb_buffer each time. Would it be a better idea to use the 
BiDi levels as the split criteria?

2) Is there anything wrong with reordering arabic characters from LTR to 
RTL and then shape them as if they were LTR?

Thanks!

El 30/10/2013 17:08, Behdad Esfahbod escribió:
>
> You got it mostly right. I'll reply to you in detail next week. 
> Traveling right now.
>
> On Oct 30, 2013 3:56 PM, "eduardo" <eduardo at brainstorm.es 
> <mailto:eduardo at brainstorm.es>> wrote:
>
>     BiDi/harfbuzz integration code samples are also welcome
>
>     On Mon, 28 Oct 2013 12:48:09 +0100, Eduardo Castineyra wrote:
>
>         Hi,
>
>         I have an unicode string with the bidi already solved, but I don't
>         know exactly how to feed harfbuzz with the result. There is a
>         list of
>         things I don't know and finally my guess on how this should be
>         solved:
>
>         1) Given the friBiDi already switched the order of the glyhs, do I
>         still need to set the buffer direction to RTL ?
>         2) Do I have to shape each unidirectional segment separately?
>         How do
>         I manage the clusters?
>         3) How do I combine the L_to_V output from friBiDi with the hb
>         clusters?
>
>         Could you please correct me if I got something wrong with this
>         algorithm?
>
>         from friBiDi, I'm using only the l2v, v2l and RTL props, and
>         completely discarding the glyhps:
>
>         1) friBiDi pass
>         2) Using the l2v list identify the direction of every character
>         3) Split the original text into monodirectional runs.
>         4) For each run, we save the lowest visual position (LVP) and the
>         lowest logical position (LLP)
>         5) Shape every segment separately (setting the appropriate
>         buffer direction).
>         6) Sort the segments based on their LVP
>         7) Add the LLP to the cluster of every glyph.
>
>         Isn't there an easier way to do this?
>
>         Thanks!
>         _______________________________________________
>         HarfBuzz mailing list
>         HarfBuzz at lists.freedesktop.org
>         <mailto:HarfBuzz at lists.freedesktop.org>
>         http://lists.freedesktop.org/mailman/listinfo/harfbuzz
>
>
>     _______________________________________________
>     HarfBuzz mailing list
>     HarfBuzz at lists.freedesktop.org <mailto:HarfBuzz at lists.freedesktop.org>
>     http://lists.freedesktop.org/mailman/listinfo/harfbuzz
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freedesktop.org/archives/harfbuzz/attachments/20131118/776139f8/attachment.html>


More information about the HarfBuzz mailing list