2021-07-07 10:03:50 -06:00
|
|
|
diff --git a/meson.build b/meson.build
|
2023-02-20 16:46:02 -07:00
|
|
|
index 50ec14b..f45dd6a 100644
|
2021-07-07 10:03:50 -06:00
|
|
|
--- a/meson.build
|
|
|
|
+++ b/meson.build
|
2023-02-20 16:46:02 -07:00
|
|
|
@@ -200,7 +200,6 @@ endif
|
2021-07-07 10:03:50 -06:00
|
|
|
pango_deps = []
|
2021-08-18 06:04:08 -06:00
|
|
|
|
2021-07-07 10:03:50 -06:00
|
|
|
glib_req_version = '>= 2.62'
|
2021-08-18 06:04:08 -06:00
|
|
|
-fribidi_req_version = '>= 1.0.6'
|
2021-07-07 10:03:50 -06:00
|
|
|
libthai_req_version = '>= 0.1.9'
|
2021-12-04 03:51:28 -07:00
|
|
|
harfbuzz_req_version = '>= 2.6.0'
|
|
|
|
fontconfig_req_version = '>= 2.13.0'
|
2023-02-20 16:46:02 -07:00
|
|
|
@@ -217,10 +216,6 @@ gobject_dep = dependency('gobject-2.0', version: glib_req_version)
|
|
|
|
gio_dep = dependency('gio-2.0', version: glib_req_version)
|
2021-07-07 10:03:50 -06:00
|
|
|
pango_deps += [glib_dep, gobject_dep, gio_dep]
|
2021-08-18 06:04:08 -06:00
|
|
|
|
2021-07-07 10:03:50 -06:00
|
|
|
-fribidi_dep = dependency('fribidi', version: fribidi_req_version,
|
|
|
|
- default_options: ['docs=false'])
|
|
|
|
-pango_deps += fribidi_dep
|
2023-02-20 16:46:02 -07:00
|
|
|
-
|
2021-07-07 10:03:50 -06:00
|
|
|
thai_dep = dependency('libthai', version: libthai_req_version, required: get_option('libthai'))
|
|
|
|
if thai_dep.found()
|
2023-02-20 16:46:02 -07:00
|
|
|
pango_conf.set('HAVE_LIBTHAI', 1)
|
2021-07-07 10:03:50 -06:00
|
|
|
diff --git a/pango/pango-bidi-type.c b/pango/pango-bidi-type.c
|
2023-02-20 16:46:02 -07:00
|
|
|
index 4277dc1..73d3476 100644
|
2021-07-07 10:03:50 -06:00
|
|
|
--- a/pango/pango-bidi-type.c
|
|
|
|
+++ b/pango/pango-bidi-type.c
|
2023-02-20 16:46:02 -07:00
|
|
|
@@ -23,14 +23,21 @@
|
2021-08-18 06:04:08 -06:00
|
|
|
|
2021-07-07 10:03:50 -06:00
|
|
|
#include <string.h>
|
2021-08-18 06:04:08 -06:00
|
|
|
|
2021-08-18 07:51:13 -06:00
|
|
|
-#include <fribidi.h>
|
2023-02-20 16:46:02 -07:00
|
|
|
-
|
2021-07-07 10:03:50 -06:00
|
|
|
#undef PANGO_DISABLE_DEPRECATED
|
2021-08-18 06:04:08 -06:00
|
|
|
|
2021-08-18 07:51:13 -06:00
|
|
|
#include "pango-bidi-type.h"
|
|
|
|
#include "pango-utils.h"
|
2023-02-20 16:46:02 -07:00
|
|
|
#include "pango-utils-private.h"
|
2021-08-18 07:51:13 -06:00
|
|
|
|
2021-07-07 10:03:50 -06:00
|
|
|
+typedef uint32_t FriBidiChar;
|
|
|
|
+typedef uint32_t FriBidiCharType;
|
2021-08-18 06:04:08 -06:00
|
|
|
+typedef uint32_t FriBidiBracketType;
|
2021-07-07 10:03:50 -06:00
|
|
|
+typedef int FriBidiStrIndex;
|
|
|
|
+typedef int FriBidiParType;
|
|
|
|
+typedef signed char FriBidiLevel;
|
|
|
|
+
|
|
|
|
+#define FRIBIDI_PAR_LTR (0x00000010L | 0x00000100L)
|
2021-08-18 06:04:08 -06:00
|
|
|
+
|
2021-08-18 07:51:13 -06:00
|
|
|
/**
|
|
|
|
* pango_bidi_type_for_unichar:
|
|
|
|
* @ch: a Unicode character
|
2023-02-20 16:46:02 -07:00
|
|
|
@@ -49,41 +56,7 @@
|
2021-07-07 10:03:50 -06:00
|
|
|
PangoBidiType
|
|
|
|
pango_bidi_type_for_unichar (gunichar ch)
|
|
|
|
{
|
|
|
|
- FriBidiCharType fribidi_ch_type;
|
|
|
|
-
|
|
|
|
- G_STATIC_ASSERT (sizeof (FriBidiChar) == sizeof (gunichar));
|
|
|
|
-
|
|
|
|
- fribidi_ch_type = fribidi_get_bidi_type (ch);
|
|
|
|
-
|
|
|
|
- switch (fribidi_ch_type)
|
|
|
|
- {
|
|
|
|
- case FRIBIDI_TYPE_LTR: return PANGO_BIDI_TYPE_L;
|
|
|
|
- case FRIBIDI_TYPE_LRE: return PANGO_BIDI_TYPE_LRE;
|
|
|
|
- case FRIBIDI_TYPE_LRO: return PANGO_BIDI_TYPE_LRO;
|
|
|
|
- case FRIBIDI_TYPE_RTL: return PANGO_BIDI_TYPE_R;
|
|
|
|
- case FRIBIDI_TYPE_AL: return PANGO_BIDI_TYPE_AL;
|
|
|
|
- case FRIBIDI_TYPE_RLE: return PANGO_BIDI_TYPE_RLE;
|
|
|
|
- case FRIBIDI_TYPE_RLO: return PANGO_BIDI_TYPE_RLO;
|
|
|
|
- case FRIBIDI_TYPE_PDF: return PANGO_BIDI_TYPE_PDF;
|
|
|
|
- case FRIBIDI_TYPE_EN: return PANGO_BIDI_TYPE_EN;
|
|
|
|
- case FRIBIDI_TYPE_ES: return PANGO_BIDI_TYPE_ES;
|
|
|
|
- case FRIBIDI_TYPE_ET: return PANGO_BIDI_TYPE_ET;
|
|
|
|
- case FRIBIDI_TYPE_AN: return PANGO_BIDI_TYPE_AN;
|
|
|
|
- case FRIBIDI_TYPE_CS: return PANGO_BIDI_TYPE_CS;
|
|
|
|
- case FRIBIDI_TYPE_NSM: return PANGO_BIDI_TYPE_NSM;
|
|
|
|
- case FRIBIDI_TYPE_BN: return PANGO_BIDI_TYPE_BN;
|
|
|
|
- case FRIBIDI_TYPE_BS: return PANGO_BIDI_TYPE_B;
|
|
|
|
- case FRIBIDI_TYPE_SS: return PANGO_BIDI_TYPE_S;
|
|
|
|
- case FRIBIDI_TYPE_WS: return PANGO_BIDI_TYPE_WS;
|
|
|
|
- case FRIBIDI_TYPE_ON: return PANGO_BIDI_TYPE_ON;
|
|
|
|
- case FRIBIDI_TYPE_LRI: return PANGO_BIDI_TYPE_LRI;
|
|
|
|
- case FRIBIDI_TYPE_RLI: return PANGO_BIDI_TYPE_RLI;
|
|
|
|
- case FRIBIDI_TYPE_FSI: return PANGO_BIDI_TYPE_FSI;
|
|
|
|
- case FRIBIDI_TYPE_PDI: return PANGO_BIDI_TYPE_PDI;
|
2021-12-04 03:51:28 -07:00
|
|
|
- case _FRIBIDI_TYPE_SENTINEL:
|
2021-07-07 10:03:50 -06:00
|
|
|
- default:
|
|
|
|
- return PANGO_BIDI_TYPE_ON;
|
|
|
|
- }
|
2021-12-04 03:51:28 -07:00
|
|
|
+ return PANGO_BIDI_TYPE_L;
|
2021-07-07 10:03:50 -06:00
|
|
|
}
|
2021-08-18 06:04:08 -06:00
|
|
|
|
2021-07-07 10:03:50 -06:00
|
|
|
/* Some bidi-related functions */
|
2023-02-20 16:46:02 -07:00
|
|
|
@@ -136,38 +109,14 @@ pango_log2vis_fill_embedding_levels (const gchar *text,
|
|
|
|
{
|
|
|
|
glong i;
|
2021-07-07 10:03:50 -06:00
|
|
|
const gchar *p;
|
|
|
|
- FriBidiParType fribidi_base_dir;
|
|
|
|
FriBidiCharType *bidi_types;
|
2023-02-20 16:46:02 -07:00
|
|
|
FriBidiCharType bidi_types_[64];
|
2021-07-07 10:03:50 -06:00
|
|
|
FriBidiBracketType *bracket_types;
|
2023-02-20 16:46:02 -07:00
|
|
|
FriBidiBracketType bracket_types_[64];
|
2021-10-02 08:39:41 -06:00
|
|
|
- FriBidiLevel max_level;
|
|
|
|
- FriBidiCharType ored_types = 0;
|
2021-07-07 10:03:50 -06:00
|
|
|
- FriBidiCharType anded_strongs = FRIBIDI_TYPE_RLE;
|
2021-08-18 06:04:08 -06:00
|
|
|
|
2021-07-07 10:03:50 -06:00
|
|
|
G_STATIC_ASSERT (sizeof (FriBidiLevel) == sizeof (guint8));
|
|
|
|
G_STATIC_ASSERT (sizeof (FriBidiChar) == sizeof (gunichar));
|
2021-08-18 06:04:08 -06:00
|
|
|
|
2021-07-07 10:03:50 -06:00
|
|
|
- switch (*pbase_dir)
|
|
|
|
- {
|
|
|
|
- case PANGO_DIRECTION_LTR:
|
|
|
|
- case PANGO_DIRECTION_TTB_RTL:
|
|
|
|
- fribidi_base_dir = FRIBIDI_PAR_LTR;
|
|
|
|
- break;
|
|
|
|
- case PANGO_DIRECTION_RTL:
|
|
|
|
- case PANGO_DIRECTION_TTB_LTR:
|
|
|
|
- fribidi_base_dir = FRIBIDI_PAR_RTL;
|
|
|
|
- break;
|
|
|
|
- case PANGO_DIRECTION_WEAK_RTL:
|
|
|
|
- fribidi_base_dir = FRIBIDI_PAR_WRTL;
|
|
|
|
- break;
|
|
|
|
- case PANGO_DIRECTION_WEAK_LTR:
|
|
|
|
- case PANGO_DIRECTION_NEUTRAL:
|
|
|
|
- default:
|
|
|
|
- fribidi_base_dir = FRIBIDI_PAR_WLTR;
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
-
|
2023-02-20 16:46:02 -07:00
|
|
|
if (n_chars < 64)
|
|
|
|
{
|
|
|
|
bidi_types = bidi_types_;
|
|
|
|
@@ -181,20 +130,11 @@ pango_log2vis_fill_embedding_levels (const gchar *text,
|
2021-08-18 06:04:08 -06:00
|
|
|
|
2021-07-07 10:03:50 -06:00
|
|
|
for (i = 0, p = text; p < text + length; p = g_utf8_next_char(p), i++)
|
|
|
|
{
|
|
|
|
- gunichar ch = g_utf8_get_char (p);
|
|
|
|
- FriBidiCharType char_type = fribidi_get_bidi_type (ch);
|
2021-08-18 07:51:13 -06:00
|
|
|
-
|
2021-07-07 10:03:50 -06:00
|
|
|
if (i == n_chars)
|
|
|
|
break;
|
2021-08-18 06:04:08 -06:00
|
|
|
|
2021-08-18 07:51:13 -06:00
|
|
|
- bidi_types[i] = char_type;
|
|
|
|
- ored_types |= char_type;
|
2021-07-07 10:03:50 -06:00
|
|
|
- if (FRIBIDI_IS_STRONG (char_type))
|
|
|
|
- anded_strongs &= char_type;
|
2021-08-18 06:04:08 -06:00
|
|
|
- if (G_UNLIKELY(bidi_types[i] == FRIBIDI_TYPE_ON))
|
|
|
|
- bracket_types[i] = fribidi_get_bracket (ch);
|
|
|
|
- else
|
|
|
|
- bracket_types[i] = FRIBIDI_NO_BRACKET;
|
2021-08-18 07:51:13 -06:00
|
|
|
+ bidi_types[i] = FRIBIDI_PAR_LTR;
|
2021-08-18 06:04:08 -06:00
|
|
|
+ bracket_types[i] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Short-circuit (malloc-expensive) FriBidi call for unidirectional
|
2023-02-20 16:46:02 -07:00
|
|
|
@@ -211,59 +151,14 @@ pango_log2vis_fill_embedding_levels (const gchar *text,
|
2021-07-07 10:03:50 -06:00
|
|
|
* o base_dir doesn't have an RTL taste.
|
|
|
|
* o there are letters, and base_dir is weak.
|
|
|
|
*/
|
|
|
|
- if (!FRIBIDI_IS_ISOLATE (ored_types) &&
|
|
|
|
- !FRIBIDI_IS_RTL (ored_types) &&
|
|
|
|
- !FRIBIDI_IS_ARABIC (ored_types) &&
|
|
|
|
- (!FRIBIDI_IS_RTL (fribidi_base_dir) ||
|
|
|
|
- (FRIBIDI_IS_WEAK (fribidi_base_dir) &&
|
|
|
|
- FRIBIDI_IS_LETTER (ored_types))
|
|
|
|
- ))
|
|
|
|
- {
|
|
|
|
- /* all LTR */
|
|
|
|
- fribidi_base_dir = FRIBIDI_PAR_LTR;
|
2021-08-18 07:51:13 -06:00
|
|
|
memset (embedding_levels_list, 0, n_chars);
|
2021-08-18 06:04:08 -06:00
|
|
|
- goto resolved;
|
2021-07-07 10:03:50 -06:00
|
|
|
- }
|
|
|
|
- /* The case that all resolved levels will be RTL is much more complex.
|
|
|
|
- * No isolates, no numbers, all strongs are RTL, and one of
|
|
|
|
- * the following:
|
|
|
|
- *
|
|
|
|
- * o base_dir has an RTL taste (may be weak).
|
|
|
|
- * o there are letters, and base_dir is weak.
|
|
|
|
- */
|
|
|
|
- else if (!FRIBIDI_IS_ISOLATE (ored_types) &&
|
|
|
|
- !FRIBIDI_IS_NUMBER (ored_types) &&
|
|
|
|
- FRIBIDI_IS_RTL (anded_strongs) &&
|
|
|
|
- (FRIBIDI_IS_RTL (fribidi_base_dir) ||
|
|
|
|
- (FRIBIDI_IS_WEAK (fribidi_base_dir) &&
|
|
|
|
- FRIBIDI_IS_LETTER (ored_types))
|
|
|
|
- ))
|
|
|
|
- {
|
|
|
|
- /* all RTL */
|
|
|
|
- fribidi_base_dir = FRIBIDI_PAR_RTL;
|
|
|
|
- memset (embedding_levels_list, 1, n_chars);
|
|
|
|
- goto resolved;
|
|
|
|
- }
|
2021-08-18 06:04:08 -06:00
|
|
|
-
|
|
|
|
-
|
|
|
|
- max_level = fribidi_get_par_embedding_levels_ex (bidi_types, bracket_types, n_chars,
|
|
|
|
- &fribidi_base_dir,
|
|
|
|
- (FriBidiLevel*)embedding_levels_list);
|
|
|
|
-
|
2021-07-07 10:03:50 -06:00
|
|
|
- if (G_UNLIKELY(max_level == 0))
|
2021-08-18 06:04:08 -06:00
|
|
|
- {
|
|
|
|
- /* fribidi_get_par_embedding_levels() failed. */
|
|
|
|
- memset (embedding_levels_list, 0, length);
|
|
|
|
- }
|
2021-12-04 03:51:28 -07:00
|
|
|
-
|
2021-10-02 08:39:41 -06:00
|
|
|
-resolved:
|
2023-02-20 16:46:02 -07:00
|
|
|
if (n_chars >= 64)
|
|
|
|
{
|
|
|
|
g_free (bidi_types);
|
|
|
|
g_free (bracket_types);
|
|
|
|
}
|
2021-08-18 06:04:08 -06:00
|
|
|
|
2021-07-07 10:03:50 -06:00
|
|
|
- *pbase_dir = (fribidi_base_dir == FRIBIDI_PAR_LTR) ? PANGO_DIRECTION_LTR : PANGO_DIRECTION_RTL;
|
|
|
|
+ *pbase_dir = PANGO_DIRECTION_LTR;
|
|
|
|
}
|
2023-02-20 16:46:02 -07:00
|
|
|
|
|
|
|
/**
|
|
|
|
@@ -285,18 +180,7 @@ resolved:
|
2021-07-07 10:03:50 -06:00
|
|
|
PangoDirection
|
|
|
|
pango_unichar_direction (gunichar ch)
|
|
|
|
{
|
|
|
|
- FriBidiCharType fribidi_ch_type;
|
|
|
|
-
|
|
|
|
- G_STATIC_ASSERT (sizeof (FriBidiChar) == sizeof (gunichar));
|
|
|
|
-
|
|
|
|
- fribidi_ch_type = fribidi_get_bidi_type (ch);
|
|
|
|
-
|
|
|
|
- if (!FRIBIDI_IS_STRONG (fribidi_ch_type))
|
|
|
|
- return PANGO_DIRECTION_NEUTRAL;
|
|
|
|
- else if (FRIBIDI_IS_RTL (fribidi_ch_type))
|
|
|
|
- return PANGO_DIRECTION_RTL;
|
|
|
|
- else
|
2023-02-20 16:46:02 -07:00
|
|
|
- return PANGO_DIRECTION_LTR;
|
|
|
|
+ return PANGO_DIRECTION_LTR;
|
2021-07-07 10:03:50 -06:00
|
|
|
}
|
2021-08-18 06:04:08 -06:00
|
|
|
|
2023-02-20 16:46:02 -07:00
|
|
|
|