[FriBidi-commit] fribidi/lib fribidi-bidi-types.h, 1.11,
1.12 fribidi-bidi.c, 1.13, 1.14 fribidi-bidi.h, 1.10,
1.11 fribidi-types.h, 1.7, 1.8 fribidi.c, 1.11, 1.12
Behdad Esfahbod
behdad at pdx.freedesktop.org
Fri Jun 18 12:21:35 PDT 2004
Update of /cvs/fribidi/fribidi/lib
In directory pdx:/tmp/cvs-serv19990/lib
Modified Files:
fribidi-bidi-types.h fribidi-bidi.c fribidi-bidi.h
fribidi-types.h fribidi.c
Log Message:
Fixed good catch by Mark Davis that rule L1 is partly done after line
breaking. Also calculate more reasonable levels for explicit marks and BN.
Index: fribidi-bidi-types.h
===================================================================
RCS file: /cvs/fribidi/fribidi/lib/fribidi-bidi-types.h,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- fribidi-bidi-types.h 15 Jun 2004 20:54:00 -0000 1.11
+++ fribidi-bidi-types.h 18 Jun 2004 19:21:33 -0000 1.12
@@ -306,11 +306,14 @@
#define FRIBIDI_IS_EXPLICIT_OR_BN(p) \
((p) & (FRIBIDI_MASK_EXPLICIT | FRIBIDI_MASK_BN))
-/* Is explicit or BN or NSM: LRE, RLE, LRO, RLO, PDF, BN, NSM?
- * This is a good approximation of being zero-width. */
+/* Is explicit or BN or NSM: LRE, RLE, LRO, RLO, PDF, BN, NSM? */
#define FRIBIDI_IS_EXPLICIT_OR_BN_OR_NSM(p) \
((p) & (FRIBIDI_MASK_EXPLICIT | FRIBIDI_MASK_BN | FRIBIDI_MASK_NSM))
+/* Is explicit or BN or WS: LRE, RLE, LRO, RLO, PDF, BN, WS? */
+#define FRIBIDI_IS_EXPLICIT_OR_BN_OR_WS(p) \
+ ((p) & (FRIBIDI_MASK_EXPLICIT | FRIBIDI_MASK_BN | FRIBIDI_MASK_WS))
+
/* Is explicit or separator or BN or WS: LRE, RLE, LRO, RLO, PDF, BS, SS, BN, WS? */
#define FRIBIDI_IS_EXPLICIT_OR_SEPARATOR_OR_BN_OR_WS(p) \
((p) & (FRIBIDI_MASK_EXPLICIT | FRIBIDI_MASK_SEPARATOR \
Index: fribidi-bidi.c
===================================================================
RCS file: /cvs/fribidi/fribidi/lib/fribidi-bidi.c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- fribidi-bidi.c 15 Jun 2004 11:52:02 -0000 1.13
+++ fribidi-bidi.c 18 Jun 2004 19:21:33 -0000 1.14
@@ -45,6 +45,10 @@
#include "bidi-types.h"
#include "run.h"
+/*
+ * This file implements most of Unicode Standard Annex #9, Tracking Number 13.
+ */
+
#ifndef MAX
# define MAX(a,b) ((a) > (b) ? (a) : (b))
#endif /* !MAX */
@@ -447,19 +451,27 @@
FRIBIDI_DIR_TO_LEVEL (this_type);
PUSH_STATUS;
}
+
+ /* Set level to the higher level */
+ RL_LEVEL (pp) = level;
}
else if (this_type == FRIBIDI_TYPE_PDF)
{
+ /* Set level to the higher level */
+ RL_LEVEL (pp) = level;
+
/* 3. Terminating Embeddings and overrides */
/* X7. With each PDF, determine the matching embedding or
override code. */
for (i = RL_LEN (pp); i; i--)
POP_STATUS;
}
+ else
+ RL_LEVEL (pp) = level;
+
/* X9. Remove all RLE, LRE, RLO, LRO, PDF, and BN codes. */
/* Remove element and add it to explicits_list */
temp_link.next = pp->next;
- pp->level = FRIBIDI_SENTINEL;
move_node_before (pp, explicits_list);
pp = &temp_link;
}
@@ -727,11 +739,13 @@
explicits_list = NULL;
if UNLIKELY
(!stat) goto out;
+ /* We don't need this code since we set levels for everything we remove.
p = main_run_list->next;
if (p != main_run_list && p->level == FRIBIDI_SENTINEL)
p->level = base_level;
for_run_list (p, main_run_list) if (p->level == FRIBIDI_SENTINEL)
p->level = p->prev->level;
+ */
}
# if DEBUG
@@ -744,13 +758,18 @@
}
# endif /* DEBUG */
- DBG ("reset the embedding levels");
+ DBG ("reset the embedding levels, 1, 2, 3.");
{
register int j, state, pos;
register FriBidiCharType char_type;
register FriBidiRun *p, *q, *list;
- /* L1. Reset the embedding levels of some chars. */
+ /* L1. Reset the embedding levels of some chars:
+ 1. segment separators,
+ 2. paragraph separators,
+ 3. any sequence of whitespace characters preceding a segment
+ separator or paragraph separator, and
+ ... (to be continued in fribidi_reorder_line()). */
list = new_run_list ();
if UNLIKELY
(!list) goto out;
@@ -759,11 +778,9 @@
pos = len - 1;
for (j = len - 1; j >= -1; j--)
{
- /* if state is on at the very first of the string, do this too. */
+ /* close up the open link at the end */
if (j >= 0)
- {
- char_type = BIDI_TYPE (j);
- }
+ char_type = BIDI_TYPE (j);
else
char_type = FRIBIDI_TYPE_ON;
if (!state && FRIBIDI_IS_SEPARATOR (char_type))
@@ -868,13 +885,15 @@
FRIBIDI_ENTRY FriBidiLevel
fribidi_reorder_line (
+ /* input and output */
+ FriBidiChar *str,
/* input */
- const FriBidiLevel *embedding_levels,
const FriBidiStrIndex len,
const FriBidiStrIndex off,
const FriBidiCharType *bidi_types,
+ const FriBidiParType base_dir,
/* input and output */
- FriBidiChar *str,
+ FriBidiLevel *embedding_levels,
/* output */
FriBidiStrIndex *positions_L_to_V,
FriBidiStrIndex *positions_V_to_L
@@ -904,8 +923,19 @@
DBG ("in fribidi_reorder_line");
- fribidi_assert (embedding_levels);
fribidi_assert (str || bidi_types);
+ fribidi_assert (embedding_levels);
+
+ 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 = len - 1; i >= 0 &&
+ FRIBIDI_IS_EXPLICIT_OR_BN_OR_WS (BIDI_TYPE (i)); i--)
+ embedding_levels[i] = FRIBIDI_DIR_TO_LEVEL (base_dir);
+ }
/* If l2v is to be calculated we must have v2l as well. If it is not
given by the caller, we have to make a private instance of it. */
Index: fribidi-bidi.h
===================================================================
RCS file: /cvs/fribidi/fribidi/lib/fribidi-bidi.h,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- fribidi-bidi.h 15 Jun 2004 11:52:02 -0000 1.10
+++ fribidi-bidi.h 18 Jun 2004 19:21:33 -0000 1.11
@@ -80,8 +80,9 @@
* This function finds the bidi embedding levels of a single paragraph,
* as defined by the Unicode Bidirectional Algorithm available at
* http://www.unicode.org/reports/tr9/. This function implements rules P2 to
- * L1 inclusive, except for rule X9 which is implemented in
- * fribidi_remove_bidi_marks().
+ * I1 inclusive, and parts 1 to 3 of L1, except for rule X9 which is
+ * 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
@@ -109,8 +110,8 @@
/* fribidi_reorder_line - reorder a line of logical string to visual
*
* This function reorders the characters in a line of text from logical to
- * final visual order. This function implements rules L2 and L3 of the
- * Unicode Bidirectional Algorithm available at
+ * final visual order. This function implements part 4 of rule L1, and rules
+ * L2 and L3 of the Unicode Bidirectional Algorithm available at
* http://www.unicode.org/reports/tr9/#Reordering_Resolved_Levels.
*
* As a side effect it also sets position maps if not NULL.
@@ -122,6 +123,12 @@
* should provide the same types to this function for valid resutls.
* Providing bidi types if available at your side, saves you a few cycles.
*
+ * 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
+ * of white space at the end of line is reset to the paragraph embedding level
+ * (That is part 4 of rule L1).
+ *
* Note that the bidi types and embedding levels are not reordered. You can
* reorder these (or any other) arrays using the position_L_to_V_map later.
*
@@ -132,14 +139,15 @@
* occured (memory allocation failure most probably).
*/
FRIBIDI_ENTRY FriBidiLevel fribidi_reorder_line (
- const FriBidiLevel *embedding_levels, /* input list of embedding levels,
- as returned by
- fribidi_get_par_embedding_levels */
+ FriBidiChar *str, /* string to reorder */
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 */
- FriBidiChar *str, /* string to shape */
+ const FriBidiParType base_dir, /* resolved paragraph base direction */
+ FriBidiLevel *embedding_levels, /* input list of embedding levels,
+ as returned by
+ fribidi_get_par_embedding_levels */
FriBidiStrIndex *positions_L_to_V, /* output mapping from logical to
visual string positions */
FriBidiStrIndex *positions_V_to_L /* output mapping from visual string
Index: fribidi-types.h
===================================================================
RCS file: /cvs/fribidi/fribidi/lib/fribidi-types.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- fribidi-types.h 15 Jun 2004 11:52:02 -0000 1.7
+++ fribidi-types.h 18 Jun 2004 19:21:33 -0000 1.8
@@ -139,8 +139,8 @@
#ifndef FRIBIDI_MAX_STRING_LENGTH
# define FRIBIDI_MAX_STRING_LENGTH (sizeof (FriBidiStrIndex) == 2 ? \
- 0x7FFE : (sizeof (FriBidiStrIndex) == 1 ? \
- 0x7E : 0x8FFFFFFEL))
+ 0xFFFF : (sizeof (FriBidiStrIndex) == 1 ? \
+ 0xFF : 0xFFFFFFFFL))
#endif
/* A few macros for working with bits */
Index: fribidi.c
===================================================================
RCS file: /cvs/fribidi/fribidi/lib/fribidi.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- fribidi.c 15 Jun 2004 11:52:02 -0000 1.11
+++ fribidi.c 18 Jun 2004 19:21:33 -0000 1.12
@@ -202,9 +202,7 @@
fribidi_shape (embedding_levels, len, visual_str);
- status =
- fribidi_reorder_line (embedding_levels, len, 0, NULL, visual_str,
- positions_L_to_V, positions_V_to_L);
+ status = fribidi_reorder_line (visual_str, len, 0, NULL, *pbase_dir, embedding_levels, positions_L_to_V, positions_V_to_L);
out:
More information about the FriBidi-Commit
mailing list