| 1 |
/* FriBidi |
| 2 |
* fribidi-joining-types.c - character joining types |
| 3 |
* |
| 4 |
* Authors: |
| 5 |
* Behdad Esfahbod, 2001, 2002, 2004 |
| 6 |
* |
| 7 |
* Copyright (C) 2004 Sharif FarsiWeb, Inc. |
| 8 |
* Copyright (C) 2001,2002 Behdad Esfahbod |
| 9 |
* |
| 10 |
* This library is free software; you can redistribute it and/or |
| 11 |
* modify it under the terms of the GNU Lesser General Public |
| 12 |
* License as published by the Free Software Foundation; either |
| 13 |
* version 2.1 of the License, or (at your option) any later version. |
| 14 |
* |
| 15 |
* This library is distributed in the hope that it will be useful, |
| 16 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 18 |
* Lesser General Public License for more details. |
| 19 |
* |
| 20 |
* You should have received a copy of the GNU Lesser General Public License |
| 21 |
* along with this library, in a file named COPYING; if not, write to the |
| 22 |
* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 23 |
* Boston, MA 02110-1301, USA |
| 24 |
* |
| 25 |
* For licensing issues, contact <[email protected]>. |
| 26 |
*/ |
| 27 |
|
| 28 |
#include "common.h" |
| 29 |
|
| 30 |
#include <fribidi-joining-types.h> |
| 31 |
|
| 32 |
#include "joining-types.h" |
| 33 |
|
| 34 |
enum FriBidiJoiningTypeShortEnum |
| 35 |
{ |
| 36 |
# define _FRIBIDI_ADD_TYPE(TYPE,SYMBOL) TYPE = FRIBIDI_JOINING_TYPE_##TYPE, |
| 37 |
# include "fribidi-joining-types-list.h" |
| 38 |
# undef _FRIBIDI_ADD_TYPE |
| 39 |
_FRIBIDI_NUM_TYPES |
| 40 |
}; |
| 41 |
|
| 42 |
#include "joining-type.tab.i" |
| 43 |
|
| 44 |
FRIBIDI_ENTRY FriBidiJoiningType |
| 45 |
fribidi_get_joining_type ( |
| 46 |
/* input */ |
| 47 |
FriBidiChar ch |
| 48 |
) |
| 49 |
{ |
| 50 |
return FRIBIDI_GET_JOINING_TYPE (ch); |
| 51 |
} |
| 52 |
|
| 53 |
FRIBIDI_ENTRY void |
| 54 |
fribidi_get_joining_types ( |
| 55 |
/* input */ |
| 56 |
const FriBidiChar *str, |
| 57 |
const FriBidiStrIndex len, |
| 58 |
/* output */ |
| 59 |
FriBidiJoiningType *jtypes |
| 60 |
) |
| 61 |
{ |
| 62 |
register FriBidiStrIndex i = len; |
| 63 |
for (; i; i--) |
| 64 |
{ |
| 65 |
*jtypes++ = FRIBIDI_GET_JOINING_TYPE (*str); |
| 66 |
str++; |
| 67 |
} |
| 68 |
} |
| 69 |
|
| 70 |
FRIBIDI_ENTRY const char * |
| 71 |
fribidi_get_joining_type_name ( |
| 72 |
/* input */ |
| 73 |
FriBidiJoiningType j |
| 74 |
) |
| 75 |
{ |
| 76 |
switch (j) |
| 77 |
{ |
| 78 |
# define _FRIBIDI_ADD_TYPE(TYPE,SYMBOL) case FRIBIDI_JOINING_TYPE_##TYPE: return STRINGIZE(TYPE); |
| 79 |
# include "fribidi-joining-types-list.h" |
| 80 |
# undef _FRIBIDI_ADD_TYPE |
| 81 |
default: |
| 82 |
return "?"; |
| 83 |
} |
| 84 |
} |
| 85 |
|
| 86 |
#ifdef DEBUG |
| 87 |
|
| 88 |
char |
| 89 |
fribidi_char_from_joining_type ( |
| 90 |
/* input */ |
| 91 |
FriBidiJoiningType j, |
| 92 |
fribidi_boolean visual |
| 93 |
) |
| 94 |
{ |
| 95 |
/* switch left and right if on visual run */ |
| 96 |
if (visual & ((FRIBIDI_JOINS_RIGHT (j) && !FRIBIDI_JOINS_LEFT (j)) | |
| 97 |
(!FRIBIDI_JOINS_RIGHT (j) && FRIBIDI_JOINS_LEFT (j)))) |
| 98 |
j ^= FRIBIDI_MASK_JOINS_RIGHT | FRIBIDI_MASK_JOINS_LEFT; |
| 99 |
|
| 100 |
# define _FRIBIDI_ADD_TYPE(TYPE,SYMBOL) \ |
| 101 |
if (FRIBIDI_IS_JOINING_TYPE_##TYPE(j)) return SYMBOL; |
| 102 |
# include "fribidi-joining-types-list.h" |
| 103 |
# undef _FRIBIDI_ADD_TYPE |
| 104 |
|
| 105 |
return '?'; |
| 106 |
} |
| 107 |
|
| 108 |
#endif /* DEBUG */ |
| 109 |
|
| 110 |
/* Editor directions: |
| 111 |
* vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent |
| 112 |
*/ |