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 byfribidi_get_bidi_types(). and likeβ¦ there are 23 possible values for aconst 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 aconst FriBidiParTypeare: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 byfribidi_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 initializemapto something sensible β like an identity mapping β or just passNULLif 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:
fribidi_shape_arabic(3)fribidi_get_par_direction(3)fribidi_get_par_embedding_levels_ex(3)fribidi_get_bidi_type(3)fribidi_get_bidi_types(3)fribidi_get_bidi_type_name(3)fribidi_charset_to_unicode(3)fribidi_unicode_to_charset(3)fribidi_parse_charset(3)fribidi_debug_status(3)fribidi_set_debug(3)fribidi_mirroring_status(3)fribidi_set_mirroring(3)fribidi_reorder_nsm_status(3)fribidi_set_reorder_nsm(3)fribidi_log2vis_get_embedding_levels(3)fribidi_get_type(3)fribidi_get_type_internal(3)fribidi_get_par_embedding_levels(3)fribidi_join_arabic(3)fribidi_get_joining_type(3)fribidi_get_joining_types(3)fribidi_get_joining_type_name(3)fribidi_get_mirror_char(3)fribidi_shape_mirroring(3)fribidi_get_bracket(3)fribidi_get_bracket_types(3)fribidi_shape(3)fribidi_remove_bidi_marks(3)fribidi_log2vis(3)
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
- arch rolling: fribidi 1.0.18-1 Β· LGPL-2.1-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms