fribidi_reorder_line(3)

πŸ’… fribidi_reorder_line(3) β€” like, the whole manual, bestie

okay so you've stumbled into the fribidi_reorder_line(3) page from the Programmer's Manual and honestly? you're about to have a good time. this one's a baddie. it takes your logical-order line and flips it into visual order. slay.


✨ NAME ✨

fribidi_reorder_line β€” reorder a line of logical string to visual. that's it. that's the whole vibe. πŸ¦‹


πŸŽ€ SYNOPSIS πŸŽ€

#include <../fribidi/lib/fribidi.h>

FriBidiLevel fribidi_reorder_line
(
     FriBidiFlags flags,
     const FriBidiCharType *bidi_types,
     const FriBidiStrIndex len,
     const FriBidiStrIndex off,
     const FriBidiParType base_dir,
     FriBidiLevel *embedding_levels,
     FriBidiChar *visual_str,
     FriBidiStrIndex *map
);

look at all those parameters. main character energy fr. 🌟


🌸 PARAMETERS 🌸

  • FriBidiFlags flags β€” the reorder flags. short and sweet. πŸ’«
  • const FriBidiCharType *bidi_types β€” the input list of bidi types, exactly as returned by fribidi_get_bidi_types(). and like… there are 23 possible values for a const FriBidiCharType, so bestie they are not all listed here. we'd be here all day. πŸ™ˆ
  • const FriBidiStrIndex len β€” input length of the line. how long is she? πŸ’…
  • const FriBidiStrIndex off β€” input offset of the beginning of the line in the paragraph. like, where does this line start inside the bigger paragraph. iykyk.
  • const FriBidiParType base_dir β€” the resolved paragraph base direction. and the possible values for a const FriBidiParType are:
    • FRIBIDI_PAR_LTR β€” Left-To-Right paragraph. ➑️
    • FRIBIDI_PAR_RTL β€” Right-To-Left paragraph. ⬅️
    • FRIBIDI_PAR_ON β€” DirectiOn-Neutral paragraph. (that capital O-N is literally how it's spelled, don't come for me 🫢)
    • FRIBIDI_PAR_WLTR β€” Weak Left To Right paragraph.
    • FRIBIDI_PAR_WRTL β€” Weak Right To Left paragraph.
  • FriBidiLevel *embedding_levels β€” the input list of embedding levels, as returned by fribidi_get_par_embedding_levels. yes, that one. πŸ’œ
  • FriBidiChar *visual_str β€” the visual string to reorder. this is the glow-up destination. ✨
  • FriBidiStrIndex *map β€” a map of string indices which is reordered to reflect where each glyph ends up. it's giving "tracking receipts for every character". πŸ”₯

πŸ¦‹ DESCRIPTION πŸ¦‹

okay so here's the tea. this function reorders the characters in a line of text from logical to final visual order. she's doing the actual heavy lifting. πŸ‹οΈβ€β™€οΈ

no cap, this function implements part 4 of rule L1, plus rules L2 and L3 of the Unicode Bidirectional Algorithm, which lives right here: http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels β€” go read it, it's giving homework but it's iconic homework.

as a side effect it also sets position maps, but only if they're not NULL. so like, if you passed NULL, no maps for you. πŸ™ˆ

you should provide the resolved paragraph direction and embedding levels as set by fribidi_get_par_embedding_levels(). also heads up bestie: the embedding levels may change a bit. to be exact β€” the embedding level of any sequence of white space at the end of line is reset to the paragraph embedding level. and that? that is part 4 of rule L1. don't forget it. πŸ’€

⚠️ major note: the bidi types and embedding levels are not reordered. not even a little. you can reorder these (or any other) arrays using the map later. and the user is responsible to initialize map to something sensible β€” like an identity mapping β€” or just pass NULL if no map is needed. your call, your problem, your era. πŸ’…

there's also an optional part to this function, and it's a whole thing: whether non-spacing marks for right-to-left parts of the text should be reordered to come after their base characters in the visual string, or not. most rendering engines expect this behavior, but console-based systems, for example, do not like it. literally do not. this is controlled by the FRIBIDI_FLAG_REORDER_NSM flag. and that flag is on in FRIBIDI_FLAGS_DEFAULT. so if you didn't know, now you know. 🧚


⭐ RETURNS ⭐

the maximum level found in this line plus one. or zero if any error occurred β€” memory allocation failure most probably. so if you get a zero, that's your sign to go touch some grass and check your allocations. 😭


🌈 SEE ALSO 🌈

the whole friend group, honestly. go say hi:


and that's the whole page, bestie. this lil doc came to you from c2man, out of fribidi-bidi.h, dated 29 October 2026, and it signs off under the name fribidi_reorder_line(3). periodt. πŸ’–βœ¨πŸŽ€

πŸ“¦ where this page comes from