2 * fribidi.h - Unicode bidirectional and Arabic joining/shaping algorithms
5 * Behdad Esfahbod, 2004
7 * Copyright (C) 2004 Sharif FarsiWeb, Inc
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with this library, in a file named COPYING; if not, write to the
21 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
22 * Boston, MA 02110-1301, USA
24 * For licensing issues, contact <fribidi.license@gmail.com>.
29 #include "fribidi-common.h"
31 #include "fribidi-unicode.h"
32 #include "fribidi-types.h"
33 #include "fribidi-flags.h"
34 #include "fribidi-bidi-types.h"
35 #include "fribidi-bidi.h"
36 #include "fribidi-joining-types.h"
37 #include "fribidi-joining.h"
38 #include "fribidi-mirroring.h"
39 #include "fribidi-brackets.h"
40 #include "fribidi-arabic.h"
41 #include "fribidi-shape.h"
42 #include "fribidi-char-sets.h"
44 #include "fribidi-begindecls.h"
46 /* fribidi_remove_bidi_marks - remove bidi marks out of an string
48 * This function removes the bidi and boundary-neutral marks out of an string
49 * and the accompanying lists. It implements rule X9 of the Unicode
50 * Bidirectional Algorithm available at
51 * http://www.unicode.org/reports/tr9/#X9, with the exception that it removes
52 * U+200E LEFT-TO-RIGHT MARK and U+200F RIGHT-TO-LEFT MARK too.
54 * If any of the input lists are NULL, the list is skipped. If str is the
55 * visual string, then positions_to_this is positions_L_to_V and
56 * position_from_this_list is positions_V_to_L; if str is the logical
57 * string, the other way. Moreover, the position maps should be filled with
60 * A position map pointing to a removed character is filled with \(mi1. By the
61 * way, you should not use embedding_levels if str is visual string.
63 * For best results this function should be run on a whole paragraph, not
64 * lines; but feel free to do otherwise if you know what you are doing.
66 * Returns: New length of the string, or \(mi1 if an error occurred (memory
67 * allocation failure most probably).
69 FRIBIDI_ENTRY FriBidiStrIndex
70 fribidi_remove_bidi_marks (
71 FriBidiChar *str, /* input string to clean */
72 const FriBidiStrIndex len, /* input string length */
73 FriBidiStrIndex *positions_to_this, /* list mapping positions to the
75 FriBidiStrIndex *position_from_this_list, /* list mapping positions from the
77 FriBidiLevel *embedding_levels /* list of embedding levels */
81 /* fribidi_log2vis - get visual string
83 * This function converts the logical input string to the visual output
84 * strings as specified by the Unicode Bidirectional Algorithm. As a side
85 * effect it also generates mapping lists between the two strings, and the
86 * list of embedding levels as defined by the algorithm.
88 * If NULL is passed as any of the the lists, the list is ignored and not
91 * Note that this function handles one-line paragraphs. For multi-
92 * paragraph texts it is necessary to first split the text into
93 * separate paragraphs and then carry over the resolved pbase_dir
94 * between the subsequent invocations.
96 * Returns: Maximum level found plus one, or zero if any error occurred
97 * (memory allocation failure most probably).
99 FRIBIDI_ENTRY FriBidiLevel fribidi_log2vis (
100 const FriBidiChar *str, /* input logical string */
101 const FriBidiStrIndex len, /* input string length */
102 FriBidiParType *pbase_dir, /* requested and resolved paragraph
104 FriBidiChar *visual_str, /* output visual string */
105 FriBidiStrIndex *positions_L_to_V, /* output mapping from logical to
106 * visual string positions */
107 FriBidiStrIndex *positions_V_to_L, /* output mapping from visual string
108 * back to the logical string
110 FriBidiLevel *embedding_levels /* output list of embedding levels */
113 /* End of functions */
115 #ifdef FRIBIDI_NO_DEPRECATED
117 # include "fribidi-deprecated.h"
118 #endif /* !FRIBIDI_NO_DEPRECATED */
121 /* An string containing the version information of the library. */
122 FRIBIDI_ENTRY FRIBIDI_EXTERN const char *fribidi_version_info;
124 #include "fribidi-enddecls.h"
126 #endif /* !_FRIBIDI_H */
127 /* Editor directions:
128 * vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent