[FriBidi] multiple line

Behnam Esfahbod behnam at zwnj.org
Mon Sep 18 16:45:55 UTC 2017


Yuri,

The `fribidi_get_par_embedding_levels()`, as the name suggests, is expected
to be called for each paragraph. IIRC, FriBidi doesn't have a high-level
API to pass-in multi-paragraph text with a default paragraph direction to
apply for all of them. This is something you need to do in your app.

To answer your question about the example: the
`fribidi_get_par_embedding_levels()`
call is applying the default parag-dir only to the first paragraph,
resulting in the first paragraph to jump to level 2. The other two
paragraphs, though, are only processed with a default (0, LTR) parag-dir,
which results in them remaining in 0 level.

So, I believe what you need is to, after `fribidi_get_bidi_types()`, which
can be done over multi-paragraph text, split your text into paragraph
ranges, and call `fribidi_get_par_embedding_levels()` on each paragraph.

Hope this answers your questions.

-Behnam



On Mon, Sep 18, 2017 at 4:24 AM, Yuri D. <kotuk81 at gmail.com> wrote:

> Hi,
>
> I wonder what is the correct input to the FRIBIDI library while parsing
> the levels for multiple lines?
> Should I send each line separately or I can send all the lines in the same
> string?
>
> I'm running the code below:
>
> FriBidiChar* unicodeString = new FriBidiChar[textLength];
> FriBidiCharType* bidiTypes = new FriBidiCharType[textLength];
> FriBidiLevel* bidiLevels = new FriBidiLevel[textLength];
>
> std::string text = "some.\ncar.\nhere.";
>
> // Convert string to unicode
> FriBidiStrIndex len = fribidi_charset_to_unicode(FRIBIDI_CHAR_SET_UTF8,
> text.c_str(), (FriBidiStrIndex)text.length(), unicodeString);
>
> // Get BIDI types
> fribidi_get_bidi_types(unicodeString, (uint32_t)text.size(), bidiTypes);
>
> // Get BIDI levels
> FriBidiLevel resolveParDir = fribidi_get_par_embedding_levels(bidiTypes,
> (uint32_t)text.size(), *FRIBIDI_PAR_RTL*, bidiLevels);
>
> And in the result, I get the BIDI levels below:
> 2 2 2 2 1 1 0 0 0 0 1 0 0 0 0 0
>
> The question is: why I have a level change for the first '.' but not for
> the following '.'?
>
> _______________________________________________
> fribidi mailing list
> fribidi at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/fribidi
>
>


-- 
Behnam Esfahbod | بهنام اسفهبد
http://behnam.es/
GPG-FP: 3E7F B4B6 6F4C A8AB 9BB9 7520 5701 CA40 259E 0F8B
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/fribidi/attachments/20170918/80efd2f5/attachment.html>


More information about the fribidi mailing list