Imported Upstream version 1.0.10
[platform/upstream/fribidi.git] / lib / fribidi.h
1 /* FriBidi
2  * fribidi.h - Unicode bidirectional and Arabic joining/shaping algorithms
3  *
4  * Author:
5  *   Behdad Esfahbod, 2004
6  *
7  * Copyright (C) 2004 Sharif FarsiWeb, Inc
8  * 
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.
13  * 
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.
18  * 
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
23  * 
24  * For licensing issues, contact <fribidi.license@gmail.com>.
25  */
26 #ifndef _FRIBIDI_H
27 #define _FRIBIDI_H
28
29 #include "fribidi-common.h"
30
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"
43
44 #include "fribidi-begindecls.h"
45
46 /* fribidi_remove_bidi_marks - remove bidi marks out of an string
47  *
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.
53  *
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
58  * valid entries.
59  * 
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.
62  * 
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.
65  *
66  * Returns: New length of the string, or \(mi1 if an error occurred (memory
67  * allocation failure most probably).
68  */
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
74                                            order used in str */
75   FriBidiStrIndex *position_from_this_list,     /* list mapping positions from the
76                                                    order used in str */
77   FriBidiLevel *embedding_levels        /* list of embedding levels */
78 );
79
80
81 /* fribidi_log2vis - get visual string
82  *
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.
87  *
88  * If NULL is passed as any of the the lists, the list is ignored and not
89  * filled.
90  *
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.
95  *
96  * Returns: Maximum level found plus one, or zero if any error occurred
97  * (memory allocation failure most probably).
98  */
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
103                                  * base direction */
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
109                                          * positions */
110   FriBidiLevel *embedding_levels        /* output list of embedding levels */
111 );
112
113 /* End of functions */
114
115 #ifdef FRIBIDI_NO_DEPRECATED
116 #else
117 # include "fribidi-deprecated.h"
118 #endif                          /* !FRIBIDI_NO_DEPRECATED */
119
120
121 /* An string containing the version information of the library. */
122 FRIBIDI_ENTRY FRIBIDI_EXTERN const char *fribidi_version_info;
123
124 #include "fribidi-enddecls.h"
125
126 #endif /* !_FRIBIDI_H */
127 /* Editor directions:
128  * vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent
129  */