mirror of
https://github.com/VincentWei/MiniGUI.git
synced 2026-09-25 02:33:59 +08:00
rename files and internal apis
This commit is contained in:
@@ -9935,6 +9935,13 @@ MG_EXPORT Uint32 GUIAPI GetACharType (LOGFONT* logfont, Achar32 chv);
|
||||
/* Weak Right-To-Left */
|
||||
#define BIDI_TYPE_WRTL (BIDI_MASK_WEAK | BIDI_MASK_RTL)
|
||||
|
||||
/* The following are only used internally */
|
||||
|
||||
/* Start of text */
|
||||
#define BIDI_TYPE_SOT (BIDI_MASK_SENTINEL)
|
||||
/* End of text */
|
||||
#define BIDI_TYPE_EOT (BIDI_MASK_SENTINEL + BIDI_MASK_RTL)
|
||||
|
||||
/* Is private-use value? */
|
||||
//#define BIDI_TYPE_PRIVATE(p) ((p) < 0)
|
||||
|
||||
|
||||
+13
-14
@@ -2,7 +2,7 @@ SUBDIRS = in-core
|
||||
|
||||
noinst_LTLIBRARIES = libfont.la
|
||||
|
||||
SRC_FILES = charset.c charset-arabic.c \
|
||||
SRC_FILES = charset.c charset-arabic.c legacy-bidi.c \
|
||||
unicode-comp.c unicode-script.c language-code.c \
|
||||
sysfont.c logfont.c devfont.c fontname.c \
|
||||
rawbitmap.c varbitmap.c qpf.c upf.c \
|
||||
@@ -13,25 +13,24 @@ SRC_FILES = charset.c charset-arabic.c \
|
||||
mapunitogb.c mapunitogbk.c mapunitobig5.c mapunitogb18030.c \
|
||||
bitmapfont.c scripteasy.c \
|
||||
unicode-emoji.c \
|
||||
mgbidi.c
|
||||
unicode-bidi.c
|
||||
|
||||
HDR_FILES = charset.h rawbitmap.h varbitmap.h freetype2.h qpf.h se_minigui.h \
|
||||
upf.h bitmapfont.h unicode-bidi-tables.h \
|
||||
unicode-tables.h unicode-break-tables.h unicode-script-table.h \
|
||||
unicode-decomp.h unicode-comp.h \
|
||||
unicode-emoji-tables.h \
|
||||
iso8859-bidi-tables.inc \
|
||||
mgbidi.h \
|
||||
mgbidi-bidi-types-list.inc \
|
||||
mgbidi-joining-types-list.inc \
|
||||
mgbidi-arabic-misc-table.inc \
|
||||
mgbidi-bidi-type-table.inc \
|
||||
mgbidi-brackets-table.inc \
|
||||
mgbidi-brackets-type-table.inc \
|
||||
mgbidi-mirroring-table.inc \
|
||||
mgbidi-arabic-shaping-table.inc \
|
||||
mgbidi-joining-type-table.inc
|
||||
|
||||
legacy-bidi-tables.inc \
|
||||
unicode-bidi.h \
|
||||
unicode-joining-types-list.inc \
|
||||
unicode-joining-type-table.inc \
|
||||
unicode-arabic-shaping-table.inc \
|
||||
unicode-arabic-misc-table.inc \
|
||||
unicode-bidi-bidi-types-list.inc \
|
||||
unicode-bidi-bidi-type-table.inc \
|
||||
unicode-bidi-brackets-table.inc \
|
||||
unicode-bidi-brackets-type-table.inc \
|
||||
unicode-bidi-mirroring-table.inc
|
||||
|
||||
EXTRA_DIST = convgbmap.c jisunimap.c $(SRC_FILES) $(HDR_FILES) \
|
||||
makefile.ng makefile.msvc
|
||||
|
||||
+7
-7
@@ -732,7 +732,7 @@ static CHARSETOPS CharsetOps_iso8859_5 = {
|
||||
#endif /* _CYRILLIC */
|
||||
|
||||
#if defined (_MGCHARSET_HEBREW) || defined (_MGCHARSET_ARABIC)
|
||||
#include "iso8859-bidi-tables.inc"
|
||||
#include "legacy-bidi-tables.inc"
|
||||
#endif
|
||||
|
||||
#if defined (_MGCHARSET_HEBREW) || defined (_MGCHARSET_ARABIC) || defined (_MGCHARSET_UNICODE)
|
||||
@@ -3583,17 +3583,17 @@ static unsigned int unicode_char_type (Achar32 chv)
|
||||
|
||||
enum _BidiCharTypeLinearEnum {
|
||||
#define _MGBIDI_ADD_TYPE(TYPE,SYMBOL) TYPE,
|
||||
#include "mgbidi-bidi-types-list.inc"
|
||||
#include "unicode-bidi-types-list.inc"
|
||||
#undef _MGBIDI_ADD_TYPE
|
||||
_MGBIDI_NUM_TYPES
|
||||
};
|
||||
|
||||
#include "mgbidi-bidi-type-table.inc"
|
||||
#include "unicode-bidi-type-table.inc"
|
||||
|
||||
/* Map _BidiCharTypeLinearEnum to BidiType. */
|
||||
static const BidiType linear_enum_to_bidi_type[] = {
|
||||
#define _MGBIDI_ADD_TYPE(TYPE,SYMBOL) BIDI_TYPE_##TYPE,
|
||||
#include "mgbidi-bidi-types-list.inc"
|
||||
#include "unicode-bidi-types-list.inc"
|
||||
#undef _MGBIDI_ADD_TYPE
|
||||
};
|
||||
|
||||
@@ -3617,8 +3617,8 @@ void UCharGetBidiTypes(const Uchar32 *str, int len, BidiType *btypes)
|
||||
}
|
||||
}
|
||||
|
||||
#include "mgbidi-brackets-table.inc"
|
||||
#include "mgbidi-brackets-type-table.inc"
|
||||
#include "unicode-bidi-brackets-table.inc"
|
||||
#include "unicode-bidi-brackets-type-table.inc"
|
||||
|
||||
#define MGBIDI_TYPE_BRACKET_OPEN 2
|
||||
|
||||
@@ -3667,7 +3667,7 @@ void UCharGetBracketTypes(const Uchar32 *str, int len,
|
||||
}
|
||||
}
|
||||
|
||||
#include "mgbidi-mirroring-table.inc"
|
||||
#include "unicode-bidi-mirroring-table.inc"
|
||||
|
||||
static BOOL unicode_bidi_mirror_char(Achar32 ch, Achar32* mirrored_ch)
|
||||
{
|
||||
|
||||
@@ -1,267 +0,0 @@
|
||||
/*
|
||||
* This file is part of MiniGUI, a mature cross-platform windowing
|
||||
* and Graphics User Interface (GUI) support system for embedded systems
|
||||
* and smart IoT devices.
|
||||
*
|
||||
* Copyright (C) 2002~2019, Beijing FMSoft Technologies Co., Ltd.
|
||||
* Copyright (C) 1998~2002, WEI Yongming
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Or,
|
||||
*
|
||||
* As this program is a library, any link to this program must follow
|
||||
* GNU General Public License version 3 (GPLv3). If you cannot accept
|
||||
* GPLv3, you need to be licensed from FMSoft.
|
||||
*
|
||||
* If you have got a commercial license of this program, please use it
|
||||
* under the terms and conditions of the commercial license.
|
||||
*
|
||||
* For more information about the commercial license, please refer to
|
||||
* <http://www.minigui.com/en/about/licensing-policy/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
** mgbidi.h:
|
||||
**
|
||||
** A general implementation of UNICODE BIDIRECTIONAL ALGORITHM for MiniGUI
|
||||
**
|
||||
** https://www.unicode.org/reports/tr9/
|
||||
**
|
||||
** Created by WEI Yongming at 2019/03/08
|
||||
**
|
||||
** This implementation is based on LGPL'd FriBidi:
|
||||
**
|
||||
** https://github.com/fribidi/fribidi
|
||||
*/
|
||||
|
||||
#ifndef _MGFONT_GENERAL_BIDI_H
|
||||
#define _MGFONT_GENERAL_BIDI_H
|
||||
|
||||
#ifdef _MGCHARSET_UNICODE_FULL
|
||||
#define MGBIDI_UNICODE_CHARS 0x110000
|
||||
#else
|
||||
#define MGBIDI_UNICODE_CHARS 0xFFFE
|
||||
#endif
|
||||
|
||||
/* some general macros */
|
||||
#define STRINGIZE(symbol) #symbol
|
||||
|
||||
/* A few macros for working with bits */
|
||||
#define BIDI_TEST_BITS(x, mask) (((x) & (mask)) ? 1 : 0)
|
||||
|
||||
#define BIDI_INCLUDE_BITS(x, mask) ((x) | (mask))
|
||||
|
||||
#define BIDI_EXCLUDE_BITS(x, mask) ((x) & ~(mask))
|
||||
|
||||
#define BIDI_SET_BITS(x, mask) ((x) |= (mask))
|
||||
|
||||
#define BIDI_UNSET_BITS(x, mask) ((x) &= ~(mask))
|
||||
|
||||
#define BIDI_ADJUST_BITS(x, mask, cond) \
|
||||
((x) = ((x) & ~(mask)) | ((cond) ? (mask) : 0))
|
||||
|
||||
#define BIDI_ADJUST_AND_TEST_BITS(x, mask, cond) \
|
||||
BIDI_TEST_BITS(BIDI_ADJUST_BITS((x), (mask), (cond)), (mask))
|
||||
|
||||
/* The maximum embedding level value assigned by explicit marks */
|
||||
#define BIDI_MAX_EXPLICIT_LEVEL 125
|
||||
|
||||
/* The maximum *number* of different resolved embedding levels: 0-126 */
|
||||
#define BIDI_MAX_RESOLVED_LEVELS 127
|
||||
|
||||
/* The maximum *number* of nested brackets: 0-63 */
|
||||
#define BIDI_MAX_NESTED_BRACKET_PAIRS 63
|
||||
|
||||
#define BIDI_SENTINEL -1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct _BidiRun BidiRun;
|
||||
|
||||
struct _BidiRun {
|
||||
BidiRun *prev;
|
||||
BidiRun *next;
|
||||
|
||||
/* Additional links for connecting the isolate tree */
|
||||
BidiRun *prev_isolate;
|
||||
BidiRun *next_isolate;
|
||||
|
||||
int pos, len;
|
||||
BidiType type;
|
||||
BidiLevel level;
|
||||
BidiLevel isolate_level;
|
||||
Uint8 bracket_type;
|
||||
};
|
||||
|
||||
#define swap(a,b) \
|
||||
do { \
|
||||
void *t; \
|
||||
(t) = (a); \
|
||||
(a) = (b); \
|
||||
(b) = (t); \
|
||||
} while(0)
|
||||
|
||||
#define merge_lists(a,b) \
|
||||
do { \
|
||||
swap((a)->prev->next, (b)->prev->next); \
|
||||
swap((a)->prev, (b)->prev); \
|
||||
} while(0)
|
||||
|
||||
#define delete_node(x) \
|
||||
do { \
|
||||
(x)->prev->next = (x)->next; \
|
||||
(x)->next->prev = (x)->prev; \
|
||||
} while(0)
|
||||
|
||||
#define insert_node_before(x, list) \
|
||||
do { \
|
||||
(x)->prev = (list)->prev; \
|
||||
(list)->prev->next = (x); \
|
||||
(x)->next = (list); \
|
||||
(list)->prev = (x); \
|
||||
} while(0)
|
||||
|
||||
#define move_node_before(x, list) \
|
||||
do { \
|
||||
if ((x)->prev) { \
|
||||
delete_node(x); \
|
||||
} \
|
||||
insert_node_before((x), (list)); \
|
||||
} while(0)
|
||||
|
||||
#define for_run_list(x, list) \
|
||||
for ((x) = (list)->next; (x)->type != BIDI_TYPE_SENTINEL; (x) = (x)->next)
|
||||
|
||||
/**
|
||||
* \fn mgbidi_get_paragraph_dir
|
||||
* \brief get base paragraph direction
|
||||
*
|
||||
* This function finds the base direction of a single paragraph,
|
||||
* as defined by rule P2 of the Unicode Bidirectional Algorithm available at
|
||||
* http://www.unicode.org/reports/tr9/#P2.
|
||||
*
|
||||
* You typically do not need this function as
|
||||
* mgbidi_get_paragraph_els_ex() knows how to compute base direction
|
||||
* itself, but you may need this to implement a more sophisticated paragraph
|
||||
* direction handling. Note that you can pass more than a paragraph to this
|
||||
* function and the direction of the first non-neutral paragraph is returned,
|
||||
* which is a very good heuristic to set direction of the neutral paragraphs
|
||||
* at the beginning of text. For other neutral paragraphs, you better use the
|
||||
* direction of the previous paragraph.
|
||||
*
|
||||
* \param bidi_types the pointer to the BidiType array as returned by
|
||||
* mgbidi_get_bidi_types()
|
||||
* \param len The length of bidi_types
|
||||
*
|
||||
* \return Base pargraph direction. No weak paragraph direction is returned,
|
||||
* only BIDI_PGDIR_LTR, BIDI_PGDIR_RTL, or BIDI_PGDIR_ON.
|
||||
*
|
||||
*/
|
||||
int mgbidi_get_paragraph_dir(const BidiType *bidi_types, int len);
|
||||
|
||||
/**
|
||||
* \fn mgbidi_get_paragraph_els_ex
|
||||
* \brief Get bidi embedding levels of a paragraph
|
||||
*
|
||||
* 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 I1 inclusive, and parts 1 to 3 of L1.
|
||||
* Part 4 of L1 is implemented in mgbidi_reorder_line().
|
||||
*
|
||||
* There are a few macros defined in mgbidi-bidi-types.h to work with this
|
||||
* embedding levels.
|
||||
*
|
||||
* \param bidi_types the pointer to the BidiType array as returned by
|
||||
* mgbidi_get_bidi_types()
|
||||
* \param bracket_types The pointer to a Uint8 which contains the
|
||||
bracket types as returned by UCharGetBracketTypes()
|
||||
* \param len The length of the list.
|
||||
* \param base_dir requested and resolved paragraph base direction
|
||||
* \param embedding_levels The pointer to a buffer which will restore
|
||||
* the embedding levels
|
||||
*
|
||||
* \return The Maximum level found plus one, or zero if any error occurred
|
||||
* (memory allocation failure most probably).
|
||||
*/
|
||||
BidiLevel mgbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
const BidiBracketType* bracket_types, int len,
|
||||
int *base_dir, BidiLevel *embedding_levels);
|
||||
|
||||
/**
|
||||
* \fn mgbidi_reorder_line
|
||||
* \brief 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 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.
|
||||
*
|
||||
* You should provide the resolved paragraph direction and embedding levels as
|
||||
* set by mgbidi_get_paragraph_els_ex(). 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 map later.
|
||||
* The user is responsible to initialize map to something sensible,
|
||||
* like an identity mapping, or pass NULL if no map is needed.
|
||||
*
|
||||
* There is an optional part to this function, which is whether non-spacing
|
||||
* marks for right-to-left parts of the text should be reordered to come after
|
||||
* their base characters in the visual string or not.
|
||||
*
|
||||
* Most rendering engines expect this behavior, but console-based systems
|
||||
* for example do not like it. This is controlled by the
|
||||
* BIDI_FLAG_REORDER_NSM flag. The flag is on in BIDI_FLAGS_DEFAULT.
|
||||
*
|
||||
* \param flags The reorder flags.
|
||||
* \param bidi_types the pointer to the BidiType array as returned by
|
||||
* mgbidi_get_bidi_types()
|
||||
* \param bracket_types The pointer to a Uint8 which contains the
|
||||
bracket types as returned by UCharGetBracketTypes()
|
||||
* \param len The length of the list.
|
||||
* \param off The input offset of the beginning of the line in the paragraph.
|
||||
* \param base_dir The resolved paragraph base direction.
|
||||
* \param embedding_levels The embedding levels, as returned by
|
||||
mgbidi_get_paragraph_els_ex()
|
||||
* \param visual_str
|
||||
* \param extra The pointer to the extra array to reorder; can be NULL.
|
||||
* \param cb_reverse_extra The callback function to reverse the extra array.
|
||||
* \param map a map of string indices which is reordered to reflect
|
||||
* where each glyph ends up.
|
||||
*
|
||||
* \return Maximum level found in this line plus one, or zero if any error
|
||||
* occurred (memory allocation failure most probably).
|
||||
*/
|
||||
BidiLevel mgbidi_reorder_line(Uint32 flags, const BidiType *bidi_types,
|
||||
int len, int off, int base_dir, BidiLevel *embedding_levels,
|
||||
Achar32 *visual_str, int *map,
|
||||
void* extra, CB_REVERSE_EXTRA cb_reverse_extra);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* !_MGFONT_GENERAL_BIDI_H */
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
** mgbidi.c:
|
||||
** unicode-bidi.c:
|
||||
**
|
||||
** A general implementation of UNICODE BIDIRECTIONAL ALGORITHM for MiniGUI
|
||||
**
|
||||
@@ -61,15 +61,10 @@
|
||||
#include "devfont.h"
|
||||
|
||||
#include "bidi.h"
|
||||
#include "mgbidi.h"
|
||||
#include "unicode-bidi.h"
|
||||
|
||||
#ifdef DEBUG
|
||||
|
||||
static inline int mgbidi_debug_status(void)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
static void validate_run_list(BidiRun *run_list)
|
||||
@@ -479,14 +474,14 @@ static const char char_from_level_array[] = {
|
||||
'*', '*', '*', '*', '*'
|
||||
};
|
||||
|
||||
#define mgbidi_char_from_level(level) char_from_level_array[(level) + 1]
|
||||
#define unicode_bidi_char_from_level(level) char_from_level_array[(level) + 1]
|
||||
|
||||
static const char *mgbidi_get_bidi_type_name(BidiType t)
|
||||
static const char *unicode_bidi_get_bidi_type_name(BidiType t)
|
||||
{
|
||||
switch ((int)t) {
|
||||
# define _BIDI_ADD_TYPE(TYPE,SYMBOL) case BIDI_TYPE_##TYPE: return #TYPE;
|
||||
# define _BIDI_ALL_TYPES
|
||||
# include "mgbidi-bidi-types-list.inc"
|
||||
# include "unicode-bidi-types-list.inc"
|
||||
# undef _BIDI_ALL_TYPES
|
||||
# undef _BIDI_ADD_TYPE
|
||||
default:
|
||||
@@ -499,7 +494,7 @@ static void print_types_re(const BidiRun *pp)
|
||||
_DBG_PRINTF (" Run types : ");
|
||||
for_run_list (pp, pp) {
|
||||
_DBG_PRINTF ("%d:%d(%s)[%d,%d] ",
|
||||
pp->pos, pp->len, mgbidi_get_bidi_type_name (pp->type), pp->level, pp->isolate_level);
|
||||
pp->pos, pp->len, unicode_bidi_get_bidi_type_name (pp->type), pp->level, pp->isolate_level);
|
||||
}
|
||||
_DBG_PRINTF ("\n");
|
||||
}
|
||||
@@ -511,7 +506,7 @@ static void print_resolved_levels(const BidiRun *pp)
|
||||
{
|
||||
register int i;
|
||||
for (i = RL_LEN (pp); i; i--)
|
||||
_DBG_PRINTF ("%c", mgbidi_char_from_level (RL_LEVEL (pp)));
|
||||
_DBG_PRINTF ("%c", unicode_bidi_char_from_level (RL_LEVEL (pp)));
|
||||
}
|
||||
_DBG_PRINTF ("\n");
|
||||
}
|
||||
@@ -522,7 +517,7 @@ static void print_resolved_types(const BidiRun *pp)
|
||||
for_run_list (pp, pp) {
|
||||
int i;
|
||||
for (i = RL_LEN (pp); i; i--)
|
||||
_DBG_PRINTF ("%s ", mgbidi_get_bidi_type_name (pp->type));
|
||||
_DBG_PRINTF ("%s ", unicode_bidi_get_bidi_type_name (pp->type));
|
||||
}
|
||||
_DBG_PRINTF ("\n");
|
||||
}
|
||||
@@ -533,7 +528,7 @@ static void print_bidi_string(const BidiType *bidi_types, const int len)
|
||||
|
||||
_DBG_PRINTF (" Org. types : ");
|
||||
for (i = 0; i < len; i++)
|
||||
_DBG_PRINTF ("%s ", mgbidi_get_bidi_type_name (bidi_types[i]));
|
||||
_DBG_PRINTF ("%s ", unicode_bidi_get_bidi_type_name (bidi_types[i]));
|
||||
_DBG_PRINTF ("\n");
|
||||
}
|
||||
|
||||
@@ -647,7 +642,7 @@ static void print_pairing_nodes(BidiPairingNode *nodes)
|
||||
#define BIDI_EMBEDDING_DIRECTION(link) \
|
||||
BIDI_LEVEL_TO_DIR(RL_LEVEL(link))
|
||||
|
||||
int mgbidi_get_par_direction(const BidiType *bidi_types, const int len)
|
||||
int unicode_bidi_get_par_direction(const BidiType *bidi_types, const int len)
|
||||
{
|
||||
register int i;
|
||||
|
||||
@@ -741,7 +736,7 @@ static void free_pairing_nodes(BidiPairingNode *nodes)
|
||||
}
|
||||
}
|
||||
|
||||
BidiLevel mgbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
BidiLevel unicode_bidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
const BidiBracketType *bracket_types, const int len,
|
||||
int *pbase_dir, BidiLevel *embedding_levels)
|
||||
{
|
||||
@@ -757,7 +752,7 @@ BidiLevel mgbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
goto out;
|
||||
}
|
||||
|
||||
_DBG_PRINTF ("in mgbidi_get_paragraph_els");
|
||||
_DBG_PRINTF ("in unicode_bidi_get_paragraph_els");
|
||||
|
||||
/* Determinate character types */
|
||||
{
|
||||
@@ -794,16 +789,14 @@ BidiLevel mgbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
}
|
||||
}
|
||||
base_dir = BIDI_LEVEL_TO_DIR (base_level);
|
||||
_DBG_PRINTF (" base level : %c", mgbidi_char_from_level (base_level));
|
||||
_DBG_PRINTF (" base dir : %s", mgbidi_get_bidi_type_name (base_dir));
|
||||
_DBG_PRINTF (" base level : %c", unicode_bidi_char_from_level (base_level));
|
||||
_DBG_PRINTF (" base dir : %s", unicode_bidi_get_bidi_type_name (base_dir));
|
||||
|
||||
base_level_per_iso_level[0] = base_level;
|
||||
|
||||
# ifdef DEBUG
|
||||
if (mgbidi_debug_status ()) {
|
||||
print_types_re (main_run_list);
|
||||
}
|
||||
# endif /* DEBUG */
|
||||
#ifdef DEBUG
|
||||
print_types_re (main_run_list);
|
||||
#endif /* DEBUG */
|
||||
|
||||
/* Explicit Levels and Directions */
|
||||
_DBG_PRINTF ("explicit levels and directions");
|
||||
@@ -1042,14 +1035,12 @@ BidiLevel mgbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
|
||||
compact_list (main_run_list);
|
||||
|
||||
# ifdef DEBUG
|
||||
if (mgbidi_debug_status ()) {
|
||||
print_types_re (main_run_list);
|
||||
print_bidi_string (bidi_types, len);
|
||||
print_resolved_levels (main_run_list);
|
||||
print_resolved_types (main_run_list);
|
||||
}
|
||||
# endif /* DEBUG */
|
||||
#ifdef DEBUG
|
||||
print_types_re (main_run_list);
|
||||
print_bidi_string (bidi_types, len);
|
||||
print_resolved_levels (main_run_list);
|
||||
print_resolved_types (main_run_list);
|
||||
#endif /* DEBUG */
|
||||
|
||||
/* 4. Resolving weak types. Also calculate the maximum isolate level */
|
||||
max_iso_level = 0;
|
||||
@@ -1225,11 +1216,9 @@ BidiLevel mgbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
compact_neutrals (main_run_list);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (mgbidi_debug_status ()) {
|
||||
print_resolved_levels (main_run_list);
|
||||
print_resolved_types (main_run_list);
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
print_resolved_levels (main_run_list);
|
||||
print_resolved_types (main_run_list);
|
||||
#endif /* DEBUG */
|
||||
|
||||
/* 5. Resolving Neutral Types */
|
||||
|
||||
@@ -1309,9 +1298,7 @@ BidiLevel mgbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
sort_pairing_nodes(&pairing_nodes);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (mgbidi_debug_status ()) {
|
||||
print_pairing_nodes (pairing_nodes);
|
||||
}
|
||||
print_pairing_nodes (pairing_nodes);
|
||||
#endif /* DEBUG */
|
||||
|
||||
/* Start the N0 */
|
||||
@@ -1402,10 +1389,8 @@ BidiLevel mgbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if (mgbidi_debug_status ()) {
|
||||
print_resolved_levels (main_run_list);
|
||||
print_resolved_types (main_run_list);
|
||||
}
|
||||
print_resolved_levels (main_run_list);
|
||||
print_resolved_types (main_run_list);
|
||||
#endif /* DEBUG */
|
||||
}
|
||||
|
||||
@@ -1443,10 +1428,8 @@ BidiLevel mgbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
compact_list (main_run_list);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (mgbidi_debug_status ()) {
|
||||
print_resolved_levels (main_run_list);
|
||||
print_resolved_types (main_run_list);
|
||||
}
|
||||
print_resolved_levels (main_run_list);
|
||||
print_resolved_types (main_run_list);
|
||||
#endif /* DEBUG */
|
||||
|
||||
/* 6. Resolving implicit levels */
|
||||
@@ -1479,12 +1462,10 @@ BidiLevel mgbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
compact_list (main_run_list);
|
||||
|
||||
#ifdef DEBUG
|
||||
if (mgbidi_debug_status ()) {
|
||||
print_bidi_string (bidi_types, len);
|
||||
print_resolved_levels (main_run_list);
|
||||
print_resolved_types (main_run_list);
|
||||
}
|
||||
#endif /* DEBUG */
|
||||
print_bidi_string (bidi_types, len);
|
||||
print_resolved_levels (main_run_list);
|
||||
print_resolved_types (main_run_list);
|
||||
#endif /* DEBUG */
|
||||
|
||||
/* Reinsert the explicit codes & BN's that are already removed, from the
|
||||
explicits_list to main_run_list. */
|
||||
@@ -1505,13 +1486,11 @@ BidiLevel mgbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
p->level = p->prev->level;
|
||||
}
|
||||
|
||||
# ifdef DEBUG
|
||||
if (mgbidi_debug_status ()) {
|
||||
print_types_re (main_run_list);
|
||||
print_resolved_levels (main_run_list);
|
||||
print_resolved_types (main_run_list);
|
||||
}
|
||||
# endif /* DEBUG */
|
||||
#ifdef DEBUG
|
||||
print_types_re (main_run_list);
|
||||
print_resolved_levels (main_run_list);
|
||||
print_resolved_types (main_run_list);
|
||||
#endif /* DEBUG */
|
||||
|
||||
_DBG_PRINTF ("reset the embedding levels, 1, 2, 3.");
|
||||
{
|
||||
@@ -1526,7 +1505,7 @@ BidiLevel mgbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
separator or paragraph separator, and
|
||||
4. any sequence of whitespace characters and/or isolate formatting
|
||||
characters at the end of the line.
|
||||
... (to be continued in mgbidi_reorder_line()). */
|
||||
... (to be continued in unicode_bidi_reorder_line()). */
|
||||
list = new_run_list ();
|
||||
if (!list) goto out;
|
||||
q = list;
|
||||
@@ -1566,11 +1545,9 @@ BidiLevel mgbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
}
|
||||
|
||||
#ifdef DEBUG
|
||||
if (mgbidi_debug_status ()) {
|
||||
print_types_re (main_run_list);
|
||||
print_resolved_levels (main_run_list);
|
||||
print_resolved_types (main_run_list);
|
||||
}
|
||||
print_types_re (main_run_list);
|
||||
print_resolved_levels (main_run_list);
|
||||
print_resolved_types (main_run_list);
|
||||
#endif /* DEBUG */
|
||||
|
||||
{
|
||||
@@ -1587,7 +1564,7 @@ BidiLevel mgbidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
status = TRUE;
|
||||
|
||||
out:
|
||||
_DBG_PRINTF ("leaving mgbidi_get_paragraph_els");
|
||||
_DBG_PRINTF ("leaving unicode_bidi_get_paragraph_els");
|
||||
|
||||
if (main_run_list)
|
||||
free_run_list (main_run_list);
|
||||
@@ -1620,7 +1597,7 @@ static void index_array_reverse (int *arr, int len)
|
||||
}
|
||||
}
|
||||
|
||||
BidiLevel mgbidi_reorder_line(Uint32 flags,
|
||||
BidiLevel unicode_bidi_reorder_line(Uint32 flags,
|
||||
const BidiType *bidi_types, int len,
|
||||
int off, int base_dir,
|
||||
BidiLevel *embedding_levels,
|
||||
@@ -1635,7 +1612,7 @@ BidiLevel mgbidi_reorder_line(Uint32 flags,
|
||||
goto out;
|
||||
}
|
||||
|
||||
_DBG_PRINTF ("in mgbidi_reorder_line");
|
||||
_DBG_PRINTF ("in unicode_bidi_reorder_line");
|
||||
|
||||
_DBG_PRINTF ("reset the embedding levels, 4. whitespace at the end of line");
|
||||
{
|
||||
@@ -1723,7 +1700,6 @@ BidiLevel mgbidi_reorder_line(Uint32 flags,
|
||||
status = TRUE;
|
||||
|
||||
out:
|
||||
|
||||
return status ? max_level + 1 : 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
/*
|
||||
* This file is part of MiniGUI, a mature cross-platform windowing
|
||||
* and Graphics User Interface (GUI) support system for embedded systems
|
||||
* and smart IoT devices.
|
||||
*
|
||||
* Copyright (C) 2002~2019, Beijing FMSoft Technologies Co., Ltd.
|
||||
* Copyright (C) 1998~2002, WEI Yongming
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
* Or,
|
||||
*
|
||||
* As this program is a library, any link to this program must follow
|
||||
* GNU General Public License version 3 (GPLv3). If you cannot accept
|
||||
* GPLv3, you need to be licensed from FMSoft.
|
||||
*
|
||||
* If you have got a commercial license of this program, please use it
|
||||
* under the terms and conditions of the commercial license.
|
||||
*
|
||||
* For more information about the commercial license, please refer to
|
||||
* <http://www.minigui.com/en/about/licensing-policy/>.
|
||||
*/
|
||||
|
||||
/*
|
||||
** unicode-bidi.h:
|
||||
**
|
||||
** A general implementation of UNICODE BIDIRECTIONAL ALGORITHM for MiniGUI
|
||||
**
|
||||
** https://www.unicode.org/reports/tr9/
|
||||
**
|
||||
** Created by WEI Yongming at 2019/03/08
|
||||
**
|
||||
** This implementation is based on LGPL'd FriBidi:
|
||||
**
|
||||
** https://github.com/fribidi/fribidi
|
||||
*/
|
||||
|
||||
#ifndef _MGFONT_UNICODE_BIDI_H
|
||||
#define _MGFONT_UNICODE_BIDI_H
|
||||
|
||||
#ifdef _MGCHARSET_UNICODE_FULL
|
||||
#define MGBIDI_UNICODE_CHARS 0x110000
|
||||
#else
|
||||
#define MGBIDI_UNICODE_CHARS 0xFFFE
|
||||
#endif
|
||||
|
||||
/* some general macros */
|
||||
#define STRINGIZE(symbol) #symbol
|
||||
|
||||
/* A few macros for working with bits */
|
||||
#define BIDI_TEST_BITS(x, mask) (((x) & (mask)) ? 1 : 0)
|
||||
|
||||
#define BIDI_INCLUDE_BITS(x, mask) ((x) | (mask))
|
||||
|
||||
#define BIDI_EXCLUDE_BITS(x, mask) ((x) & ~(mask))
|
||||
|
||||
#define BIDI_SET_BITS(x, mask) ((x) |= (mask))
|
||||
|
||||
#define BIDI_UNSET_BITS(x, mask) ((x) &= ~(mask))
|
||||
|
||||
#define BIDI_ADJUST_BITS(x, mask, cond) \
|
||||
((x) = ((x) & ~(mask)) | ((cond) ? (mask) : 0))
|
||||
|
||||
#define BIDI_ADJUST_AND_TEST_BITS(x, mask, cond) \
|
||||
BIDI_TEST_BITS(BIDI_ADJUST_BITS((x), (mask), (cond)), (mask))
|
||||
|
||||
/* The maximum embedding level value assigned by explicit marks */
|
||||
#define BIDI_MAX_EXPLICIT_LEVEL 125
|
||||
|
||||
/* The maximum *number* of different resolved embedding levels: 0-126 */
|
||||
#define BIDI_MAX_RESOLVED_LEVELS 127
|
||||
|
||||
/* The maximum *number* of nested brackets: 0-63 */
|
||||
#define BIDI_MAX_NESTED_BRACKET_PAIRS 63
|
||||
|
||||
#define BIDI_SENTINEL -1
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
typedef struct _BidiRun BidiRun;
|
||||
|
||||
struct _BidiRun {
|
||||
BidiRun *prev;
|
||||
BidiRun *next;
|
||||
|
||||
/* Additional links for connecting the isolate tree */
|
||||
BidiRun *prev_isolate;
|
||||
BidiRun *next_isolate;
|
||||
|
||||
int pos, len;
|
||||
BidiType type;
|
||||
BidiLevel level;
|
||||
BidiLevel isolate_level;
|
||||
Uint8 bracket_type;
|
||||
};
|
||||
|
||||
#define swap(a,b) \
|
||||
do { \
|
||||
void *t; \
|
||||
(t) = (a); \
|
||||
(a) = (b); \
|
||||
(b) = (t); \
|
||||
} while(0)
|
||||
|
||||
#define merge_lists(a,b) \
|
||||
do { \
|
||||
swap((a)->prev->next, (b)->prev->next); \
|
||||
swap((a)->prev, (b)->prev); \
|
||||
} while(0)
|
||||
|
||||
#define delete_node(x) \
|
||||
do { \
|
||||
(x)->prev->next = (x)->next; \
|
||||
(x)->next->prev = (x)->prev; \
|
||||
} while(0)
|
||||
|
||||
#define insert_node_before(x, list) \
|
||||
do { \
|
||||
(x)->prev = (list)->prev; \
|
||||
(list)->prev->next = (x); \
|
||||
(x)->next = (list); \
|
||||
(list)->prev = (x); \
|
||||
} while(0)
|
||||
|
||||
#define move_node_before(x, list) \
|
||||
do { \
|
||||
if ((x)->prev) { \
|
||||
delete_node(x); \
|
||||
} \
|
||||
insert_node_before((x), (list)); \
|
||||
} while(0)
|
||||
|
||||
#define for_run_list(x, list) \
|
||||
for ((x) = (list)->next; (x)->type != BIDI_TYPE_SENTINEL; (x) = (x)->next)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* !_MGFONT_UNICODE_BIDI_H */
|
||||
|
||||
+23
-23
@@ -3,7 +3,7 @@ CFLAGS=-Wall -Werror -g -D__MINIGUI_LIB__ -I../../../include/
|
||||
COMPRESSION=2
|
||||
|
||||
all:mkmap-ucs-gb18030 mkmap-ucs-gb2312 \
|
||||
mgbidi-unicode-version.h \
|
||||
unicode-version.h \
|
||||
gen-unicode-version \
|
||||
gen-bidi-type-tab \
|
||||
gen-joining-type-tab \
|
||||
@@ -24,19 +24,19 @@ gen-mirroring-tab:gen-mirroring-tab.o packtab.o
|
||||
gen-brackets-tab:gen-brackets-tab.o packtab.o
|
||||
gen-brackets-type-tab:gen-brackets-type-tab.o packtab.o
|
||||
|
||||
biditables:mgbidi-unicode-version.h \
|
||||
mgbidi-bidi-type-table.inc \
|
||||
mgbidi-joining-type-table.inc \
|
||||
mgbidi-arabic-shaping-table.inc \
|
||||
mgbidi-mirroring-table.inc \
|
||||
mgbidi-brackets-table.inc \
|
||||
mgbidi-brackets-type-table.inc
|
||||
biditables:unicode-version.h \
|
||||
unicode-bidi-type-table.inc \
|
||||
unicode-joining-type-table.inc \
|
||||
unicode-arabic-shaping-table.inc \
|
||||
unicode-bidi-mirroring-table.inc \
|
||||
unicode-bidi-brackets-table.inc \
|
||||
unicode-bidi-brackets-type-table.inc
|
||||
|
||||
mgbidi-unicode-version.h:ucd/ReadMe.txt gen-unicode-version
|
||||
./gen-unicode-version ucd/ReadMe.txt > mgbidi-unicode-version.h
|
||||
unicode-version.h:ucd/ReadMe.txt gen-unicode-version
|
||||
./gen-unicode-version ucd/ReadMe.txt > unicode-version.h
|
||||
|
||||
clean:
|
||||
rm -f *.o mgbidi-*.h mgbidi-*.inc \
|
||||
rm -f *.o unicode-*.h unicode-*.inc \
|
||||
mkmap-ucs-gb2312 mkmap-gb18030-ucs.c mkmap-ucs-gb18030 \
|
||||
gen-unicode-version \
|
||||
gen-bidi-type-tab \
|
||||
@@ -46,41 +46,41 @@ clean:
|
||||
gen-brackets-tab \
|
||||
gen-brackets-type-tab
|
||||
|
||||
mgbidi-bidi-type-table.inc: \
|
||||
unicode-bidi-type-table.inc: \
|
||||
ucd/UnicodeData.txt \
|
||||
mgbidi-unicode-version.h \
|
||||
unicode-version.h \
|
||||
gen-bidi-type-tab
|
||||
./gen-bidi-type-tab $(COMPRESSION) $^ > $@
|
||||
|
||||
mgbidi-joining-type-table.inc: \
|
||||
unicode-joining-type-table.inc: \
|
||||
ucd/UnicodeData.txt \
|
||||
ucd/ArabicShaping.txt \
|
||||
mgbidi-unicode-version.h \
|
||||
unicode-version.h \
|
||||
gen-joining-type-tab
|
||||
./gen-joining-type-tab $(COMPRESSION) $^ > $@
|
||||
|
||||
mgbidi-arabic-shaping-table.inc: \
|
||||
unicode-arabic-shaping-table.inc: \
|
||||
ucd/UnicodeData.txt \
|
||||
mgbidi-unicode-version.h \
|
||||
unicode-version.h \
|
||||
gen-arabic-shaping-tab
|
||||
./gen-arabic-shaping-tab $(COMPRESSION) $^ > $@
|
||||
|
||||
mgbidi-mirroring-table.inc: \
|
||||
unicode-bidi-mirroring-table.inc: \
|
||||
ucd/BidiMirroring.txt \
|
||||
mgbidi-unicode-version.h \
|
||||
unicode-version.h \
|
||||
gen-mirroring-tab
|
||||
./gen-mirroring-tab $(COMPRESSION) $^ > $@
|
||||
|
||||
mgbidi-brackets-table.inc: \
|
||||
unicode-bidi-brackets-table.inc: \
|
||||
ucd/BidiBrackets.txt \
|
||||
ucd/UnicodeData.txt \
|
||||
mgbidi-unicode-version.h \
|
||||
unicode-version.h \
|
||||
gen-brackets-tab
|
||||
./gen-brackets-tab $(COMPRESSION) $^ > $@
|
||||
|
||||
mgbidi-brackets-type-table.inc: \
|
||||
unicode-bidi-brackets-type-table.inc: \
|
||||
ucd/BidiBrackets.txt \
|
||||
mgbidi-unicode-version.h \
|
||||
unicode-version.h \
|
||||
gen-brackets-type-tab
|
||||
./gen-brackets-type-tab $(COMPRESSION) $^ > $@
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* MGBidi
|
||||
* gen-arabic-shaping-tab.c - generate mgbidi-arabic-shaping-table.h
|
||||
* gen-arabic-shaping-tab.c - generate unicode-arabic-shaping-table.h
|
||||
*
|
||||
* Revised from FriBidi by Vincent Wei for MiniGUI 3.4.0
|
||||
*
|
||||
@@ -37,11 +37,11 @@
|
||||
|
||||
#include "packtab.h"
|
||||
|
||||
#include "../mgbidi.h"
|
||||
#include "mgbidi-unicode-version.h"
|
||||
#include "../unicode-bidi.h"
|
||||
#include "unicode-version.h"
|
||||
|
||||
#define appname "gen-arabic-shaping-tab"
|
||||
#define outputname "mgbidi-arabic-shaping-table.h"
|
||||
#define outputname "unicode-arabic-shaping-table.inc"
|
||||
|
||||
static void
|
||||
die (
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* MGBidi
|
||||
* gen-bidi-type-tab.c - generate mgbidi-bidi-type-table.h
|
||||
* gen-bidi-type-tab.c - generate unicode-bidi-type-table.h
|
||||
*
|
||||
* Revised from FriBidi by Vincent Wei for MiniGUI 3.4.0
|
||||
*
|
||||
@@ -37,11 +37,11 @@
|
||||
|
||||
#include "packtab.h"
|
||||
|
||||
#include "../mgbidi.h"
|
||||
#include "mgbidi-unicode-version.h"
|
||||
#include "../unicode-bidi.h"
|
||||
#include "unicode-version.h"
|
||||
|
||||
#define appname "gen-bidi-type-tab"
|
||||
#define outputname "mgbidi-bidi-type-table.h"
|
||||
#define outputname "unicode-bidi-type-table.h"
|
||||
|
||||
static void
|
||||
die (
|
||||
@@ -81,7 +81,7 @@ enum Char32TypeLinearEnumOffsetOne
|
||||
{
|
||||
# define _MGBIDI_ADD_TYPE(TYPE,SYMBOL) TYPE,
|
||||
# define _MGBIDI_ADD_ALIAS(TYPE1,TYPE2) TYPE1 = TYPE2,
|
||||
# include "../mgbidi-bidi-types-list.inc"
|
||||
# include "../unicode-bidi-types-list.inc"
|
||||
# undef _MGBIDI_ADD_ALIAS
|
||||
# undef _MGBIDI_ADD_TYPE
|
||||
NUM_TYPES
|
||||
@@ -96,7 +96,7 @@ type_names[] =
|
||||
{
|
||||
# define _MGBIDI_ADD_TYPE(TYPE,SYMBOL) {STRINGIZE(TYPE), TYPE},
|
||||
# define _MGBIDI_ADD_ALIAS(TYPE1,TYPE2) _MGBIDI_ADD_TYPE(TYPE1, SYMBOL)
|
||||
# include "../mgbidi-bidi-types-list.inc"
|
||||
# include "../unicode-bidi-types-list.inc"
|
||||
# undef _MGBIDI_ADD_ALIAS
|
||||
# undef _MGBIDI_ADD_TYPE
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* MGBidi
|
||||
* gen-brackets-tab.c - generate mgbidi-brackets-tables.h
|
||||
* gen-brackets-tab.c - generate unicode-bidi-brackets-tables.h
|
||||
*
|
||||
* Revised from FriBidi by Vincent Wei for MiniGUI 3.4.0
|
||||
*
|
||||
@@ -40,11 +40,11 @@
|
||||
|
||||
#include "packtab.h"
|
||||
|
||||
#include "../mgbidi.h"
|
||||
#include "mgbidi-unicode-version.h"
|
||||
#include "../unicode-bidi.h"
|
||||
#include "unicode-version.h"
|
||||
|
||||
#define appname "gen-brackets-tab"
|
||||
#define outputname "mgbidi-brackets-table.h"
|
||||
#define outputname "unicode-bidi-brackets-table.inc"
|
||||
|
||||
static void
|
||||
die (
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* MGBidi
|
||||
* gen-brackets-type-tab.c - generate mgbidi-brackets-type-table.h
|
||||
* gen-brackets-type-tab.c - generate unicode-bidi-brackets-type-table.h
|
||||
*
|
||||
* Revised from FriBidi by Vincent Wei for MiniGUI 3.4.0
|
||||
*
|
||||
@@ -39,11 +39,11 @@
|
||||
|
||||
#include "packtab.h"
|
||||
|
||||
#include "../mgbidi.h"
|
||||
#include "mgbidi-unicode-version.h"
|
||||
#include "../unicode-bidi.h"
|
||||
#include "unicode-version.h"
|
||||
|
||||
#define appname "gen-brackets-type-tab"
|
||||
#define outputname "mgbidi-brackets-type-tablel.h"
|
||||
#define outputname "unicode-bidi-brackets-type-table.inc"
|
||||
|
||||
static void
|
||||
die (
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* MGBidi
|
||||
* gen-joining-type-tab.c - generate mgbidi-joining-type-table.h
|
||||
* gen-joining-type-tab.c - generate unicode-joining-type-table.h
|
||||
*
|
||||
* Revised from FriBidi by Vincent Wei for MiniGUI 3.4.0
|
||||
*
|
||||
@@ -37,11 +37,11 @@
|
||||
|
||||
#include "packtab.h"
|
||||
|
||||
#include "../mgbidi.h"
|
||||
#include "mgbidi-unicode-version.h"
|
||||
#include "../unicode-bidi.h"
|
||||
#include "unicode-version.h"
|
||||
|
||||
#define appname "gen-joining-type-tab"
|
||||
#define outputname "mgbidi-joining-type-table.h"
|
||||
#define outputname "unicode-joining-type-table.h"
|
||||
|
||||
static void
|
||||
die (
|
||||
@@ -93,7 +93,7 @@ die3l (
|
||||
enum FriBidiJoiningLinearEnumOffsetOne
|
||||
{
|
||||
# define _MGBIDI_ADD_TYPE(TYPE,SYMBOL) TYPE,
|
||||
# include "../mgbidi-joining-types-list.inc"
|
||||
# include "../unicode-joining-types-list.inc"
|
||||
# undef _MGBIDI_ADD_TYPE
|
||||
NUM_TYPES
|
||||
};
|
||||
@@ -106,7 +106,7 @@ struct
|
||||
type_names[] =
|
||||
{
|
||||
# define _MGBIDI_ADD_TYPE(TYPE,SYMBOL) {STRINGIZE(TYPE), TYPE},
|
||||
# include "../mgbidi-joining-types-list.inc"
|
||||
# include "../unicode-joining-types-list.inc"
|
||||
# undef _MGBIDI_ADD_TYPE
|
||||
};
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* MGBidi
|
||||
* gen-mirroring-tab.c - generate mgbidi-mirroring-table.h
|
||||
* gen-mirroring-tab.c - generate unicode-bidi-mirroring-table.h
|
||||
*
|
||||
* Revised from FriBidi by Vincent Wei for MiniGUI 3.4.0
|
||||
*
|
||||
@@ -37,11 +37,11 @@
|
||||
|
||||
#include "packtab.h"
|
||||
|
||||
#include "../mgbidi.h"
|
||||
#include "mgbidi-unicode-version.h"
|
||||
#include "../unicode-bidi.h"
|
||||
#include "unicode-version.h"
|
||||
|
||||
#define appname "gen-mirroring-tab"
|
||||
#define outputname "mgbidi-mirroring-table.h"
|
||||
#define outputname "unicode-bidi-mirroring-table.inc"
|
||||
|
||||
static void
|
||||
die (
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/* MGBidi
|
||||
* gen-unicode-version.c - generate mgbidi-unicode-version.h
|
||||
* gen-unicode-version.c - generate unicode-version.h
|
||||
*
|
||||
* Revised from FriBidi by Vincent Wei for MiniGUI 3.4.0
|
||||
*
|
||||
@@ -39,7 +39,7 @@
|
||||
#include "packtab.h"
|
||||
|
||||
#define appname "gen-unicode-version"
|
||||
#define outputname "mgbidi-unicode-version.h"
|
||||
#define outputname "unicode-version.h"
|
||||
|
||||
static void
|
||||
die (
|
||||
|
||||
@@ -101,6 +101,123 @@ void __mg_charset_bidi_get_embeddlevels (const CHARSETOPS* charset_ops,
|
||||
Uint32 __mg_charset_bidi_str_base_dir (const CHARSETOPS* charset_ops,
|
||||
Achar32* achars, int len);
|
||||
|
||||
#ifdef _MGCHARSET_UNICODE
|
||||
|
||||
/**
|
||||
* \fn unicode_bidi_get_paragraph_dir
|
||||
* \brief get base paragraph direction
|
||||
*
|
||||
* This function finds the base direction of a single paragraph,
|
||||
* as defined by rule P2 of the Unicode Bidirectional Algorithm available at
|
||||
* http://www.unicode.org/reports/tr9/#P2.
|
||||
*
|
||||
* You typically do not need this function as
|
||||
* unicode_bidi_get_paragraph_els_ex() knows how to compute base direction
|
||||
* itself, but you may need this to implement a more sophisticated paragraph
|
||||
* direction handling. Note that you can pass more than a paragraph to this
|
||||
* function and the direction of the first non-neutral paragraph is returned,
|
||||
* which is a very good heuristic to set direction of the neutral paragraphs
|
||||
* at the beginning of text. For other neutral paragraphs, you better use the
|
||||
* direction of the previous paragraph.
|
||||
*
|
||||
* \param bidi_types the pointer to the BidiType array as returned by
|
||||
* unicode_bidi_get_bidi_types()
|
||||
* \param len The length of bidi_types
|
||||
*
|
||||
* \return Base pargraph direction. No weak paragraph direction is returned,
|
||||
* only BIDI_PGDIR_LTR, BIDI_PGDIR_RTL, or BIDI_PGDIR_ON.
|
||||
*
|
||||
*/
|
||||
int unicode_bidi_get_paragraph_dir(const BidiType *bidi_types, int len);
|
||||
|
||||
/**
|
||||
* \fn unicode_bidi_get_paragraph_els_ex
|
||||
* \brief Get bidi embedding levels of a paragraph
|
||||
*
|
||||
* 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 I1 inclusive, and parts 1 to 3 of L1.
|
||||
* Part 4 of L1 is implemented in unicode_bidi_reorder_line().
|
||||
*
|
||||
* There are a few macros defined in mgbidi-bidi-types.h to work with this
|
||||
* embedding levels.
|
||||
*
|
||||
* \param bidi_types the pointer to the BidiType array as returned by
|
||||
* unicode_bidi_get_bidi_types()
|
||||
* \param bracket_types The pointer to a Uint8 which contains the
|
||||
bracket types as returned by UCharGetBracketTypes()
|
||||
* \param len The length of the list.
|
||||
* \param base_dir requested and resolved paragraph base direction
|
||||
* \param embedding_levels The pointer to a buffer which will restore
|
||||
* the embedding levels
|
||||
*
|
||||
* \return The Maximum level found plus one, or zero if any error occurred
|
||||
* (memory allocation failure most probably).
|
||||
*/
|
||||
BidiLevel unicode_bidi_get_paragraph_els_ex(const BidiType *bidi_types,
|
||||
const BidiBracketType* bracket_types, int len,
|
||||
int *base_dir, BidiLevel *embedding_levels);
|
||||
|
||||
/**
|
||||
* \fn unicode_bidi_reorder_line
|
||||
* \brief 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 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.
|
||||
*
|
||||
* You should provide the resolved paragraph direction and embedding levels as
|
||||
* set by unicode_bidi_get_paragraph_els_ex(). 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 map later.
|
||||
* The user is responsible to initialize map to something sensible,
|
||||
* like an identity mapping, or pass NULL if no map is needed.
|
||||
*
|
||||
* There is an optional part to this function, which is whether non-spacing
|
||||
* marks for right-to-left parts of the text should be reordered to come after
|
||||
* their base characters in the visual string or not.
|
||||
*
|
||||
* Most rendering engines expect this behavior, but console-based systems
|
||||
* for example do not like it. This is controlled by the
|
||||
* BIDI_FLAG_REORDER_NSM flag. The flag is on in BIDI_FLAGS_DEFAULT.
|
||||
*
|
||||
* \param flags The reorder flags.
|
||||
* \param bidi_types the pointer to the BidiType array as returned by
|
||||
* unicode_bidi_get_bidi_types()
|
||||
* \param bracket_types The pointer to a Uint8 which contains the
|
||||
bracket types as returned by UCharGetBracketTypes()
|
||||
* \param len The length of the list.
|
||||
* \param off The input offset of the beginning of the line in the paragraph.
|
||||
* \param base_dir The resolved paragraph base direction.
|
||||
* \param embedding_levels The embedding levels, as returned by
|
||||
unicode_bidi_get_paragraph_els_ex()
|
||||
* \param visual_str
|
||||
* \param extra The pointer to the extra array to reorder; can be NULL.
|
||||
* \param cb_reverse_extra The callback function to reverse the extra array.
|
||||
* \param map a map of string indices which is reordered to reflect
|
||||
* where each glyph ends up.
|
||||
*
|
||||
* \return Maximum level found in this line plus one, or zero if any error
|
||||
* occurred (memory allocation failure most probably).
|
||||
*/
|
||||
BidiLevel unicode_bidi_reorder_line(Uint32 flags, const BidiType *bidi_types,
|
||||
int len, int off, int base_dir, BidiLevel *embedding_levels,
|
||||
Achar32 *visual_str, int *map,
|
||||
void* extra, CB_REVERSE_EXTRA cb_reverse_extra);
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
Reference in New Issue
Block a user