Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:57:27

0001 /* FriBidi
0002  * fribidi-joining-types.h - character joining types
0003  *
0004  * Author:
0005  *   Behdad Esfahbod, 2001, 2002, 2004
0006  *
0007  * Copyright (C) 2004 Sharif FarsiWeb, Inc.
0008  * Copyright (C) 2001,2002 Behdad Esfahbod
0009  * 
0010  * This library is free software; you can redistribute it and/or
0011  * modify it under the terms of the GNU Lesser General Public
0012  * License as published by the Free Software Foundation; either
0013  * version 2.1 of the License, or (at your option) any later version.
0014  * 
0015  * This library is distributed in the hope that it will be useful,
0016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
0017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
0018  * Lesser General Public License for more details.
0019  * 
0020  * You should have received a copy of the GNU Lesser General Public License
0021  * along with this library, in a file named COPYING; if not, write to the
0022  * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
0023  * Boston, MA 02110-1301, USA
0024  *
0025  * For licensing issues, contact <fribidi.license@gmail.com>.
0026  */
0027 #ifndef _FRIBIDI_JOINING_TYPES_H
0028 #define _FRIBIDI_JOINING_TYPES_H
0029 
0030 #include "fribidi-common.h"
0031 
0032 #include "fribidi-types.h"
0033 
0034 #include "fribidi-begindecls.h"
0035 
0036 /* 
0037  * Define bit masks that joining types are based on, each mask has
0038  * only one bit set.
0039  */
0040 
0041 #define FRIBIDI_MASK_JOINS_RIGHT    0x01    /* May join to right */
0042 #define FRIBIDI_MASK_JOINS_LEFT     0x02    /* May join to right */
0043 #define FRIBIDI_MASK_ARAB_SHAPES    0x04    /* May Arabic shape */
0044 #define FRIBIDI_MASK_TRANSPARENT    0x08    /* Is transparent */
0045 #define FRIBIDI_MASK_IGNORED        0x10    /* Is ignored */
0046 #define FRIBIDI_MASK_LIGATURED      0x20    /* Is ligatured */
0047 
0048 /*
0049  * Define values for FriBidiJoiningType
0050  */
0051 
0052 /* nUn-joining */
0053 #define FRIBIDI_JOINING_TYPE_U_VAL  ( 0 )
0054 
0055 /* Right-joining */
0056 #define FRIBIDI_JOINING_TYPE_R_VAL  \
0057     ( FRIBIDI_MASK_JOINS_RIGHT | FRIBIDI_MASK_ARAB_SHAPES )
0058 
0059 /* Dual-joining */
0060 #define FRIBIDI_JOINING_TYPE_D_VAL  \
0061     ( FRIBIDI_MASK_JOINS_RIGHT | FRIBIDI_MASK_JOINS_LEFT \
0062     | FRIBIDI_MASK_ARAB_SHAPES )
0063 
0064 /* join-Causing */
0065 #define FRIBIDI_JOINING_TYPE_C_VAL  \
0066     ( FRIBIDI_MASK_JOINS_RIGHT | FRIBIDI_MASK_JOINS_LEFT )
0067 
0068 /* Left-joining */
0069 #define FRIBIDI_JOINING_TYPE_L_VAL  \
0070     ( FRIBIDI_MASK_JOINS_LEFT | FRIBIDI_MASK_ARAB_SHAPES )
0071 
0072 /* Transparent */
0073 #define FRIBIDI_JOINING_TYPE_T_VAL  \
0074     ( FRIBIDI_MASK_TRANSPARENT | FRIBIDI_MASK_ARAB_SHAPES )
0075 
0076 /* iGnored */
0077 #define FRIBIDI_JOINING_TYPE_G_VAL  ( FRIBIDI_MASK_IGNORED )
0078 
0079 
0080 enum _FriBidiJoiningTypeEnum
0081 {
0082 # define _FRIBIDI_ADD_TYPE(TYPE,SYMBOL) \
0083     FRIBIDI_JOINING_TYPE_##TYPE = FRIBIDI_JOINING_TYPE_##TYPE##_VAL,
0084 # include "fribidi-joining-types-list.h"
0085 # undef _FRIBIDI_ADD_TYPE
0086   _FRIBIDI_JOINING_TYPE_JUNK    /* Don't use this */
0087 };
0088 
0089 #ifdef __FRIBIDI_DOC
0090 typedef enum _FriBidiJoiningTypeEnum FriBidiJoiningType;
0091 #else /* !__FRIBIDI_DOC */
0092 typedef uint8_t FriBidiJoiningType;
0093 #endif /* !__FRIBIDI_DOC */
0094 
0095 /* FriBidiArabicProp is essentially the same type as FriBidiJoiningType, but
0096  * not limited to the few values returned by fribidi_get_joining_type. */
0097 typedef uint8_t FriBidiArabicProp;
0098 
0099 /*
0100  * The equivalent of JoiningType values for ArabicProp
0101  */
0102 
0103 /* Primary Arabic Joining Classes (Table 8-2) */
0104 
0105 /* nUn-joining */
0106 #define FRIBIDI_IS_JOINING_TYPE_U(p)    \
0107     ( 0 == ( (p) &  \
0108         ( FRIBIDI_MASK_TRANSPARENT | FRIBIDI_MASK_IGNORED   \
0109         | FRIBIDI_MASK_JOINS_RIGHT | FRIBIDI_MASK_JOINS_LEFT ) ) )
0110 
0111 /* Right-joining */
0112 #define FRIBIDI_IS_JOINING_TYPE_R(p)    \
0113     ( FRIBIDI_MASK_JOINS_RIGHT == ( (p) &   \
0114         ( FRIBIDI_MASK_TRANSPARENT | FRIBIDI_MASK_IGNORED   \
0115         | FRIBIDI_MASK_JOINS_RIGHT | FRIBIDI_MASK_JOINS_LEFT ) ) )
0116 
0117 /* Dual-joining */
0118 #define FRIBIDI_IS_JOINING_TYPE_D(p)    \
0119     ( ( FRIBIDI_MASK_JOINS_RIGHT | FRIBIDI_MASK_JOINS_LEFT  \
0120       | FRIBIDI_MASK_ARAB_SHAPES ) == ( (p) &   \
0121         ( FRIBIDI_MASK_TRANSPARENT | FRIBIDI_MASK_IGNORED   \
0122         | FRIBIDI_MASK_JOINS_RIGHT | FRIBIDI_MASK_JOINS_LEFT    \
0123         | FRIBIDI_MASK_ARAB_SHAPES ) ) )
0124 
0125 /* join-Causing */
0126 #define FRIBIDI_IS_JOINING_TYPE_C(p)    \
0127     ( ( FRIBIDI_MASK_JOINS_RIGHT | FRIBIDI_MASK_JOINS_LEFT ) == ( (p) & \
0128         ( FRIBIDI_MASK_TRANSPARENT | FRIBIDI_MASK_IGNORED   \
0129         | FRIBIDI_MASK_JOINS_RIGHT | FRIBIDI_MASK_JOINS_LEFT    \
0130         | FRIBIDI_MASK_ARAB_SHAPES ) ) )
0131 
0132 /* Left-joining */
0133 #define FRIBIDI_IS_JOINING_TYPE_L(p)    \
0134     ( FRIBIDI_MASK_JOINS_LEFT == ( (p) &    \
0135         ( FRIBIDI_MASK_TRANSPARENT | FRIBIDI_MASK_IGNORED   \
0136         | FRIBIDI_MASK_JOINS_RIGHT | FRIBIDI_MASK_JOINS_LEFT ) ) )
0137 
0138 /* Transparent */
0139 #define FRIBIDI_IS_JOINING_TYPE_T(p)    \
0140     ( FRIBIDI_MASK_TRANSPARENT == ( (p) &   \
0141         ( FRIBIDI_MASK_TRANSPARENT | FRIBIDI_MASK_IGNORED ) ) )
0142 
0143 /* iGnored */
0144 #define FRIBIDI_IS_JOINING_TYPE_G(p)    \
0145     ( FRIBIDI_MASK_IGNORED == ( (p) &   \
0146         ( FRIBIDI_MASK_TRANSPARENT | FRIBIDI_MASK_IGNORED ) ) )
0147 
0148 /* and for Derived Arabic Joining Classes (Table 8-3) */
0149 
0150 /* Right join-Causing */
0151 #define FRIBIDI_IS_JOINING_TYPE_RC(p)   \
0152     ( FRIBIDI_MASK_JOINS_RIGHT == ( (p) &   \
0153         ( FRIBIDI_MASK_TRANSPARENT | FRIBIDI_MASK_IGNORED   \
0154         | FRIBIDI_MASK_JOINS_RIGHT ) ) )
0155 
0156 /* Left join-Causing */
0157 #define FRIBIDI_IS_JOINING_TYPE_LC(p)   \
0158     ( FRIBIDI_MASK_JOINS_LEFT == ( (p) &    \
0159         ( FRIBIDI_MASK_TRANSPARENT | FRIBIDI_MASK_IGNORED   \
0160         | FRIBIDI_MASK_JOINS_LEFT ) ) )
0161 
0162 
0163 /*
0164  * Defining macros for needed queries, It is fully dependent on the 
0165  * implementation of FriBidiJoiningType.
0166  */
0167 
0168 /* Joins to right: R, D, C? */
0169 #define FRIBIDI_JOINS_RIGHT(p)  ((p) & FRIBIDI_MASK_JOINS_RIGHT)
0170 
0171 /* Joins to left: L, D, C? */
0172 #define FRIBIDI_JOINS_LEFT(p)   ((p) & FRIBIDI_MASK_JOINS_LEFT)
0173 
0174 /* May shape: R, D, L, T? */
0175 #define FRIBIDI_ARAB_SHAPES(p)  ((p) & FRIBIDI_MASK_ARAB_SHAPES)
0176 
0177 /* Is skipped in joining: T, G? */
0178 #define FRIBIDI_IS_JOIN_SKIPPED(p)  \
0179     ((p) & (FRIBIDI_MASK_TRANSPARENT | FRIBIDI_MASK_IGNORED))
0180 
0181 /* Is base that will be shaped: R, D, L? */
0182 #define FRIBIDI_IS_JOIN_BASE_SHAPES(p)  \
0183     ( FRIBIDI_MASK_ARAB_SHAPES == ( (p) &   \
0184         ( FRIBIDI_MASK_TRANSPARENT | FRIBIDI_MASK_IGNORED   \
0185         | FRIBIDI_MASK_ARAB_SHAPES ) ) )
0186 
0187 #define FRIBIDI_JOINS_PRECEDING_MASK(level) \
0188     (FRIBIDI_LEVEL_IS_RTL (level) ? FRIBIDI_MASK_JOINS_RIGHT    \
0189                       : FRIBIDI_MASK_JOINS_LEFT)
0190 
0191 #define FRIBIDI_JOINS_FOLLOWING_MASK(level) \
0192     (FRIBIDI_LEVEL_IS_RTL (level) ? FRIBIDI_MASK_JOINS_LEFT \
0193                       : FRIBIDI_MASK_JOINS_RIGHT)
0194 
0195 #define FRIBIDI_JOIN_SHAPE(p)   \
0196     ((p) & ( FRIBIDI_MASK_JOINS_RIGHT | FRIBIDI_MASK_JOINS_LEFT ))
0197 
0198 /* Functions finally */
0199 
0200 
0201 /* fribidi_get_joining_type - get character joining type
0202  *
0203  * This function returns the joining type of a character as defined in Table
0204  * 8-2 Primary Arabic Joining Classes of the Unicode standard available at
0205  * http://www.unicode.org/versions/Unicode4.0.0/ch08.pdf#G7462, using data
0206  * provided in file ArabicShaping.txt and UnicodeData.txt of the Unicode
0207  * Character Database available at
0208  * http://www.unicode.org/Public/UNIDATA/ArabicShaping.txt and
0209  * http://www.unicode.org/Public/UNIDATA/UnicodeData.txt. 
0210  *
0211  * There are a few macros defined in fribidi-joining-types.h for querying a
0212  * joining type.
0213  */
0214 FRIBIDI_ENTRY FriBidiJoiningType
0215 fribidi_get_joining_type (
0216   FriBidiChar ch        /* input character */
0217 ) FRIBIDI_GNUC_CONST;
0218 
0219 /* fribidi_get_joining_types - get joining types for an string of characters
0220  *
0221  * This function finds the joining types of an string of characters.  See
0222  * fribidi_get_joining_type for more information about the joining types
0223  * returned by this function.
0224  */
0225 FRIBIDI_ENTRY void fribidi_get_joining_types (
0226   const FriBidiChar *str,   /* input string */
0227   const FriBidiStrIndex len,    /* input string length */
0228   FriBidiJoiningType *jtypes    /* output joining types */
0229 );
0230 
0231 /* fribidi_get_joining_type_name - get joining type name
0232  *
0233  * This function returns the joining type name of a joining type.  The
0234  * returned string is a static string and should not be freed.
0235  *
0236  * The type names are the same as ones defined in Table 8-2  Primary Arabic
0237  * Joining Classes of the Unicode standard available at
0238  * http://www.unicode.org/versions/Unicode4.0.0/ch08.pdf#G7462.
0239  */
0240 FRIBIDI_ENTRY const char *fribidi_get_joining_type_name (
0241   FriBidiJoiningType j      /* input joining type */
0242 ) FRIBIDI_GNUC_CONST;
0243 
0244 #include "fribidi-enddecls.h"
0245 
0246 #endif /* !_FRIBIDI_JOINING_TYPES_H */
0247 /* Editor directions:
0248  * vim:textwidth=78:tabstop=8:shiftwidth=2:autoindent:cindent
0249  */