[Tizen] Add codes for Dali Windows Backend
[platform/core/uifw/dali-adaptor.git] / dali-windows-backend / ExInclude / fribidi / fribidi-bidi-types.h
1 /* FriBidi
2  * fribidi-bidi-types.h - character bidi types
3  *
4  * $Id: fribidi-bidi-types.h,v 1.15 2008-11-24 17:48:31 behdad Exp $
5  * $Author: behdad $
6  * $Date: 2008-11-24 17:48:31 $
7  * $Revision: 1.15 $
8  * $Source: /cvs/fribidi/fribidi2/lib/fribidi-bidi-types.h,v $
9  *
10  * Author:
11  *   Behdad Esfahbod, 2001, 2002, 2004
12  *
13  * Copyright (C) 2004 Sharif FarsiWeb, Inc.
14  * Copyright (C) 2001,2002 Behdad Esfahbod
15  * 
16  * This library is free software; you can redistribute it and/or
17  * modify it under the terms of the GNU Lesser General Public
18  * License as published by the Free Software Foundation; either
19  * version 2.1 of the License, or (at your option) any later version.
20  * 
21  * This library is distributed in the hope that it will be useful,
22  * but WITHOUT ANY WARRANTY; without even the implied warranty of
23  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
24  * Lesser General Public License for more details.
25  * 
26  * You should have received a copy of the GNU Lesser General Public License
27  * along with this library, in a file named COPYING; if not, write to the
28  * Free Software Foundation, Inc., 59 Temple Place, Suite 330,
29  * Boston, MA 02111-1307, USA
30  *
31  * For licensing issues, contact <license@farsiweb.info>.
32  */
33 #ifndef _FRIBIDI_BIDI_TYPES_H
34 #define _FRIBIDI_BIDI_TYPES_H
35
36 #include "fribidi-common.h"
37
38 #include "fribidi-types.h"
39
40 #include "fribidi-begindecls.h"
41
42 typedef signed char FriBidiLevel;
43
44 /* 
45  * Define bit masks that bidi types are based on, each mask has
46  * only one bit set.
47  */
48
49 /* RTL mask better be the least significant bit. */
50 #define FRIBIDI_MASK_RTL        0x00000001L     /* Is right to left */
51 #define FRIBIDI_MASK_ARABIC     0x00000002L     /* Is arabic */
52
53 /* Each char can be only one of the three following. */
54 #define FRIBIDI_MASK_STRONG     0x00000010L     /* Is strong */
55 #define FRIBIDI_MASK_WEAK       0x00000020L     /* Is weak */
56 #define FRIBIDI_MASK_NEUTRAL    0x00000040L     /* Is neutral */
57 #define FRIBIDI_MASK_SENTINEL   0x00000080L     /* Is sentinel */
58 /* Sentinels are not valid chars, just identify the start/end of strings. */
59
60 /* Each char can be only one of the five following. */
61 #define FRIBIDI_MASK_LETTER     0x00000100L     /* Is letter: L, R, AL */
62 #define FRIBIDI_MASK_NUMBER     0x00000200L     /* Is number: EN, AN */
63 #define FRIBIDI_MASK_NUMSEPTER  0x00000400L     /* Is separator or terminator: ES, ET, CS */
64 #define FRIBIDI_MASK_SPACE      0x00000800L     /* Is space: BN, BS, SS, WS */
65 #define FRIBIDI_MASK_EXPLICIT   0x00001000L     /* Is expilict mark: LRE, RLE, LRO, RLO, PDF */
66
67 /* Can be set only if FRIBIDI_MASK_SPACE is also set. */
68 #define FRIBIDI_MASK_SEPARATOR  0x00002000L     /* Is text separator: BS, SS */
69 /* Can be set only if FRIBIDI_MASK_EXPLICIT is also set. */
70 #define FRIBIDI_MASK_OVERRIDE   0x00004000L     /* Is explicit override: LRO, RLO */
71
72 /* The following exist to make types pairwise different, some of them can
73  * be removed but are here because of efficiency (make queries faster). */
74
75 #define FRIBIDI_MASK_ES         0x00010000L
76 #define FRIBIDI_MASK_ET         0x00020000L
77 #define FRIBIDI_MASK_CS         0x00040000L
78
79 #define FRIBIDI_MASK_NSM        0x00080000L
80 #define FRIBIDI_MASK_BN         0x00100000L
81
82 #define FRIBIDI_MASK_BS         0x00200000L
83 #define FRIBIDI_MASK_SS         0x00400000L
84 #define FRIBIDI_MASK_WS         0x00800000L
85
86 /* We reserve a single bit for user's private use: we will never use it. */
87 #define FRIBIDI_MASK_PRIVATE    0x01000000L
88
89
90 /*
91  * Define values for FriBidiCharType
92  */
93
94 /* Strong types */
95
96 /* Left-To-Right letter */
97 #define FRIBIDI_TYPE_LTR_VAL    ( FRIBIDI_MASK_STRONG | FRIBIDI_MASK_LETTER )
98 /* Right-To-Left letter */
99 #define FRIBIDI_TYPE_RTL_VAL    ( FRIBIDI_MASK_STRONG | FRIBIDI_MASK_LETTER \
100                                 | FRIBIDI_MASK_RTL)
101 /* Arabic Letter */
102 #define FRIBIDI_TYPE_AL_VAL     ( FRIBIDI_MASK_STRONG | FRIBIDI_MASK_LETTER \
103                                 | FRIBIDI_MASK_RTL | FRIBIDI_MASK_ARABIC )
104 /* Left-to-Right Embedding */
105 #define FRIBIDI_TYPE_LRE_VAL    ( FRIBIDI_MASK_STRONG | FRIBIDI_MASK_EXPLICIT)
106 /* Right-to-Left Embedding */
107 #define FRIBIDI_TYPE_RLE_VAL    ( FRIBIDI_MASK_STRONG | FRIBIDI_MASK_EXPLICIT \
108                                 | FRIBIDI_MASK_RTL )
109 /* Left-to-Right Override */
110 #define FRIBIDI_TYPE_LRO_VAL    ( FRIBIDI_MASK_STRONG | FRIBIDI_MASK_EXPLICIT \
111                                 | FRIBIDI_MASK_OVERRIDE )
112 /* Right-to-Left Override */
113 #define FRIBIDI_TYPE_RLO_VAL    ( FRIBIDI_MASK_STRONG | FRIBIDI_MASK_EXPLICIT \
114                                 | FRIBIDI_MASK_RTL | FRIBIDI_MASK_OVERRIDE )
115
116 /* Weak types */
117
118 /* Pop Directional Flag*/
119 #define FRIBIDI_TYPE_PDF_VAL    ( FRIBIDI_MASK_WEAK | FRIBIDI_MASK_EXPLICIT )
120 /* European Numeral */
121 #define FRIBIDI_TYPE_EN_VAL     ( FRIBIDI_MASK_WEAK | FRIBIDI_MASK_NUMBER )
122 /* Arabic Numeral */
123 #define FRIBIDI_TYPE_AN_VAL     ( FRIBIDI_MASK_WEAK | FRIBIDI_MASK_NUMBER \
124                                 | FRIBIDI_MASK_ARABIC )
125 /* European number Separator */
126 #define FRIBIDI_TYPE_ES_VAL     ( FRIBIDI_MASK_WEAK | FRIBIDI_MASK_NUMSEPTER \
127                                 | FRIBIDI_MASK_ES )
128 /* European number Terminator */
129 #define FRIBIDI_TYPE_ET_VAL     ( FRIBIDI_MASK_WEAK | FRIBIDI_MASK_NUMSEPTER \
130                                 | FRIBIDI_MASK_ET )
131 /* Common Separator */
132 #define FRIBIDI_TYPE_CS_VAL     ( FRIBIDI_MASK_WEAK | FRIBIDI_MASK_NUMSEPTER \
133                                 | FRIBIDI_MASK_CS )
134 /* Non Spacing Mark */
135 #define FRIBIDI_TYPE_NSM_VAL    ( FRIBIDI_MASK_WEAK | FRIBIDI_MASK_NSM )
136 /* Boundary Neutral */
137 #define FRIBIDI_TYPE_BN_VAL     ( FRIBIDI_MASK_WEAK | FRIBIDI_MASK_SPACE \
138                                 | FRIBIDI_MASK_BN )
139
140 /* Neutral types */
141
142 /* Block Separator */
143 #define FRIBIDI_TYPE_BS_VAL     ( FRIBIDI_MASK_NEUTRAL | FRIBIDI_MASK_SPACE \
144                                 | FRIBIDI_MASK_SEPARATOR | FRIBIDI_MASK_BS )
145 /* Segment Separator */
146 #define FRIBIDI_TYPE_SS_VAL     ( FRIBIDI_MASK_NEUTRAL | FRIBIDI_MASK_SPACE \
147                                 | FRIBIDI_MASK_SEPARATOR | FRIBIDI_MASK_SS )
148 /* WhiteSpace */
149 #define FRIBIDI_TYPE_WS_VAL     ( FRIBIDI_MASK_NEUTRAL | FRIBIDI_MASK_SPACE \
150                                 | FRIBIDI_MASK_WS )
151 /* Other Neutral */
152 #define FRIBIDI_TYPE_ON_VAL     ( FRIBIDI_MASK_NEUTRAL )
153
154
155 /* The following are used in specifying paragraph direction only. */
156
157 /* Weak Left-To-Right */
158 #define FRIBIDI_TYPE_WLTR_VAL   ( FRIBIDI_MASK_WEAK )
159 /* Weak Right-To-Left */
160 #define FRIBIDI_TYPE_WRTL_VAL   ( FRIBIDI_MASK_WEAK | FRIBIDI_MASK_RTL )
161
162 /* start or end of text (run list) SENTINEL.  Only used internally */
163 #define FRIBIDI_TYPE_SENTINEL   ( FRIBIDI_MASK_SENTINEL )
164
165 /* Private types for applications.  More private types can be obtained by
166  * summing up from this one. */
167 #define FRIBIDI_TYPE_PRIVATE    ( FRIBIDI_MASK_PRIVATE )
168
169
170 /* Define Enums only if sizeof(int) == 4 (UTF-32), and not compiling C++.
171  * The problem with C++ is that then casts between int32 and enum will fail!
172  */
173 #if defined(__FRIBIDI_DOC) || (FRIBIDI_SIZEOF_INT+0 == 4 && !defined(__cplusplus))
174
175 typedef enum
176 {
177 # define _FRIBIDI_ADD_TYPE(TYPE,SYMBOL) \
178         FRIBIDI_TYPE_##TYPE = FRIBIDI_TYPE_##TYPE##_VAL,
179 # include "fribidi-bidi-types-list.h"
180 # undef _FRIBIDI_ADD_TYPE
181   _FRIBIDI_TYPE_SENTINEL = FRIBIDI_TYPE_SENTINEL        /* Don't use this */
182 } FriBidiCharType;
183
184 typedef enum
185 {
186 # define _FRIBIDI_PAR_TYPES
187 # define _FRIBIDI_ADD_TYPE(TYPE,SYMBOL) \
188         FRIBIDI_PAR_##TYPE = FRIBIDI_TYPE_##TYPE##_VAL,
189 # include "fribidi-bidi-types-list.h"
190 # undef _FRIBIDI_ADD_TYPE
191 # undef _FRIBIDI_PAR_TYPES
192   _FRIBIDI_PAR_SENTINEL = FRIBIDI_TYPE_SENTINEL /* Don't use this */
193 } FriBidiParType;
194
195 #else
196
197 typedef fribidi_uint32 FriBidiCharType;
198 # define FRIBIDI_TYPE_LTR       FRIBIDI_TYPE_LTR_VAL
199 # define FRIBIDI_TYPE_RTL       FRIBIDI_TYPE_RTL_VAL
200 # define FRIBIDI_TYPE_AL        FRIBIDI_TYPE_AL_VAL
201 # define FRIBIDI_TYPE_EN        FRIBIDI_TYPE_EN_VAL
202 # define FRIBIDI_TYPE_AN        FRIBIDI_TYPE_AN_VAL
203 # define FRIBIDI_TYPE_ES        FRIBIDI_TYPE_ES_VAL
204 # define FRIBIDI_TYPE_ET        FRIBIDI_TYPE_ET_VAL
205 # define FRIBIDI_TYPE_CS        FRIBIDI_TYPE_CS_VAL
206 # define FRIBIDI_TYPE_NSM       FRIBIDI_TYPE_NSM_VAL
207 # define FRIBIDI_TYPE_BN        FRIBIDI_TYPE_BN_VAL
208 # define FRIBIDI_TYPE_BS        FRIBIDI_TYPE_BS_VAL
209 # define FRIBIDI_TYPE_SS        FRIBIDI_TYPE_SS_VAL
210 # define FRIBIDI_TYPE_WS        FRIBIDI_TYPE_WS_VAL
211 # define FRIBIDI_TYPE_ON        FRIBIDI_TYPE_ON_VAL
212 # define FRIBIDI_TYPE_LRE       FRIBIDI_TYPE_LRE_VAL
213 # define FRIBIDI_TYPE_RLE       FRIBIDI_TYPE_RLE_VAL
214 # define FRIBIDI_TYPE_LRO       FRIBIDI_TYPE_LRO_VAL
215 # define FRIBIDI_TYPE_RLO       FRIBIDI_TYPE_RLO_VAL
216 # define FRIBIDI_TYPE_PDF       FRIBIDI_TYPE_PDF_VAL
217
218 typedef fribidi_uint32 FriBidiParType;
219 # define FRIBIDI_PAR_LTR        FRIBIDI_TYPE_LTR_VAL
220 # define FRIBIDI_PAR_RTL        FRIBIDI_TYPE_RTL_VAL
221 # define FRIBIDI_PAR_ON         FRIBIDI_TYPE_ON_VAL
222 # define FRIBIDI_PAR_WLTR       FRIBIDI_TYPE_WLTR_VAL
223 # define FRIBIDI_PAR_WRTL       FRIBIDI_TYPE_WRTL_VAL
224
225 #endif
226
227 /* Please don't use these two type names, use FRIBIDI_PAR_* form instead. */
228 #define FRIBIDI_TYPE_WLTR       FRIBIDI_PAR_WLTR
229 #define FRIBIDI_TYPE_WRTL       FRIBIDI_PAR_WRTL
230
231
232 /*
233  * Defining macros for needed queries, It is fully dependent on the 
234  * implementation of FriBidiCharType.
235  */
236
237
238 /* Is right-to-left level? */
239 #define FRIBIDI_LEVEL_IS_RTL(lev) ((lev) & 1)
240
241 /* Return the bidi type corresponding to the direction of the level number,
242    FRIBIDI_TYPE_LTR for evens and FRIBIDI_TYPE_RTL for odds. */
243 #define FRIBIDI_LEVEL_TO_DIR(lev)       \
244         (FRIBIDI_LEVEL_IS_RTL (lev) ? FRIBIDI_TYPE_RTL : FRIBIDI_TYPE_LTR)
245
246 /* Return the minimum level of the direction, 0 for FRIBIDI_TYPE_LTR and
247    1 for FRIBIDI_TYPE_RTL and FRIBIDI_TYPE_AL. */
248 #define FRIBIDI_DIR_TO_LEVEL(dir)       \
249         ((FriBidiLevel) (FRIBIDI_IS_RTL (dir) ? 1 : 0))
250
251 /* Is right to left: RTL, AL, RLE, RLO? */
252 #define FRIBIDI_IS_RTL(p)      ((p) & FRIBIDI_MASK_RTL)
253 /* Is arabic: AL, AN? */
254 #define FRIBIDI_IS_ARABIC(p)   ((p) & FRIBIDI_MASK_ARABIC)
255
256 /* Is strong? */
257 #define FRIBIDI_IS_STRONG(p)   ((p) & FRIBIDI_MASK_STRONG)
258 /* Is weak? */
259 #define FRIBIDI_IS_WEAK(p)     ((p) & FRIBIDI_MASK_WEAK)
260 /* Is neutral? */
261 #define FRIBIDI_IS_NEUTRAL(p)  ((p) & FRIBIDI_MASK_NEUTRAL)
262 /* Is sentinel? */
263 #define FRIBIDI_IS_SENTINEL(p) ((p) & FRIBIDI_MASK_SENTINEL)
264
265 /* Is letter: L, R, AL? */
266 #define FRIBIDI_IS_LETTER(p)   ((p) & FRIBIDI_MASK_LETTER)
267 /* Is number: EN, AN? */
268 #define FRIBIDI_IS_NUMBER(p)   ((p) & FRIBIDI_MASK_NUMBER)
269 /* Is number separator or terminator: ES, ET, CS? */
270 #define FRIBIDI_IS_NUMBER_SEPARATOR_OR_TERMINATOR(p) \
271         ((p) & FRIBIDI_MASK_NUMSEPTER)
272 /* Is space: BN, BS, SS, WS? */
273 #define FRIBIDI_IS_SPACE(p)    ((p) & FRIBIDI_MASK_SPACE)
274 /* Is explicit mark: LRE, RLE, LRO, RLO, PDF? */
275 #define FRIBIDI_IS_EXPLICIT(p) ((p) & FRIBIDI_MASK_EXPLICIT)
276
277 /* Is text separator: BS, SS? */
278 #define FRIBIDI_IS_SEPARATOR(p) ((p) & FRIBIDI_MASK_SEPARATOR)
279
280 /* Is explicit override: LRO, RLO? */
281 #define FRIBIDI_IS_OVERRIDE(p) ((p) & FRIBIDI_MASK_OVERRIDE)
282
283 /* Some more: */
284
285 /* Is left to right letter: LTR? */
286 #define FRIBIDI_IS_LTR_LETTER(p) \
287         ((p) & (FRIBIDI_MASK_LETTER | FRIBIDI_MASK_RTL) == FRIBIDI_MASK_LETTER)
288
289 /* Is right to left letter: RTL, AL? */
290 #define FRIBIDI_IS_RTL_LETTER(p) \
291         ((p) & (FRIBIDI_MASK_LETTER | FRIBIDI_MASK_RTL) \
292         == (FRIBIDI_MASK_LETTER | FRIBIDI_MASK_RTL))
293
294 /* Is ES or CS: ES, CS? */
295 #define FRIBIDI_IS_ES_OR_CS(p) \
296         ((p) & (FRIBIDI_MASK_ES | FRIBIDI_MASK_CS))
297
298 /* Is explicit or BN: LRE, RLE, LRO, RLO, PDF, BN? */
299 #define FRIBIDI_IS_EXPLICIT_OR_BN(p) \
300         ((p) & (FRIBIDI_MASK_EXPLICIT | FRIBIDI_MASK_BN))
301
302 /* Is explicit or BN or NSM: LRE, RLE, LRO, RLO, PDF, BN, NSM? */
303 #define FRIBIDI_IS_EXPLICIT_OR_BN_OR_NSM(p) \
304         ((p) & (FRIBIDI_MASK_EXPLICIT | FRIBIDI_MASK_BN | FRIBIDI_MASK_NSM))
305
306 /* Is explicit or BN or WS: LRE, RLE, LRO, RLO, PDF, BN, WS? */
307 #define FRIBIDI_IS_EXPLICIT_OR_BN_OR_WS(p) \
308         ((p) & (FRIBIDI_MASK_EXPLICIT | FRIBIDI_MASK_BN | FRIBIDI_MASK_WS))
309
310 /* Is explicit or separator or BN or WS: LRE, RLE, LRO, RLO, PDF, BS, SS, BN, WS? */
311 #define FRIBIDI_IS_EXPLICIT_OR_SEPARATOR_OR_BN_OR_WS(p) \
312         ((p) & (FRIBIDI_MASK_EXPLICIT | FRIBIDI_MASK_SEPARATOR \
313                 | FRIBIDI_MASK_BN | FRIBIDI_MASK_WS))
314
315 /* Is private-use type for application? */
316 #define FRIBIDI_IS_PRIVATE(p) ((p) & FRIBIDI_MASK_PRIVATE)
317
318 /* Define some conversions. */
319
320 /* Change numbers to RTL: EN,AN -> RTL. */
321 #define FRIBIDI_CHANGE_NUMBER_TO_RTL(p) \
322         (FRIBIDI_IS_NUMBER(p) ? FRIBIDI_TYPE_RTL : (p))
323
324 /* Override status of an explicit mark:
325  * LRO,LRE->LTR, RLO,RLE->RTL, otherwise->ON. */
326 #define FRIBIDI_EXPLICIT_TO_OVERRIDE_DIR(p) \
327         (FRIBIDI_IS_OVERRIDE(p) ? FRIBIDI_LEVEL_TO_DIR(FRIBIDI_DIR_TO_LEVEL(p)) \
328                                 : FRIBIDI_TYPE_ON)
329
330 /* Weaken type for paragraph fallback purposes:
331  * LTR->WLTR, RTL->WRTL. */
332 #define FRIBIDI_WEAK_PARAGRAPH(p) (FRIBIDI_PAR_WLTR | ((p) & FRIBIDI_MASK_RTL))
333
334
335 /* Functions finally */
336
337
338 #define fribidi_get_bidi_type FRIBIDI_NAMESPACE(get_bidi_type)
339 /* fribidi_get_bidi_type - get character bidi type
340  *
341  * This function returns the bidi type of a character as defined in Table 3.7
342  * Bidirectional Character Types of the Unicode Bidirectional Algorithm
343  * available at
344  * http://www.unicode.org/reports/tr9/#Bidirectional_Character_Types, using
345  * data provided in file UnicodeData.txt of the Unicode Character Database
346  * available at http://www.unicode.org/Public/UNIDATA/UnicodeData.txt.
347  *
348  * There are a few macros defined in fribidi-bidi-types.h for querying a bidi
349  * type.
350  */
351 FriBidiCharType
352 fribidi_get_bidi_type (
353   FriBidiChar ch                /* input character */
354 ) FRIBIDI_GNUC_CONST;
355
356 #define fribidi_get_bidi_types FRIBIDI_NAMESPACE(get_bidi_types)
357 /* fribidi_get_bidi_types - get bidi types for an string of characters
358  *
359  * This function finds the bidi types of an string of characters.  See
360  * fribidi_get_bidi_type() for more information about the bidi types returned
361  * by this function.
362  */
363      void fribidi_get_bidi_types (
364   const FriBidiChar *str,       /* input string */
365   const FriBidiStrIndex len,    /* input string length */
366   FriBidiCharType *btypes       /* output bidi types */
367 );
368
369 #define fribidi_get_bidi_type_name FRIBIDI_NAMESPACE(get_bidi_type_name)
370 /* fribidi_get_bidi_type_name - get bidi type name
371  *
372  * This function returns the bidi type name of a character type.  The
373  * returned string is a static string and should not be freed.
374  *
375  * The type names are the same as ones defined in Table 3.7 Bidirectional
376  * Character Types of the Unicode Bidirectional Algorithm available at
377  * http://www.unicode.org/reports/tr9/#Bidirectional_Character_Types, with a
378  * few modifications: L->LTR, R->RTL, B->BS, S->SS.
379  */
380      const char *fribidi_get_bidi_type_name (
381   FriBidiCharType t             /* input bidi type */
382 ) FRIBIDI_GNUC_CONST;
383
384 #include "fribidi-enddecls.h"
385
386 #endif /* !_FRIBIDI_BIDI_TYPES_H */
387 /* Editor directions:
388  * vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent
389  */