diff --git a/src/font/Makefile.am b/src/font/Makefile.am
index a5925f10..f6289c62 100644
--- a/src/font/Makefile.am
+++ b/src/font/Makefile.am
@@ -2,7 +2,7 @@ SUBDIRS = in-core
noinst_LTLIBRARIES = libfont.la
-SRC_FILES = charset.c charset-arabic.c mgbidi.c \
+SRC_FILES = charset.c charset-arabic.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 \
@@ -11,13 +11,15 @@ SRC_FILES = charset.c charset-arabic.c mgbidi.c \
ujisunimap.c sjisunimap.c euckrunimap.c \
textops.c mapunitogb.c mapunitogbk.c mapunitobig5.c mapunitogb18030.c \
bitmapfont.c scripteasy.c \
- unicode-emoji.c
+ unicode-emoji.c \
+ mgbidi.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 mgbidi.h \
- unicode-emoji-tables.h unicode-arabic-shaping-tables.h
+ unicode-decomp.h unicode-comp.h \
+ unicode-emoji-tables.h \
+ mgbidi.h mgbidi-bidi-types-list.h mgbidi-joining-types-list.h
EXTRA_DIST = convgbmap.c jisunimap.c $(SRC_FILES) $(HDR_FILES) \
makefile.ng makefile.msvc
diff --git a/src/font/mgbidi-bidi-types-list.h b/src/font/mgbidi-bidi-types-list.h
new file mode 100644
index 00000000..4e942f42
--- /dev/null
+++ b/src/font/mgbidi-bidi-types-list.h
@@ -0,0 +1,118 @@
+/*
+ * 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 .
+ *
+ * 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
+ * .
+ */
+
+/*
+** mgbidi-bidi-types-list.h:
+**
+** The list of BIDI types
+**
+** Created by WEI Yongming at 2019/03/08
+**
+** This implementation is based on LGPL'd FriBidi:
+**
+** https://github.com/fribidi/fribidi
+**
+** Authors:
+** Behdad Esfahbod, 2001, 2002, 2004
+** Dov Grobgeld, 1999, 2000, 2017
+**
+** Copyright (C) 2004 Sharif FarsiWeb, Inc
+** Copyright (C) 2001,2002 Behdad Esfahbod
+** Copyright (C) 1999,2000,2017 Dov Grobgeld
+*/
+
+#ifndef _MGBIDI_ADD_TYPE
+# define _MGBIDI_ADD_TYPE(x,y)
+#endif
+#ifndef _MGBIDI_ADD_ALIAS
+# define _MGBIDI_ADD_ALIAS(x1,x2)
+#endif
+
+#if !defined(_MGBIDI_PAR_TYPES) || defined(_MGBIDI_ALL_TYPES)
+
+_MGBIDI_ADD_TYPE (LTR, 'L') /* Left-To-Right letter */
+_MGBIDI_ADD_TYPE (RTL, 'R') /* Right-To-Left letter */
+_MGBIDI_ADD_TYPE (AL, 'A') /* Arabic Letter */
+_MGBIDI_ADD_TYPE (EN, '1') /* European Numeral */
+_MGBIDI_ADD_TYPE (AN, '9') /* Arabic Numeral */
+_MGBIDI_ADD_TYPE (ES, 'w') /* European number Separator */
+_MGBIDI_ADD_TYPE (ET, 'w') /* European number Terminator */
+_MGBIDI_ADD_TYPE (CS, 'w') /* Common Separator */
+_MGBIDI_ADD_TYPE (NSM, '`') /* Non Spacing Mark */
+_MGBIDI_ADD_TYPE (BN, 'b') /* Boundary Neutral */
+_MGBIDI_ADD_TYPE (BS, 'B') /* Block Separator */
+_MGBIDI_ADD_TYPE (SS, 'S') /* Segment Separator */
+_MGBIDI_ADD_TYPE (WS, '_') /* WhiteSpace */
+_MGBIDI_ADD_TYPE (ON, 'n') /* Other Neutral */
+_MGBIDI_ADD_TYPE (LRE, '+') /* Left-to-Right Embedding */
+_MGBIDI_ADD_TYPE (RLE, '+') /* Right-to-Left Embedding */
+_MGBIDI_ADD_TYPE (LRO, '+') /* Left-to-Right Override */
+_MGBIDI_ADD_TYPE (RLO, '+') /* Right-to-Left Override */
+_MGBIDI_ADD_TYPE (PDF, '-') /* Pop Directional Flag */
+_MGBIDI_ADD_TYPE (LRI, '+') /* Left-to-Right Isolate */
+_MGBIDI_ADD_TYPE (RLI, '+') /* Right-to-Left Isolate */
+_MGBIDI_ADD_TYPE (FSI, '+') /* First-Strong Isolate */
+_MGBIDI_ADD_TYPE (PDI, '-') /* Pop Directional Isolate */
+
+#if defined(_MGBIDI_ADD_ALIAS)
+_MGBIDI_ADD_ALIAS (L, LTR)
+_MGBIDI_ADD_ALIAS (R, RTL)
+_MGBIDI_ADD_ALIAS (B, BS)
+_MGBIDI_ADD_ALIAS (S, SS)
+#endif /* _MGBIDI_ADD_ALIAS */
+
+#if defined(_MGBIDI_SENTINEL_TYPE) || defined(_MGBIDI_ALL_TYPES)
+_MGBIDI_ADD_TYPE (SENTINEL, '$') /* SENTINEL */
+#endif /* _MGBIDI_SENTINEL_TYPES || _MGBIDI_ALL_TYPES*/
+#endif /* !_MGBIDI_PAR_TYPES || _MGBIDI_ALL_TYPES */
+
+#if defined(_MGBIDI_PAR_TYPES) || defined(_MGBIDI_ALL_TYPES)
+# if !defined(_MGBIDI_ALL_TYPES)
+_MGBIDI_ADD_TYPE (LTR, 'L') /* Left-To-Right paragraph */
+_MGBIDI_ADD_TYPE (RTL, 'R') /* Right-To-Left paragraph */
+_MGBIDI_ADD_TYPE (ON, 'n') /* directiOn-Neutral paragraph */
+# endif /* !_MGBIDI_ALL_TYPES */
+_MGBIDI_ADD_TYPE (WLTR, 'l') /* Weak Left To Right paragraph */
+_MGBIDI_ADD_TYPE (WRTL, 'r') /* Weak Right To Left paragraph */
+#endif /* _MGBIDI_PAR_TYPES || _MGBIDI_ALL_TYPES*/
+
+#if defined(_MGBIDI_ENUM_TYPES)
+typedef enum {
+# define _MGBIDI_ADD_TYPE _MGBIDI_ENUM_ADD_TYPE
+# include "mgbidi-bidi-types-list.h"
+# undef _MGBIDI_ADD_TYPE
+ _MGBIDI_TYPES_MAX
+} _MGBIDI_ENUM_TYPES
+#endif /* _MGBIDI_ENUM_TYPES */
+
diff --git a/src/font/mgbidi-joining-types-list.h b/src/font/mgbidi-joining-types-list.h
new file mode 100644
index 00000000..92d37d09
--- /dev/null
+++ b/src/font/mgbidi-joining-types-list.h
@@ -0,0 +1,57 @@
+/*
+ * 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 .
+ *
+ * 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
+ * .
+ */
+
+/*
+** mgbidi-joining-types-list.h:
+**
+** The list of joining types
+**
+** Created by WEI Yongming at 2019/03/08
+**
+** This implementation is based on LGPL'd FriBidi:
+**
+** https://github.com/fribidi/fribidi
+*/
+
+#ifndef _MGBIDI_ADD_TYPE
+# define _MGBIDI_ADD_TYPE(x,y)
+#endif
+
+_MGBIDI_ADD_TYPE (U, '|') /* nUn-joining, e.g. Full Stop */
+_MGBIDI_ADD_TYPE (R, '<') /* Right-joining, e.g. Arabic Letter Dal */
+_MGBIDI_ADD_TYPE (D, '+') /* Dual-joining, e.g. Arabic Letter Ain */
+_MGBIDI_ADD_TYPE (C, '-') /* join-Causing, e.g. Tatweel, ZWJ */
+_MGBIDI_ADD_TYPE (T, '^') /* Transparent, e.g. Arabic Fatha */
+_MGBIDI_ADD_TYPE (L, '>') /* Left-joining, i.e. fictional */
+_MGBIDI_ADD_TYPE (G, '~') /* iGnored, e.g. LRE, RLE, ZWNBSP */
diff --git a/src/font/mgbidi.c b/src/font/mgbidi.c
index 79f88786..7a11084d 100644
--- a/src/font/mgbidi.c
+++ b/src/font/mgbidi.c
@@ -494,32 +494,7 @@ static const char *gbidi_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
- _BIDI_ADD_TYPE (LTR, 'L') /* Left-To-Right letter */
- _BIDI_ADD_TYPE (RTL, 'R') /* Right-To-Left letter */
- _BIDI_ADD_TYPE (AL, 'A') /* Arabic Letter */
- _BIDI_ADD_TYPE (EN, '1') /* European Numeral */
- _BIDI_ADD_TYPE (AN, '9') /* Arabic Numeral */
- _BIDI_ADD_TYPE (ES, 'w') /* European number Separator */
- _BIDI_ADD_TYPE (ET, 'w') /* European number Terminator */
- _BIDI_ADD_TYPE (CS, 'w') /* Common Separator */
- _BIDI_ADD_TYPE (NSM, '`') /* Non Spacing Mark */
- _BIDI_ADD_TYPE (BN, 'b') /* Boundary Neutral */
- _BIDI_ADD_TYPE (BS, 'B') /* Block Separator */
- _BIDI_ADD_TYPE (SS, 'S') /* Segment Separator */
- _BIDI_ADD_TYPE (WS, '_') /* WhiteSpace */
- _BIDI_ADD_TYPE (ON, 'n') /* Other Neutral */
- _BIDI_ADD_TYPE (LRE, '+') /* Left-to-Right Embedding */
- _BIDI_ADD_TYPE (RLE, '+') /* Right-to-Left Embedding */
- _BIDI_ADD_TYPE (LRO, '+') /* Left-to-Right Override */
- _BIDI_ADD_TYPE (RLO, '+') /* Right-to-Left Override */
- _BIDI_ADD_TYPE (PDF, '-') /* Pop Directional Flag */
- _BIDI_ADD_TYPE (LRI, '+') /* Left-to-Right Isolate */
- _BIDI_ADD_TYPE (RLI, '+') /* Right-to-Left Isolate */
- _BIDI_ADD_TYPE (FSI, '+') /* First-Strong Isolate */
- _BIDI_ADD_TYPE (PDI, '-') /* Pop Directional Isolate */
- _BIDI_ADD_TYPE (WLTR, 'l') /* Weak Left To Right paragraph */
- _BIDI_ADD_TYPE (WRTL, 'r') /* Weak Right To Left paragraph */
- _BIDI_ADD_TYPE (SENTINEL, '$') /* SENTINEL */
+# include "mgbidi-bidi-types-list.h"
# undef _BIDI_ALL_TYPES
# undef _BIDI_ADD_TYPE
default: