diff --git a/src/newgdi/glyphruninfo.c b/src/newgdi/glyphruninfo.c index 966d7d95..662cf7a8 100644 --- a/src/newgdi/glyphruninfo.c +++ b/src/newgdi/glyphruninfo.c @@ -80,6 +80,8 @@ GLYPHRUNINFO* GUIAPI CreateGlyphRunInfo( BidiBracketType local_brk_ts[LOCAL_ARRAY_SIZE]; BidiBracketType *brk_ts = NULL; + BidiLevel level_or, level_and; + ScriptType script_type = SCRIPT_COMMON; int i, j; @@ -122,10 +124,15 @@ GLYPHRUNINFO* GUIAPI CreateGlyphRunInfo( // remove the bidi marks from embedding levels and original string. j = 0; + level_or = 0, level_and = 1; for (i = 0; i < nr_ucs; i++) { if (!BIDI_IS_EXPLICIT_OR_BN (bidi_ts[i])) { els[j] = els[i]; ucs[j] = ucs[i]; + + level_or |= els[j]; + level_and &= els[j]; + j++; } } @@ -137,6 +144,12 @@ GLYPHRUNINFO* GUIAPI CreateGlyphRunInfo( goto out; } + // check for all even or odd + /* If none of the levels had the LSB set, all chars were even. */ + runinfo->all_even = (level_or & 0x1) == 0; + /* If all of the levels had the LSB set, all chars were odd. */ + runinfo->all_odd = (level_and & 0x1) == 1; + runinfo->ucs = ucs; runinfo->nr_ucs = nr_ucs; runinfo->els = els; diff --git a/src/newgdi/glyphruninfo.h b/src/newgdi/glyphruninfo.h index de5ca153..042afc22 100644 --- a/src/newgdi/glyphruninfo.h +++ b/src/newgdi/glyphruninfo.h @@ -78,6 +78,8 @@ typedef enum { GR_DIRECTION_BTT } GlyphRunDir; +// NOTE: we arrange the fields carefully to avoid wasting space when +// we allocate an array of this structure. typedef struct _MAPL2G { // Glyph index in the run; Less than 0 if it is ignored. Sint32 glyph_index; @@ -116,6 +118,10 @@ struct _GLYPHRUNINFO { int nr_ucs; int nr_runs; ParagraphDir base_dir; + + /* The following fields will be initialized by CreateGlyphRunInfo. */ + Uint8 all_even; + Uint8 all_odd; }; #ifdef __cplusplus