]> git.armaanb.net Git - asd-repo.git/blob - extra/pango/patches/no-fribidi.patch
kiss: switch back to upstream
[asd-repo.git] / extra / pango / patches / no-fribidi.patch
1 diff --git a/meson.build b/meson.build
2 index f542574..d57df3a 100644
3 --- a/meson.build
4 +++ b/meson.build
5 @@ -191,7 +191,6 @@ endif
6  pango_deps = []
7  
8  glib_req_version = '>= 2.62'
9 -fribidi_req_version = '>= 0.19.7'
10  libthai_req_version = '>= 0.1.9'
11  harfbuzz_req_version = '>= 2.0.0'
12  fontconfig_req_version = '>= 2.11.91'
13 @@ -211,11 +210,6 @@ gio_dep = dependency('gio-2.0', version: glib_req_version,
14                           fallback: ['glib', 'libgio_dep'])
15  pango_deps += [glib_dep, gobject_dep, gio_dep]
16  
17 -fribidi_dep = dependency('fribidi', version: fribidi_req_version,
18 -                         fallback: ['fribidi', 'libfribidi_dep'],
19 -                         default_options: ['docs=false'])
20 -pango_deps += fribidi_dep
21 -
22  thai_dep = dependency('libthai', version: libthai_req_version, required: get_option('libthai'))
23  if thai_dep.found()
24    pango_conf.set('HAVE_LIBTHAI', 1)
25 diff --git a/pango/pango-bidi-type.c b/pango/pango-bidi-type.c
26 index a5a13a9..29ddeb8 100644
27 --- a/pango/pango-bidi-type.c
28 +++ b/pango/pango-bidi-type.c
29 @@ -23,16 +23,18 @@
30  
31  #include <string.h>
32  
33 -#include <fribidi.h>
34 -
35  #undef PANGO_DISABLE_DEPRECATED
36  
37  #include "pango-bidi-type.h"
38  #include "pango-utils.h"
39  
40 -#if FRIBIDI_MAJOR_VERSION >= 1
41 -#define USE_FRIBIDI_EX_API
42 -#endif
43 +typedef uint32_t FriBidiChar;
44 +typedef uint32_t FriBidiCharType;
45 +typedef int FriBidiStrIndex;
46 +typedef int FriBidiParType;
47 +typedef signed char FriBidiLevel;
48 +
49 +#define FRIBIDI_PAR_LTR (0x00000010L | 0x00000100L)
50  
51  /**
52   * pango_bidi_type_for_unichar:
53 @@ -52,40 +54,7 @@
54  PangoBidiType
55  pango_bidi_type_for_unichar (gunichar ch)
56  {
57 -  FriBidiCharType fribidi_ch_type;
58 -
59 -  G_STATIC_ASSERT (sizeof (FriBidiChar) == sizeof (gunichar));
60 -
61 -  fribidi_ch_type = fribidi_get_bidi_type (ch);
62 -
63 -  switch (fribidi_ch_type)
64 -    {
65 -    case FRIBIDI_TYPE_LTR:  return PANGO_BIDI_TYPE_L;
66 -    case FRIBIDI_TYPE_LRE:  return PANGO_BIDI_TYPE_LRE;
67 -    case FRIBIDI_TYPE_LRO:  return PANGO_BIDI_TYPE_LRO;
68 -    case FRIBIDI_TYPE_RTL:  return PANGO_BIDI_TYPE_R;
69 -    case FRIBIDI_TYPE_AL:   return PANGO_BIDI_TYPE_AL;
70 -    case FRIBIDI_TYPE_RLE:  return PANGO_BIDI_TYPE_RLE;
71 -    case FRIBIDI_TYPE_RLO:  return PANGO_BIDI_TYPE_RLO;
72 -    case FRIBIDI_TYPE_PDF:  return PANGO_BIDI_TYPE_PDF;
73 -    case FRIBIDI_TYPE_EN:   return PANGO_BIDI_TYPE_EN;
74 -    case FRIBIDI_TYPE_ES:   return PANGO_BIDI_TYPE_ES;
75 -    case FRIBIDI_TYPE_ET:   return PANGO_BIDI_TYPE_ET;
76 -    case FRIBIDI_TYPE_AN:   return PANGO_BIDI_TYPE_AN;
77 -    case FRIBIDI_TYPE_CS:   return PANGO_BIDI_TYPE_CS;
78 -    case FRIBIDI_TYPE_NSM:  return PANGO_BIDI_TYPE_NSM;
79 -    case FRIBIDI_TYPE_BN:   return PANGO_BIDI_TYPE_BN;
80 -    case FRIBIDI_TYPE_BS:   return PANGO_BIDI_TYPE_B;
81 -    case FRIBIDI_TYPE_SS:   return PANGO_BIDI_TYPE_S;
82 -    case FRIBIDI_TYPE_WS:   return PANGO_BIDI_TYPE_WS;
83 -    case FRIBIDI_TYPE_ON:   return PANGO_BIDI_TYPE_ON;
84 -    case FRIBIDI_TYPE_LRI:  return PANGO_BIDI_TYPE_LRI;
85 -    case FRIBIDI_TYPE_RLI:  return PANGO_BIDI_TYPE_RLI;
86 -    case FRIBIDI_TYPE_FSI:  return PANGO_BIDI_TYPE_FSI;
87 -    case FRIBIDI_TYPE_PDI:  return PANGO_BIDI_TYPE_PDI;
88 -    default:
89 -      return PANGO_BIDI_TYPE_ON;
90 -    }
91 +    return PANGO_BIDI_TYPE_L;
92  }
93  
94  /* Some bidi-related functions */
95 @@ -120,38 +89,16 @@ pango_log2vis_get_embedding_levels (const gchar    *text,
96    glong n_chars, i;
97    guint8 *embedding_levels_list;
98    const gchar *p;
99 -  FriBidiParType fribidi_base_dir;
100    FriBidiCharType *bidi_types;
101  #ifdef USE_FRIBIDI_EX_API
102    FriBidiBracketType *bracket_types;
103  #endif
104    FriBidiLevel max_level;
105    FriBidiCharType ored_types = 0;
106 -  FriBidiCharType anded_strongs = FRIBIDI_TYPE_RLE;
107  
108    G_STATIC_ASSERT (sizeof (FriBidiLevel) == sizeof (guint8));
109    G_STATIC_ASSERT (sizeof (FriBidiChar) == sizeof (gunichar));
110  
111 -  switch (*pbase_dir)
112 -    {
113 -    case PANGO_DIRECTION_LTR:
114 -    case PANGO_DIRECTION_TTB_RTL:
115 -      fribidi_base_dir = FRIBIDI_PAR_LTR;
116 -      break;
117 -    case PANGO_DIRECTION_RTL:
118 -    case PANGO_DIRECTION_TTB_LTR:
119 -      fribidi_base_dir = FRIBIDI_PAR_RTL;
120 -      break;
121 -    case PANGO_DIRECTION_WEAK_RTL:
122 -      fribidi_base_dir = FRIBIDI_PAR_WRTL;
123 -      break;
124 -    case PANGO_DIRECTION_WEAK_LTR:
125 -    case PANGO_DIRECTION_NEUTRAL:
126 -    default:
127 -      fribidi_base_dir = FRIBIDI_PAR_WLTR;
128 -      break;
129 -    }
130 -
131    if (length < 0)
132      length = strlen (text);
133  
134 @@ -165,16 +112,13 @@ pango_log2vis_get_embedding_levels (const gchar    *text,
135  
136    for (i = 0, p = text; p < text + length; p = g_utf8_next_char(p), i++)
137      {
138 -      gunichar ch = g_utf8_get_char (p);
139 -      FriBidiCharType char_type = fribidi_get_bidi_type (ch);
140 +      FriBidiCharType char_type = FRIBIDI_PAR_LTR;
141  
142        if (i == n_chars)
143          break;
144  
145        bidi_types[i] = char_type;
146        ored_types |= char_type;
147 -      if (FRIBIDI_IS_STRONG (char_type))
148 -        anded_strongs &= char_type;
149  #ifdef USE_FRIBIDI_EX_API
150        if (G_UNLIKELY(bidi_types[i] == FRIBIDI_TYPE_ON))
151          bracket_types[i] = fribidi_get_bracket (ch);
152 @@ -200,39 +144,8 @@ pango_log2vis_get_embedding_levels (const gchar    *text,
153       * o base_dir doesn't have an RTL taste.
154       * o there are letters, and base_dir is weak.
155       */
156 -    if (!FRIBIDI_IS_ISOLATE (ored_types) &&
157 -       !FRIBIDI_IS_RTL (ored_types) &&
158 -       !FRIBIDI_IS_ARABIC (ored_types) &&
159 -       (!FRIBIDI_IS_RTL (fribidi_base_dir) ||
160 -         (FRIBIDI_IS_WEAK (fribidi_base_dir) &&
161 -          FRIBIDI_IS_LETTER (ored_types))
162 -       ))
163 -      {
164 -        /* all LTR */
165 -       fribidi_base_dir = FRIBIDI_PAR_LTR;
166         memset (embedding_levels_list, 0, n_chars);
167         goto resolved;
168 -      }
169 -    /* The case that all resolved levels will be RTL is much more complex.
170 -     * No isolates, no numbers, all strongs are RTL, and one of
171 -     * the following:
172 -     *
173 -     * o base_dir has an RTL taste (may be weak).
174 -     * o there are letters, and base_dir is weak.
175 -     */
176 -    else if (!FRIBIDI_IS_ISOLATE (ored_types) &&
177 -            !FRIBIDI_IS_NUMBER (ored_types) &&
178 -            FRIBIDI_IS_RTL (anded_strongs) &&
179 -            (FRIBIDI_IS_RTL (fribidi_base_dir) ||
180 -              (FRIBIDI_IS_WEAK (fribidi_base_dir) &&
181 -               FRIBIDI_IS_LETTER (ored_types))
182 -            ))
183 -      {
184 -        /* all RTL */
185 -       fribidi_base_dir = FRIBIDI_PAR_RTL;
186 -       memset (embedding_levels_list, 1, n_chars);
187 -       goto resolved;
188 -      }
189  
190  
191  #ifdef USE_FRIBIDI_EX_API
192 @@ -240,12 +153,10 @@ pango_log2vis_get_embedding_levels (const gchar    *text,
193                                                    &fribidi_base_dir,
194                                                    (FriBidiLevel*)embedding_levels_list);
195  #else
196 -  max_level = fribidi_get_par_embedding_levels (bidi_types, n_chars,
197 -                                               &fribidi_base_dir,
198 -                                               (FriBidiLevel*)embedding_levels_list);
199 +  max_level = 0;
200  #endif
201  
202 -  if (G_UNLIKELY(max_level == 0))
203 +  if (max_level == 0)
204      {
205        /* fribidi_get_par_embedding_levels() failed. */
206        memset (embedding_levels_list, 0, length);
207 @@ -258,7 +169,7 @@ resolved:
208    g_free (bracket_types);
209  #endif
210  
211 -  *pbase_dir = (fribidi_base_dir == FRIBIDI_PAR_LTR) ?  PANGO_DIRECTION_LTR : PANGO_DIRECTION_RTL;
212 +  *pbase_dir = PANGO_DIRECTION_LTR;
213  
214    return embedding_levels_list;
215  }
216 @@ -282,17 +193,6 @@ resolved:
217  PangoDirection
218  pango_unichar_direction (gunichar ch)
219  {
220 -  FriBidiCharType fribidi_ch_type;
221 -
222 -  G_STATIC_ASSERT (sizeof (FriBidiChar) == sizeof (gunichar));
223 -
224 -  fribidi_ch_type = fribidi_get_bidi_type (ch);
225 -
226 -  if (!FRIBIDI_IS_STRONG (fribidi_ch_type))
227 -    return PANGO_DIRECTION_NEUTRAL;
228 -  else if (FRIBIDI_IS_RTL (fribidi_ch_type))
229 -    return PANGO_DIRECTION_RTL;
230 -  else
231      return PANGO_DIRECTION_LTR;
232  }
233