2 * fribidi-deprecated.c - deprecated interfaces.
4 * $Id: fribidi-deprecated.c,v 1.6 2006-06-01 22:53:55 behdad Exp $
6 * $Date: 2006-06-01 22:53:55 $
8 * $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/fribidi-deprecated.c,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., 51 Franklin Street, Fifth Floor,
31 * Boston, MA 02110-1301, USA
33 * For licensing issues, contact <license@farsiweb.info>.
38 #undef FRIBIDI_NO_DEPRECATED
40 #include <fribidi-deprecated.h>
43 #if FRIBIDI_NO_DEPRECATED+0
46 static FriBidiFlags flags = FRIBIDI_FLAGS_DEFAULT | FRIBIDI_FLAGS_ARABIC;
48 FRIBIDI_ENTRY fribidi_boolean
49 fribidi_set_mirroring (
54 return FRIBIDI_ADJUST_AND_TEST_BITS (flags, FRIBIDI_FLAG_SHAPE_MIRRORING, state);
57 FRIBIDI_ENTRY fribidi_boolean
58 fribidi_mirroring_status (
62 return FRIBIDI_TEST_BITS (flags, FRIBIDI_FLAG_SHAPE_MIRRORING);
65 FRIBIDI_ENTRY fribidi_boolean
66 fribidi_set_reorder_nsm (
71 return FRIBIDI_ADJUST_AND_TEST_BITS (flags, FRIBIDI_FLAG_REORDER_NSM, state);
75 fribidi_reorder_nsm_status (
79 return FRIBIDI_TEST_BITS (flags, FRIBIDI_FLAG_REORDER_NSM);
85 FRIBIDI_ENTRY FriBidiLevel
86 fribidi_log2vis_get_embedding_levels (
87 const FriBidiCharType *bidi_types, /* input list of bidi types as returned by
88 fribidi_get_bidi_types() */
89 const FriBidiStrIndex len, /* input string length of the paragraph */
90 FriBidiParType *pbase_dir, /* requested and resolved paragraph
92 FriBidiLevel *embedding_levels /* output list of embedding levels */
95 return fribidi_get_par_embedding_levels (bidi_types, len, pbase_dir, embedding_levels);
98 FRIBIDI_ENTRY FriBidiCharType
100 FriBidiChar ch /* input character */
103 return fribidi_get_bidi_type (ch);
106 FRIBIDI_ENTRY FriBidiCharType
107 fribidi_get_type_internal (
108 FriBidiChar ch /* input character */
111 return fribidi_get_bidi_type (ch);
116 FRIBIDI_ENTRY FriBidiStrIndex
117 fribidi_remove_bidi_marks (
119 const FriBidiStrIndex len,
120 FriBidiStrIndex *positions_to_this,
121 FriBidiStrIndex *position_from_this_list,
122 FriBidiLevel *embedding_levels
125 register FriBidiStrIndex i, j = 0;
126 fribidi_boolean private_from_this = false;
127 fribidi_boolean status = false;
136 DBG ("in fribidi_remove_bidi_marks");
138 fribidi_assert (str);
140 /* If to_this is not NULL, we must have from_this as well. If it is
141 not given by the caller, we have to make a private instance of it. */
142 if (positions_to_this && !position_from_this_list)
144 position_from_this_list = fribidi_malloc (sizeof
145 (position_from_this_list[0]) *
148 (!position_from_this_list) goto out;
149 private_from_this = true;
150 for (i = 0; i < len; i++)
151 position_from_this_list[positions_to_this[i]] = i;
154 for (i = 0; i < len; i++)
155 if (!FRIBIDI_IS_EXPLICIT_OR_BN (fribidi_get_bidi_type (str[i]))
156 && str[i] != FRIBIDI_CHAR_LRM && str[i] != FRIBIDI_CHAR_RLM)
159 if (embedding_levels)
160 embedding_levels[j] = embedding_levels[i];
161 if (position_from_this_list)
162 position_from_this_list[j] = position_from_this_list[i];
166 /* Convert the from_this list to to_this */
167 if (positions_to_this)
169 for (i = 0; i < len; i++)
170 positions_to_this[i] = -1;
171 for (i = 0; i < len; i++)
172 positions_to_this[position_from_this_list[i]] = i;
179 if (private_from_this)
180 fribidi_free (position_from_this_list);
182 return status ? j : -1;
187 FRIBIDI_ENTRY FriBidiLevel
190 const FriBidiChar *str,
192 /* input and output */
193 FriBidiParType *pbase_dir,
195 FriBidiChar *visual_str,
196 FriBidiStrIndex *positions_L_to_V,
197 FriBidiStrIndex *positions_V_to_L,
198 FriBidiLevel *embedding_levels
201 register FriBidiStrIndex i;
202 FriBidiLevel max_level = 0;
203 fribidi_boolean private_V_to_L = false;
204 fribidi_boolean private_embedding_levels = false;
205 fribidi_boolean status = false;
206 FriBidiArabicProp *ar_props = NULL;
207 FriBidiCharType *bidi_types = NULL;
216 DBG ("in fribidi_log2vis");
218 fribidi_assert (str);
219 fribidi_assert (pbase_dir);
221 bidi_types = fribidi_malloc (len * sizeof bidi_types[0]);
225 fribidi_get_bidi_types (str, len, bidi_types);
227 if (!embedding_levels)
229 embedding_levels = fribidi_malloc (len * sizeof embedding_levels[0]);
230 if (!embedding_levels)
232 private_embedding_levels = true;
235 max_level = fribidi_get_par_embedding_levels (bidi_types, len, pbase_dir,
236 embedding_levels) - 1;
238 (max_level < 0) goto out;
240 /* If l2v is to be calculated we must have v2l as well. If it is not
241 given by the caller, we have to make a private instance of it. */
242 if (positions_L_to_V && !positions_V_to_L)
245 (FriBidiStrIndex *) fribidi_malloc (sizeof (FriBidiStrIndex) * len);
246 if (!positions_V_to_L)
248 private_V_to_L = true;
251 /* Set up the ordering array to identity order */
252 if (positions_V_to_L)
254 for (i = 0; i < len; i++)
255 positions_V_to_L[i] = i;
261 /* Using memcpy instead
262 for (i = len - 1; i >= 0; i--)
263 visual_str[i] = str[i];
265 memcpy (visual_str, str, len * sizeof (*visual_str));
268 ar_props = fribidi_malloc (len * sizeof ar_props[0]);
269 fribidi_get_joining_types (str, len, ar_props);
270 fribidi_join_arabic (bidi_types, len, embedding_levels, ar_props);
272 fribidi_shape (flags, embedding_levels, len, ar_props, visual_str);
275 /* line breaking goes here, but we assume one line in this function */
277 /* and this should be called once per line, but again, we assume one
278 * line in this deprecated function */
280 fribidi_reorder_line (flags, bidi_types, len, 0, *pbase_dir,
281 embedding_levels, visual_str,
284 /* Convert the v2l list to l2v */
285 if (positions_L_to_V)
287 for (i = 0; i < len; i++)
288 positions_L_to_V[i] = -1;
289 for (i = 0; i < len; i++)
290 positions_L_to_V[positions_V_to_L[i]] = i;
296 fribidi_free (positions_V_to_L);
298 if (private_embedding_levels)
299 fribidi_free (embedding_levels);
302 fribidi_free (ar_props);
305 fribidi_free (bidi_types);
307 return status ? max_level + 1 : 0;
310 #endif /* !FRIBIDI_NO_DEPRECATED */
312 /* Editor directions:
313 * vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent