1 /* fribidi-mirroring.c - get mirrored character
3 * Copyright (C) 2004 Sharif FarsiWeb, Inc
4 * Copyright (C) 2001, 2002, 2004 Behdad Esfahbod
5 * Copyright (C) 1999, 2000, 2017 Dov Grobgeld
7 * This file is part of GNU FriBidi.
9 * GNU FriBidi is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GNU FriBidi 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
17 * GNU Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public License
20 * along with GNU FriBidi; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 * For licensing issues, contact <fribidi.license@gmail.com> or write to
24 * Sharif FarsiWeb, Inc., PO Box 13445-389, Tehran, Iran.
27 * Behdad Esfahbod, 2001, 2002, 2004
28 * Dov Grobgeld, 1999, 2000
33 #include <fribidi-mirroring.h>
35 #include "mirroring.tab.i"
37 FRIBIDI_ENTRY fribidi_boolean
38 fribidi_get_mirror_char (
42 FriBidiChar *mirrored_ch
45 register FriBidiChar result;
46 result = FRIBIDI_GET_MIRRORING (ch);
48 *mirrored_ch = result;
49 return ch != result ? true : false;
54 fribidi_shape_mirroring (
56 const FriBidiLevel *embedding_levels,
57 const FriBidiStrIndex len,
58 /* input and output */
62 register FriBidiStrIndex i;
64 DBG ("in fribidi_shape_mirroring");
67 (len == 0 || !str) return;
69 fribidi_assert (embedding_levels);
71 /* L4. Mirror all characters that are in odd levels and have mirrors. */
72 for (i = len - 1; i >= 0; i--)
73 if (FRIBIDI_LEVEL_IS_RTL (embedding_levels[i]))
75 FriBidiChar mirrored_ch;
77 if (fribidi_get_mirror_char (str[i], &mirrored_ch))
89 * vim: textwidth=78: autoindent: cindent: shiftwidth=2: tabstop=8: