/* FriBidi
* bidi-types.h - define internal bidi types
*
- * $Id: bidi-types.h,v 1.5 2004-06-14 17:00:33 behdad Exp $
+ * $Id: bidi-types.h,v 1.6 2004-06-21 18:49:23 behdad Exp $
* $Author: behdad $
- * $Date: 2004-06-14 17:00:33 $
- * $Revision: 1.5 $
+ * $Date: 2004-06-21 18:49:23 $
+ * $Revision: 1.6 $
* $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/bidi-types.h,v $
*
* Author:
#endif /* DEBUG */
-#define BIDI_TYPE(i) (bidi_types ? bidi_types[(i)] : fribidi_get_bidi_type(str[(i)]))
-
#include <fribidi-enddecls.h>
#endif /* !_BIDI_TYPES_H */
/* FriBidi
* common.h - common include for library sources
*
- * $Id: common.h,v 1.14 2004-06-15 11:52:02 behdad Exp $
+ * $Id: common.h,v 1.15 2004-06-21 18:49:23 behdad Exp $
* $Author: behdad $
- * $Date: 2004-06-15 11:52:02 $
- * $Revision: 1.14 $
+ * $Date: 2004-06-21 18:49:23 $
+ * $Revision: 1.15 $
* $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/common.h,v $
*
* Author:
# define _GNU_SOURCE
#endif /* !_GNU_SOURCE */
+/* We respect our own rules. */
+#define FRIBIDI_STRICT 1
+#undef FRIBIDI_COMPAT
+
+
#include "debug.h"
#endif /* !_COMMON_H */
/* FriBidi
* fribidi-bidi-types.h - character bidi types
*
- * $Id: fribidi-bidi-types.h,v 1.12 2004-06-18 19:21:33 behdad Exp $
+ * $Id: fribidi-bidi-types.h,v 1.13 2004-06-21 18:49:23 behdad Exp $
* $Author: behdad $
- * $Date: 2004-06-18 19:21:33 $
- * $Revision: 1.12 $
+ * $Date: 2004-06-21 18:49:23 $
+ * $Revision: 1.13 $
* $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/fribidi-bidi-types.h,v $
*
* Author:
#endif
-/* For lazy people... */
+/* Please don't use these two type names, use FRIBIDI_PAR_* form instead. */
#define FRIBIDI_TYPE_WLTR FRIBIDI_PAR_WLTR
-#define FRIBIDI_TYPE_WL FRIBIDI_PAR_WLTR
#define FRIBIDI_TYPE_WRTL FRIBIDI_PAR_WRTL
+
+/* These are here just for lazy people. */
+#if !FRIBIDI_STRICT
+#define FRIBIDI_TYPE_WL FRIBIDI_PAR_WLTR
#define FRIBIDI_TYPE_WR FRIBIDI_PAR_WRTL
#define FRIBIDI_TYPE_L FRIBIDI_PAR_LTR
#define FRIBIDI_TYPE_R FRIBIDI_PAR_RTL
#define FRIBIDI_TYPE_N FRIBIDI_PAR_ON
#define FRIBIDI_TYPE_B FRIBIDI_TYPE_BS
#define FRIBIDI_TYPE_S FRIBIDI_TYPE_SS
+#endif /* !FRIBIDI_STRICT */
/*
/* FriBidi
* fribidi-bidi.c - bidirectional algorithm
*
- * $Id: fribidi-bidi.c,v 1.16 2004-06-21 16:15:27 behdad Exp $
+ * $Id: fribidi-bidi.c,v 1.17 2004-06-21 18:49:23 behdad Exp $
* $Author: behdad $
- * $Date: 2004-06-21 16:15:27 $
- * $Revision: 1.16 $
+ * $Date: 2004-06-21 18:49:23 $
+ * $Revision: 1.17 $
* $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/fribidi-bidi.c,v $
*
* Authors:
static void
print_bidi_string (
/* input */
- const FriBidiChar *str,
- const FriBidiStrIndex len,
- const FriBidiCharType *bidi_types
+ const FriBidiCharType *bidi_types,
+ const FriBidiStrIndex len
)
{
register FriBidiStrIndex i;
- fribidi_assert (str || bidi_types);
+ fribidi_assert (bidi_types);
MSG (" Org. types : ");
for (i = 0; i < len; i++)
- MSG2 ("%c", fribidi_char_from_bidi_type (BIDI_TYPE (i)));
+ MSG2 ("%c", fribidi_char_from_bidi_type (bidi_types[i]));
MSG ("\n");
}
#endif /* DEBUG */
FRIBIDI_ENTRY FriBidiParType
fribidi_get_par_direction (
/* input */
- const FriBidiChar *str,
- const FriBidiStrIndex len,
- const FriBidiCharType *bidi_types
+ const FriBidiCharType *bidi_types,
+ const FriBidiStrIndex len
)
{
register FriBidiStrIndex i;
- fribidi_assert (str || bidi_types);
+ fribidi_assert (bidi_types);
for (i = 0; i < len; i++)
- if (FRIBIDI_IS_LETTER (BIDI_TYPE (i)))
- return FRIBIDI_IS_RTL (BIDI_TYPE (i)) ? FRIBIDI_PAR_RTL :
+ if (FRIBIDI_IS_LETTER (bidi_types[i]))
+ return FRIBIDI_IS_RTL (bidi_types[i]) ? FRIBIDI_PAR_RTL :
FRIBIDI_PAR_LTR;
return FRIBIDI_PAR_ON;
FRIBIDI_ENTRY FriBidiLevel
fribidi_get_par_embedding_levels (
/* input */
- const FriBidiChar *str,
- const FriBidiStrIndex len,
const FriBidiCharType *bidi_types,
+ const FriBidiStrIndex len,
/* input and output */
FriBidiParType *pbase_dir,
/* output */
goto out;
}
- DBG ("entering fribidi_get_par_embedding_levels");
+ DBG ("in fribidi_get_par_embedding_levels");
- fribidi_assert (str || bidi_types);
+ fribidi_assert (bidi_types);
fribidi_assert (pbase_dir);
fribidi_assert (embedding_levels);
/* Determinate character types */
{
/* Get run-length encoded character types */
- main_run_list = run_list_encode_bidi_types (str, len, bidi_types);
+ main_run_list = run_list_encode_bidi_types (bidi_types, len);
if UNLIKELY
(!main_run_list) goto out;
}
(fribidi_debug_status ())
{
print_types_re (main_run_list);
- print_bidi_string (str, len, bidi_types);
+ print_bidi_string (bidi_types, len);
print_resolved_levels (main_run_list);
print_resolved_types (main_run_list);
}
if UNLIKELY
(fribidi_debug_status ())
{
- print_bidi_string (str, len, bidi_types);
+ print_bidi_string (bidi_types, len);
print_resolved_levels (main_run_list);
print_resolved_types (main_run_list);
}
{
/* close up the open link at the end */
if (j >= 0)
- char_type = BIDI_TYPE (j);
+ char_type = bidi_types[j];
else
char_type = FRIBIDI_TYPE_ON;
if (!state && FRIBIDI_IS_SEPARATOR (char_type))
FRIBIDI_ENTRY FriBidiLevel
fribidi_reorder_line (
- const FriBidiChar *str,
/* input */
+ const FriBidiCharType *bidi_types,
const FriBidiStrIndex len,
const FriBidiStrIndex off,
- const FriBidiCharType *bidi_types,
const FriBidiParType base_dir,
/* input and output */
FriBidiLevel *embedding_levels,
DBG ("in fribidi_reorder_line");
- fribidi_assert (str || visual_str || bidi_types);
+ fribidi_assert (bidi_types);
fribidi_assert (embedding_levels);
- if (!str)
- str = visual_str;
-
DBG ("reset the embedding levels, 4. whitespace at the end of line");
{
register FriBidiStrIndex i;
/* L1. Reset the embedding levels of some chars:
4. any sequence of white space characters at the end of the line. */
for (i = off + len - 1; i >= off &&
- FRIBIDI_IS_EXPLICIT_OR_BN_OR_WS (BIDI_TYPE (i)); i--)
+ FRIBIDI_IS_EXPLICIT_OR_BN_OR_WS (bidi_types[i]); i--)
embedding_levels[i] = FRIBIDI_DIR_TO_LEVEL (base_dir);
}
/* L3. Reorder NSMs. */
for (i = off + len - 1; i >= off; i--)
if (FRIBIDI_LEVEL_IS_RTL (embedding_levels[i])
- && BIDI_TYPE (i) == FRIBIDI_TYPE_NSM)
+ && bidi_types[i] == FRIBIDI_TYPE_NSM)
{
register FriBidiStrIndex seq_end = i;
level = embedding_levels[i];
for (i--; i >= off &&
- FRIBIDI_IS_EXPLICIT_OR_BN_OR_NSM (BIDI_TYPE (i))
+ FRIBIDI_IS_EXPLICIT_OR_BN_OR_NSM (bidi_types[i])
&& embedding_levels[i] == level; i--)
;
/* FriBidi
* fribidi-bidi.h - bidirectional algorithm
*
- * $Id: fribidi-bidi.h,v 1.12 2004-06-21 16:15:27 behdad Exp $
+ * $Id: fribidi-bidi.h,v 1.13 2004-06-21 18:49:23 behdad Exp $
* $Author: behdad $
- * $Date: 2004-06-21 16:15:27 $
- * $Revision: 1.12 $
+ * $Date: 2004-06-21 18:49:23 $
+ * $Revision: 1.13 $
* $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/fribidi-bidi.h,v $
*
* Authors:
* as defined by rule P2 of the Unicode Bidirectional Algorithm available at
* http://www.unicode.org/reports/tr9/#P2.
*
- * You can provide either the string, or the bidi types; or both.
- * If bidi_types are provided, they are used as the bidi types of characters
- * in the string, otherwise the types are computed from the characters in str.
- * Providing bidi types if available at your side, saves you a few cycles.
- * Bidi types can be obtained by calling fribidi_get_bidi_types().
- *
* You typically do not need this function as
* fribidi_get_par_embedding_levels() knows how to compute base direction
* itself, but you may need this to implement a more sophisticated paragraph
* only LTR, RTL, or ON.
*/
FRIBIDI_ENTRY FriBidiParType fribidi_get_par_direction (
- const FriBidiChar *str, /* input paragraph string */
- const FriBidiStrIndex len, /* input string length */
- const FriBidiCharType *bidi_types /* input bidi types */
+ const FriBidiCharType *bidi_types, /* input bidi types */
+ const FriBidiStrIndex len /* input string length */
);
#define fribidi_get_par_embedding_levels FRIBIDI_NAMESPACE(get_par_embedding_levels)
* implemented in fribidi_remove_bidi_marks(). Part 4 of L1 is implemented
* in fribidi_reorder_line().
*
- * You can provide either the string, or the bidi types; or both.
- * If bidi_types are provided, they are used as the bidi types of characters
- * in the string, otherwise the types are computed from the characters in str.
- * Providing bidi types if available at your side, saves you a few cycles.
- * Bidi types can be obtained by calling fribidi_get_bidi_types().
- *
* There are a few macros defined in fribidi-bidi-types.h to work with this
* embedding levels.
*
*/
FRIBIDI_ENTRY FriBidiLevel
fribidi_get_par_embedding_levels (
- const FriBidiChar *str, /* input paragraph string */
- const FriBidiStrIndex len, /* input string length of the paragraph */
const FriBidiCharType *bidi_types, /* input bidi types */
+ const FriBidiStrIndex len, /* input string length of the paragraph */
FriBidiParType *pbase_dir, /* requested and resolved paragraph
* base direction */
FriBidiLevel *embedding_levels /* output list of embedding levels */
*
* As a side effect it also sets position maps if not NULL.
*
- * You can provide either the string str, or the bidi types; or both. If
- * bidi_types are provided, they are used as the bidi types of characters in
- * the string, otherwise the types are computed from the characters in str.
- * If neither str nor bidi types are provided, visual_str is used instead.
- * Feel free to pass the same string as both str and visual_str, but if you
- * done extensive complicated shaping in visual_str, you better provide
- * logical string as str. There is no known differences yet between providing
- * logical or visual string as str.
- *
- * If you have obtained the embedding levels using custom bidi types, you
- * should provide the same types to this function for valid resutls.
- * Providing bidi types if available at your side, saves you a few cycles, and
- * you don't need to provide str anymore.
- *
* You should provide the resolved paragraph direction and embedding levels as
* set by fribidi_get_par_embedding_levels(). Also note that the embedding
* levels may change a bit. To be exact, the embedding level of any sequence
* occured (memory allocation failure most probably).
*/
FRIBIDI_ENTRY FriBidiLevel fribidi_reorder_line (
- const FriBidiChar *str, /* input string */
+ const FriBidiCharType *bidi_types, /* input bidi types */
const FriBidiStrIndex len, /* input length of the line */
const FriBidiStrIndex off, /* input offset of the beginning of the line
in the paragraph */
- const FriBidiCharType *bidi_types, /* input bidi types */
const FriBidiParType base_dir, /* resolved paragraph base direction */
FriBidiLevel *embedding_levels, /* list of embedding levels,
as returned by
/* FriBidi
* fribidi-joining.h - Arabic joining algorithm
*
- * $Id: fribidi-joining.c,v 1.2 2004-06-15 11:52:02 behdad Exp $
+ * $Id: fribidi-joining.c,v 1.3 2004-06-21 18:49:23 behdad Exp $
* $Author: behdad $
- * $Date: 2004-06-15 11:52:02 $
- * $Revision: 1.2 $
+ * $Date: 2004-06-21 18:49:23 $
+ * $Revision: 1.3 $
* $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/fribidi-joining.c,v $
*
* Authors:
#endif /* DEBUG */
+#if FRIBIDI_JOIN_WITHIN_RUN_LEVEL
+/* Join within same level run (to be proposed for inclusion in Unicode 4.1) */
+# define FRIBIDI_JOINING_RUN(l) (l)
+#else /* !FRIBIDI_JOIN_WITHIN_RUN_LEVEL */
+/* Join within same directional run (current rule in Unicode 4.0.1) */
+# define FRIBIDI_JOINING_RUN(l) FRIBIDI_LEVEL_IS_RTL(l)
+#endif /* !FRIBIDI_JOIN_WITHIN_RUN_LEVEL */
+
+
FRIBIDI_ENTRY void
fribidi_join_arabic (
/* input */
if UNLIKELY
(len == 0) return;
- DBG ("entering fribidi_join_arabic");
+ DBG ("in fribidi_join_arabic");
fribidi_assert (embedding_levels);
fribidi_assert (ar_props);
/* FriBidi
* fribidi-run.c - text run data type
*
- * $Id: fribidi-run.c,v 1.5 2004-06-14 18:43:53 behdad Exp $
+ * $Id: fribidi-run.c,v 1.6 2004-06-21 18:49:23 behdad Exp $
* $Author: behdad $
- * $Date: 2004-06-14 18:43:53 $
- * $Revision: 1.5 $
+ * $Date: 2004-06-21 18:49:23 $
+ * $Revision: 1.6 $
* $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/fribidi-run.c,v $
*
* Authors:
FriBidiRun *
run_list_encode_bidi_types (
/* input */
- const FriBidiChar *str,
- const FriBidiStrIndex len,
- const FriBidiCharType *bidi_types
+ const FriBidiCharType *bidi_types,
+ const FriBidiStrIndex len
)
{
FriBidiRun *list, *last;
register FriBidiRun *run = NULL;
FriBidiStrIndex i;
- fribidi_assert (str || bidi_types);
+ fribidi_assert (bidi_types);
/* Create the list sentinel */
list = new_run_list ();
/* Scan over the character types */
for (i = 0; i < len; i++)
{
- register FriBidiCharType char_type = BIDI_TYPE (i);
+ register FriBidiCharType char_type = bidi_types[i];
if (char_type != last->type)
{
run = new_run ();
/* FriBidi
* fribidi-unicode.h - general Unicode definitions
*
- * $Id: fribidi-unicode.h,v 1.3 2004-05-12 08:17:19 behdad Exp $
+ * $Id: fribidi-unicode.h,v 1.4 2004-06-21 18:49:23 behdad Exp $
* $Author: behdad $
- * $Date: 2004-05-12 08:17:19 $
- * $Revision: 1.3 $
+ * $Date: 2004-06-21 18:49:23 $
+ * $Revision: 1.4 $
* $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/fribidi-unicode.h,v $
*
* Author:
extern const char *fribidi_unicode_version;
-/* The Unicode Bidirectional Algorithm constants */
+/* Unicode Bidirectional Algorithm definitions: */
/* Number of types defined in the bidi algorithm */
#define FRIBIDI_BIDI_NUM_TYPES 19
#define FRIBIDI_BIDI_MAX_RESOLVED_LEVELS 63
+/* Unicode Arabic joining/shaping definitions: */
+
+/* Unicode 4.0.1: join within "directional run", not "level run". */
+#undef FRIBIDI_JOIN_WITHIN_RUN_LEVEL
+
+
/* A few Unicode characters */
/* Bidirectional marks */
#define FRIBIDI_CHAR_ARABIC_ZERO 0x0660
#define FRIBIDI_CHAR_PERSIAN_ZERO 0x06F0
-/* These are here just for compatibility. */
+/* These are here just for lazy people. */
+#if !FRIBIDI_STRICT
#define UNI_MAX_BIDI_LEVEL FRIBIDI_BIDI_MAX_EXPLICIT_LEVEL
#define UNI_LRM FRIBIDI_CHAR_LRM
#define UNI_RLM FRIBIDI_CHAR_RLM
#define UNI_ARABIC_ALEF FRIBIDI_CHAR_ARABIC_ALEF
#define UNI_ARABIC_ZERO FRIBIDI_CHAR_ARABIC_ZERO
#define UNI_FARSI_ZERO FRIBIDI_CHAR_PERSIAN_ZERO
+#endif /* !FRIBIDI_STRICT */
#include "fribidi-enddecls.h"
/* FriBidi
* fribidi.c - Unicode bidirectional and Arabic joining/shaping algorithms
*
- * $Id: fribidi.c,v 1.13 2004-06-21 16:15:27 behdad Exp $
+ * $Id: fribidi.c,v 1.14 2004-06-21 18:49:23 behdad Exp $
* $Author: behdad $
- * $Date: 2004-06-21 16:15:27 $
- * $Revision: 1.13 $
+ * $Date: 2004-06-21 18:49:23 $
+ * $Revision: 1.14 $
* $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/fribidi.c,v $
*
* Authors:
fribidi_boolean private_embedding_levels = false;
fribidi_boolean status = false;
FriBidiArabicProps *ar_props = NULL;
+ FriBidiCharType *bidi_types = NULL;
if UNLIKELY
(len == 0)
fribidi_assert (str);
fribidi_assert (pbase_dir);
+ bidi_types = fribidi_malloc (len * sizeof bidi_types[0]);
+ if (!bidi_types)
+ goto out;
+
+ fribidi_get_bidi_types (str, len, bidi_types);
+
if (!embedding_levels)
{
embedding_levels = fribidi_malloc (len * sizeof embedding_levels[0]);
private_embedding_levels = true;
}
- max_level = fribidi_get_par_embedding_levels (str, len, NULL, pbase_dir,
+ max_level = fribidi_get_par_embedding_levels (bidi_types, len, pbase_dir,
embedding_levels) - 1;
if UNLIKELY
(max_level < 0) goto out;
}
status =
- fribidi_reorder_line (str, len, 0, NULL, *pbase_dir,
+ fribidi_reorder_line (bidi_types, len, 0, *pbase_dir,
embedding_levels, visual_str,
positions_L_to_V, positions_V_to_L);
if (ar_props)
fribidi_free (ar_props);
+ if (bidi_types)
+ fribidi_free (bidi_types);
+
return status ? max_level + 1 : 0;
}
/* FriBidi
* run.h - text run data type
*
- * $Id: run.h,v 1.6 2004-06-14 17:00:33 behdad Exp $
+ * $Id: run.h,v 1.7 2004-06-21 18:49:23 behdad Exp $
* $Author: behdad $
- * $Date: 2004-06-14 17:00:33 $
- * $Revision: 1.6 $
+ * $Date: 2004-06-21 18:49:23 $
+ * $Revision: 1.7 $
* $Source: /home/behdad/src/fdo/fribidi/togit/git/../fribidi/fribidi2/lib/run.h,v $
*
* Authors:
#define run_list_encode_bidi_types FRIBIDI_PRIVATESPACE(run_list_encode_bidi_types)
FriBidiRun *run_list_encode_bidi_types (
- const FriBidiChar *str,
- const FriBidiStrIndex len,
- const FriBidiCharType *bidi_types
+ const FriBidiCharType *bidi_types,
+ const FriBidiStrIndex len
)
FRIBIDI_GNUC_HIDDEN FRIBIDI_GNUC_WARN_UNUSED;