2 * fribidi-bidi.h - bidirectional algorithm
4 * $Id: fribidi-bidi.h,v 1.15 2005-11-03 01:39:01 behdad Exp $
6 * $Date: 2005-11-03 01:39:01 $
8 * $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/fribidi-bidi.h,v $
11 * Behdad Esfahbod, 2001, 2002, 2004
12 * Dov Grobgeld, 1999, 2000
14 * Copyright (C) 2004 Sharif FarsiWeb, Inc
15 * Copyright (C) 2001,2002 Behdad Esfahbod
16 * Copyright (C) 1999,2000 Dov Grobgeld
18 * This library is free software; you can redistribute it and/or
19 * modify it under the terms of the GNU Lesser General Public
20 * License as published by the Free Software Foundation; either
21 * version 2.1 of the License, or (at your option) any later version.
23 * This library is distributed in the hope that it will be useful,
24 * but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
26 * Lesser General Public License for more details.
28 * You should have received a copy of the GNU Lesser General Public License
29 * along with this library, in a file named COPYING; if not, write to the
30 * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
31 * Boston, MA 02111-1307, USA
33 * For licensing issues, contact <license@farsiweb.info>.
35 #ifndef _FRIBIDI_BIDI_H
36 #define _FRIBIDI_BIDI_H
38 #include "fribidi-common.h"
40 #include "fribidi-types.h"
41 #include "fribidi-flags.h"
42 #include "fribidi-bidi-types.h"
44 #include "fribidi-begindecls.h"
46 #define fribidi_get_par_embedding_levels FRIBIDI_NAMESPACE(get_par_embedding_levels)
47 /* fribidi_get_par_direction - get base paragraph direction
49 * This function finds the base direction of a single paragraph,
50 * as defined by rule P2 of the Unicode Bidirectional Algorithm available at
51 * http://www.unicode.org/reports/tr9/#P2.
53 * You typically do not need this function as
54 * fribidi_get_par_embedding_levels() knows how to compute base direction
55 * itself, but you may need this to implement a more sophisticated paragraph
56 * direction handling. Note that you can pass more than a paragraph to this
57 * function and the direction of the first non-neutral paragraph is returned,
58 * which is a very good heuristic to set direction of the neutral paragraphs
59 * at the beginning of text. For other neutral paragraphs, you better use the
60 * direction of the previous paragraph.
62 * Returns: Base pargraph direction. No weak paragraph direction is returned,
63 * only LTR, RTL, or ON.
65 FRIBIDI_ENTRY FriBidiParType fribidi_get_par_direction (
66 const FriBidiCharType *bidi_types, /* input list of bidi types as returned by
67 fribidi_get_bidi_types() */
68 const FriBidiStrIndex len /* input string length */
71 #define fribidi_get_par_embedding_levels FRIBIDI_NAMESPACE(get_par_embedding_levels)
72 /* fribidi_get_par_embedding_levels - get bidi embedding levels of a paragraph
74 * This function finds the bidi embedding levels of a single paragraph,
75 * as defined by the Unicode Bidirectional Algorithm available at
76 * http://www.unicode.org/reports/tr9/. This function implements rules P2 to
77 * I1 inclusive, and parts 1 to 3 of L1, except for rule X9 which is
78 * implemented in fribidi_remove_bidi_marks(). Part 4 of L1 is implemented
79 * in fribidi_reorder_line().
81 * There are a few macros defined in fribidi-bidi-types.h to work with this
84 * Returns: Maximum level found plus one, or zero if any error occured
85 * (memory allocation failure most probably).
87 FRIBIDI_ENTRY FriBidiLevel
88 fribidi_get_par_embedding_levels (
89 const FriBidiCharType *bidi_types, /* input list of bidi types as returned by
90 fribidi_get_bidi_types() */
91 const FriBidiStrIndex len, /* input string length of the paragraph */
92 FriBidiParType *pbase_dir, /* requested and resolved paragraph
94 FriBidiLevel *embedding_levels /* output list of embedding levels */
95 ) FRIBIDI_GNUC_WARN_UNUSED;
97 #define fribidi_reorder_line FRIBIDI_NAMESPACE(reorder_line)
98 /* fribidi_reorder_line - reorder a line of logical string to visual
100 * This function reorders the characters in a line of text from logical to
101 * final visual order. This function implements part 4 of rule L1, and rules
102 * L2 and L3 of the Unicode Bidirectional Algorithm available at
103 * http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels.
105 * As a side effect it also sets position maps if not NULL.
107 * You should provide the resolved paragraph direction and embedding levels as
108 * set by fribidi_get_par_embedding_levels(). Also note that the embedding
109 * levels may change a bit. To be exact, the embedding level of any sequence
110 * of white space at the end of line is reset to the paragraph embedding level
111 * (That is part 4 of rule L1).
113 * Note that the bidi types and embedding levels are not reordered. You can
114 * reorder these (or any other) arrays using the map later. The user is
115 * responsible to initialize map to something sensible, like an identity
116 * mapping, or pass NULL if no map is needed.
118 * There is an optional part to this function, which is whether non-spacing
119 * marks for right-to-left parts of the text should be reordered to come after
120 * their base characters in the visual string or not. Most rendering engines
121 * expect this behavior, but console-based systems for example do not like it.
122 * This is controlled by the FRIBIDI_FLAG_REORDER_NSM flag. The flag is on
123 * in FRIBIDI_FLAGS_DEFAULT.
125 * Returns: Maximum level found in this line plus one, or zero if any error
126 * occured (memory allocation failure most probably).
128 FRIBIDI_ENTRY FriBidiLevel fribidi_reorder_line (
129 FriBidiFlags flags, /* reorder flags */
130 const FriBidiCharType *bidi_types, /* input list of bidi types as returned by
131 fribidi_get_bidi_types() */
132 const FriBidiStrIndex len, /* input length of the line */
133 const FriBidiStrIndex off, /* input offset of the beginning of the line
135 const FriBidiParType base_dir, /* resolved paragraph base direction */
136 FriBidiLevel *embedding_levels, /* input list of embedding levels,
138 fribidi_get_par_embedding_levels */
139 FriBidiChar *visual_str, /* visual string to reorder */
140 FriBidiStrIndex *map /* a map of string indices which is reordered
141 * to reflect where each glyph ends up. */
142 ) FRIBIDI_GNUC_WARN_UNUSED;
144 #include "fribidi-enddecls.h"
146 #endif /* !_FRIBIDI_BIDI_H */
147 /* Editor directions:
148 * vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent