1/* FriBidi
2 * fribidi-joining-types.h - character joining types
3 *
4 * Author:
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 <fribidi.license@gmail.com>.
26 */
27#ifndef _FRIBIDI_JOINING_TYPES_H
28#define _FRIBIDI_JOINING_TYPES_H
29
30#include "fribidi-common.h"
31
32#include "fribidi-types.h"
33
34#include "fribidi-begindecls.h"
35
36/*
37 * Define bit masks that joining types are based on, each mask has
38 * only one bit set.
39 */
40
41#define FRIBIDI_MASK_JOINS_RIGHT 0x01 /* May join to right */
42#define FRIBIDI_MASK_JOINS_LEFT 0x02 /* May join to right */
43#define FRIBIDI_MASK_ARAB_SHAPES 0x04 /* May Arabic shape */
44#define FRIBIDI_MASK_TRANSPARENT 0x08 /* Is transparent */
45#define FRIBIDI_MASK_IGNORED 0x10 /* Is ignored */
46#define FRIBIDI_MASK_LIGATURED 0x20 /* Is ligatured */
47
48/*
49 * Define values for FriBidiJoiningType
50 */
51
52/* nUn-joining */
53#define FRIBIDI_JOINING_TYPE_U_VAL ( 0 )
54
55/* Right-joining */
56#define FRIBIDI_JOINING_TYPE_R_VAL \
57 ( FRIBIDI_MASK_JOINS_RIGHT | FRIBIDI_MASK_ARAB_SHAPES )
58
59/* Dual-joining */
60#define FRIBIDI_JOINING_TYPE_D_VAL \
61 ( FRIBIDI_MASK_JOINS_RIGHT | FRIBIDI_MASK_JOINS_LEFT \
62 | FRIBIDI_MASK_ARAB_SHAPES )
63
64/* join-Causing */
65#define FRIBIDI_JOINING_TYPE_C_VAL \
66 ( FRIBIDI_MASK_JOINS_RIGHT | FRIBIDI_MASK_JOINS_LEFT )
67
68/* Left-joining */
69#define FRIBIDI_JOINING_TYPE_L_VAL \
70 ( FRIBIDI_MASK_JOINS_LEFT | FRIBIDI_MASK_ARAB_SHAPES )
71
72/* Transparent */
73#define FRIBIDI_JOINING_TYPE_T_VAL \
74 ( FRIBIDI_MASK_TRANSPARENT | FRIBIDI_MASK_ARAB_SHAPES )
75
76/* iGnored */
77#define FRIBIDI_JOINING_TYPE_G_VAL ( FRIBIDI_MASK_IGNORED )
78
79
80enum _FriBidiJoiningTypeEnum
81{
82# define _FRIBIDI_ADD_TYPE(TYPE,SYMBOL) \
83 FRIBIDI_JOINING_TYPE_##TYPE = FRIBIDI_JOINING_TYPE_##TYPE##_VAL,
84# include "fribidi-joining-types-list.h"
85# undef _FRIBIDI_ADD_TYPE
86 _FRIBIDI_JOINING_TYPE_JUNK /* Don't use this */
87};
88
89#ifdef __FRIBIDI_DOC
90typedef enum _FriBidiJoiningTypeEnum FriBidiJoiningType;
91#else /* !__FRIBIDI_DOC */
92typedef uint8_t FriBidiJoiningType;
93#endif /* !__FRIBIDI_DOC */
94
95/* FriBidiArabicProp is essentially the same type as FriBidiJoiningType, but
96 * not limited to the few values returned by fribidi_get_joining_type. */
97typedef uint8_t FriBidiArabicProp;
98
99/*
100 * The equivalent of JoiningType values for ArabicProp
101 */
102
103/* Primary Arabic Joining Classes (Table 8-2) */
104
105/* nUn-joining */
106#define FRIBIDI_IS_JOINING_TYPE_U(p) \
107 ( 0 == ( (p) & \
108 ( FRIBIDI_MASK_TRANSPARENT | FRIBIDI_MASK_IGNORED \
109 | FRIBIDI_MASK_JOINS_RIGHT | FRIBIDI_MASK_JOINS_LEFT ) ) )
110
111/* Right-joining */
112#define FRIBIDI_IS_JOINING_TYPE_R(p) \
113 ( FRIBIDI_MASK_JOINS_RIGHT == ( (p) & \
114 ( FRIBIDI_MASK_TRANSPARENT | FRIBIDI_MASK_IGNORED \
115 | FRIBIDI_MASK_JOINS_RIGHT | FRIBIDI_MASK_JOINS_LEFT ) ) )
116
117/* Dual-joining */
118#define FRIBIDI_IS_JOINING_TYPE_D(p) \
119 ( ( FRIBIDI_MASK_JOINS_RIGHT | FRIBIDI_MASK_JOINS_LEFT \
120 | FRIBIDI_MASK_ARAB_SHAPES ) == ( (p) & \
121 ( FRIBIDI_MASK_TRANSPARENT | FRIBIDI_MASK_IGNORED \
122 | FRIBIDI_MASK_JOINS_RIGHT | FRIBIDI_MASK_JOINS_LEFT \
123 | FRIBIDI_MASK_ARAB_SHAPES ) ) )
124
125/* join-Causing */
126#define FRIBIDI_IS_JOINING_TYPE_C(p) \
127 ( ( FRIBIDI_MASK_JOINS_RIGHT | FRIBIDI_MASK_JOINS_LEFT ) == ( (p) & \
128 ( FRIBIDI_MASK_TRANSPARENT | FRIBIDI_MASK_IGNORED \
129 | FRIBIDI_MASK_JOINS_RIGHT | FRIBIDI_MASK_JOINS_LEFT \
130 | FRIBIDI_MASK_ARAB_SHAPES ) ) )
131
132/* Left-joining */
133#define FRIBIDI_IS_JOINING_TYPE_L(p) \
134 ( FRIBIDI_MASK_JOINS_LEFT == ( (p) & \
135 ( FRIBIDI_MASK_TRANSPARENT | FRIBIDI_MASK_IGNORED \
136 | FRIBIDI_MASK_JOINS_RIGHT | FRIBIDI_MASK_JOINS_LEFT ) ) )
137
138/* Transparent */
139#define FRIBIDI_IS_JOINING_TYPE_T(p) \
140 ( FRIBIDI_MASK_TRANSPARENT == ( (p) & \
141 ( FRIBIDI_MASK_TRANSPARENT | FRIBIDI_MASK_IGNORED ) ) )
142
143/* iGnored */
144#define FRIBIDI_IS_JOINING_TYPE_G(p) \
145 ( FRIBIDI_MASK_IGNORED == ( (p) & \
146 ( FRIBIDI_MASK_TRANSPARENT | FRIBIDI_MASK_IGNORED ) ) )
147
148/* and for Derived Arabic Joining Classes (Table 8-3) */
149
150/* Right join-Causing */
151#define FRIBIDI_IS_JOINING_TYPE_RC(p) \
152 ( FRIBIDI_MASK_JOINS_RIGHT == ( (p) & \
153 ( FRIBIDI_MASK_TRANSPARENT | FRIBIDI_MASK_IGNORED \
154 | FRIBIDI_MASK_JOINS_RIGHT ) ) )
155
156/* Left join-Causing */
157#define FRIBIDI_IS_JOINING_TYPE_LC(p) \
158 ( FRIBIDI_MASK_JOINS_LEFT == ( (p) & \
159 ( FRIBIDI_MASK_TRANSPARENT | FRIBIDI_MASK_IGNORED \
160 | FRIBIDI_MASK_JOINS_LEFT ) ) )
161
162
163/*
164 * Defining macros for needed queries, It is fully dependent on the
165 * implementation of FriBidiJoiningType.
166 */
167
168/* Joins to right: R, D, C? */
169#define FRIBIDI_JOINS_RIGHT(p) ((p) & FRIBIDI_MASK_JOINS_RIGHT)
170
171/* Joins to left: L, D, C? */
172#define FRIBIDI_JOINS_LEFT(p) ((p) & FRIBIDI_MASK_JOINS_LEFT)
173
174/* May shape: R, D, L, T? */
175#define FRIBIDI_ARAB_SHAPES(p) ((p) & FRIBIDI_MASK_ARAB_SHAPES)
176
177/* Is skipped in joining: T, G? */
178#define FRIBIDI_IS_JOIN_SKIPPED(p) \
179 ((p) & (FRIBIDI_MASK_TRANSPARENT | FRIBIDI_MASK_IGNORED))
180
181/* Is base that will be shaped: R, D, L? */
182#define FRIBIDI_IS_JOIN_BASE_SHAPES(p) \
183 ( FRIBIDI_MASK_ARAB_SHAPES == ( (p) & \
184 ( FRIBIDI_MASK_TRANSPARENT | FRIBIDI_MASK_IGNORED \
185 | FRIBIDI_MASK_ARAB_SHAPES ) ) )
186
187#define FRIBIDI_JOINS_PRECEDING_MASK(level) \
188 (FRIBIDI_LEVEL_IS_RTL (level) ? FRIBIDI_MASK_JOINS_RIGHT \
189 : FRIBIDI_MASK_JOINS_LEFT)
190
191#define FRIBIDI_JOINS_FOLLOWING_MASK(level) \
192 (FRIBIDI_LEVEL_IS_RTL (level) ? FRIBIDI_MASK_JOINS_LEFT \
193 : FRIBIDI_MASK_JOINS_RIGHT)
194
195#define FRIBIDI_JOIN_SHAPE(p) \
196 ((p) & ( FRIBIDI_MASK_JOINS_RIGHT | FRIBIDI_MASK_JOINS_LEFT ))
197
198/* Functions finally */
199
200
201/* fribidi_get_joining_type - get character joining type
202 *
203 * This function returns the joining type of a character as defined in Table
204 * 8-2 Primary Arabic Joining Classes of the Unicode standard available at
205 * http://www.unicode.org/versions/Unicode4.0.0/ch08.pdf#G7462, using data
206 * provided in file ArabicShaping.txt and UnicodeData.txt of the Unicode
207 * Character Database available at
208 * http://www.unicode.org/Public/UNIDATA/ArabicShaping.txt and
209 * http://www.unicode.org/Public/UNIDATA/UnicodeData.txt.
210 *
211 * There are a few macros defined in fribidi-joining-types.h for querying a
212 * joining type.
213 */
214FRIBIDI_ENTRY FriBidiJoiningType
215fribidi_get_joining_type (
216 FriBidiChar ch /* input character */
217) FRIBIDI_GNUC_CONST;
218
219/* fribidi_get_joining_types - get joining types for an string of characters
220 *
221 * This function finds the joining types of an string of characters. See
222 * fribidi_get_joining_type for more information about the joining types
223 * returned by this function.
224 */
225FRIBIDI_ENTRY void fribidi_get_joining_types (
226 const FriBidiChar *str, /* input string */
227 const FriBidiStrIndex len, /* input string length */
228 FriBidiJoiningType *jtypes /* output joining types */
229);
230
231/* fribidi_get_joining_type_name - get joining type name
232 *
233 * This function returns the joining type name of a joining type. The
234 * returned string is a static string and should not be freed.
235 *
236 * The type names are the same as ones defined in Table 8-2 Primary Arabic
237 * Joining Classes of the Unicode standard available at
238 * http://www.unicode.org/versions/Unicode4.0.0/ch08.pdf#G7462.
239 */
240FRIBIDI_ENTRY const char *fribidi_get_joining_type_name (
241 FriBidiJoiningType j /* input joining type */
242) FRIBIDI_GNUC_CONST;
243
244#include "fribidi-enddecls.h"
245
246#endif /* !_FRIBIDI_JOINING_TYPES_H */
247/* Editor directions:
248 * vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent
249 */
250

source code of gtk/subprojects/fribidi/lib/fribidi-joining-types.h