summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYoungbok Shin <youngb.shin@samsung.com>2018-04-12 12:55:26 +0300
committerDaniel Hirt <hirt.danny@gmail.com>2018-04-12 12:55:26 +0300
commit4c3646123330086dd6d7508d68b6739826407929 (patch)
tree825fb5a28fa65c734a2fbaecf671e241274580ce
parente4fbab8b4716a801053119f5470caee587043bb2 (diff)
evas: apply fribidi bracket types to show paired bracket properly
Summary: The fribidi couldn't reorganize paired brackets (Ex. '(', ')') when there is RTL + LTR text. According to TR9(http://www.unicode.org/reports/tr9/), it has to be shown properly without LRM or RLM. Also, from the fribidi 1.0.0, fribidi_get_par_embedding_levels() was deprecated. It is replaced with fribidi_get_par_embedding_levels_ex() which is including paired brankets rules from TR9. @feature Test Plan: 1. Create a elm_entry. 2. Set a text by calling text_set. elm_entry_entry_set(entry, "مرحبا Hello (40)"); 3. Run and see the results. - Without this patch or fribidi 1.X.X, it will show text like this... "(Hello (40 مرحبا" - With this patch and fribidi >= 1.0.0 "Hello (40) مرحبا" Reviewers: raster, cedric, herdsman, woohyun Reviewed By: herdsman Differential Revision: https://phab.enlightenment.org/D5921
-rw-r--r--src/lib/evas/common/language/evas_bidi_utils.c70
-rw-r--r--src/lib/evas/common/language/evas_bidi_utils.h3
2 files changed, 62 insertions, 11 deletions
diff --git a/src/lib/evas/common/language/evas_bidi_utils.c b/src/lib/evas/common/language/evas_bidi_utils.c
index fc9a35dd9b..a4653416e7 100644
--- a/src/lib/evas/common/language/evas_bidi_utils.c
+++ b/src/lib/evas/common/language/evas_bidi_utils.c
@@ -234,6 +234,10 @@ evas_bidi_paragraph_props_get(const Eina_Unicode *eina_ustr, size_t len,
234 EvasBiDiLevel *embedding_levels = NULL; 234 EvasBiDiLevel *embedding_levels = NULL;
235 const FriBidiChar *ustr; 235 const FriBidiChar *ustr;
236 FriBidiChar *base_ustr = NULL; 236 FriBidiChar *base_ustr = NULL;
237 EvasBiDiLevel ret_level = 0;
238#if FRIBIDI_MAJOR_VERSION >= 1
239 EvasBiDiBracketType *bracket_types = NULL;
240#endif
237 241
238 if (!eina_ustr) 242 if (!eina_ustr)
239 return NULL; 243 return NULL;
@@ -266,6 +270,15 @@ evas_bidi_paragraph_props_get(const Eina_Unicode *eina_ustr, size_t len,
266 } 270 }
267 fribidi_get_bidi_types(ustr, len, char_types); 271 fribidi_get_bidi_types(ustr, len, char_types);
268 272
273#if FRIBIDI_MAJOR_VERSION >= 1
274 bracket_types = (EvasBiDiBracketType *) malloc(sizeof(EvasBiDiBracketType) * len);
275 if (!bracket_types)
276 {
277 goto cleanup;
278 }
279 fribidi_get_bracket_types(ustr, len, char_types, bracket_types);
280#endif
281
269 embedding_levels = (EvasBiDiLevel *)malloc(sizeof(EvasBiDiLevel) * len); 282 embedding_levels = (EvasBiDiLevel *)malloc(sizeof(EvasBiDiLevel) * len);
270 if (!embedding_levels) 283 if (!embedding_levels)
271 { 284 {
@@ -282,10 +295,19 @@ evas_bidi_paragraph_props_get(const Eina_Unicode *eina_ustr, size_t len,
282 for (itr = segment_idxs ; *itr > 0 ; itr++) 295 for (itr = segment_idxs ; *itr > 0 ; itr++)
283 { 296 {
284 direction = base_bidi; 297 direction = base_bidi;
285 if (!fribidi_get_par_embedding_levels(char_types + pos, 298#if FRIBIDI_MAJOR_VERSION >= 1
286 *itr - pos, 299 ret_level = fribidi_get_par_embedding_levels_ex(char_types + pos,
287 &direction, 300 bracket_types,
288 embedding_levels + pos)) 301 *itr - pos,
302 &direction,
303 embedding_levels + pos);
304#else
305 ret_level = fribidi_get_par_embedding_levels(char_types + pos,
306 *itr - pos,
307 &direction,
308 embedding_levels + pos);
309#endif
310 if (!ret_level)
289 { 311 {
290 goto cleanup; 312 goto cleanup;
291 } 313 }
@@ -308,10 +330,19 @@ evas_bidi_paragraph_props_get(const Eina_Unicode *eina_ustr, size_t len,
308 } 330 }
309 331
310 direction = base_bidi; 332 direction = base_bidi;
311 if (!fribidi_get_par_embedding_levels(char_types + pos, 333#if FRIBIDI_MAJOR_VERSION >= 1
312 len - pos, 334 ret_level = fribidi_get_par_embedding_levels_ex(char_types + pos,
313 &direction, 335 bracket_types,
314 embedding_levels + pos)) 336 len - pos,
337 &direction,
338 embedding_levels + pos);
339#else
340 ret_level = fribidi_get_par_embedding_levels(char_types + pos,
341 len - pos,
342 &direction,
343 embedding_levels + pos);
344#endif
345 if (!ret_level)
315 { 346 {
316 goto cleanup; 347 goto cleanup;
317 } 348 }
@@ -328,8 +359,19 @@ evas_bidi_paragraph_props_get(const Eina_Unicode *eina_ustr, size_t len,
328 } 359 }
329 else 360 else
330 { 361 {
331 if (!fribidi_get_par_embedding_levels(char_types, len, 362#if FRIBIDI_MAJOR_VERSION >= 1
332 &bidi_props->direction, embedding_levels)) 363 ret_level = fribidi_get_par_embedding_levels_ex(char_types,
364 bracket_types,
365 len,
366 &bidi_props->direction,
367 embedding_levels);
368#else
369 ret_level = fribidi_get_par_embedding_levels(char_types,
370 len,
371 &bidi_props->direction,
372 embedding_levels);
373#endif
374 if (!ret_level)
333 { 375 {
334 goto cleanup; 376 goto cleanup;
335 } 377 }
@@ -352,13 +394,19 @@ evas_bidi_paragraph_props_get(const Eina_Unicode *eina_ustr, size_t len,
352 bidi_props->char_types = char_types; 394 bidi_props->char_types = char_types;
353 395
354 if (base_ustr) free(base_ustr); 396 if (base_ustr) free(base_ustr);
355 397#if FRIBIDI_MAJOR_VERSION >= 1
398 /* Currently, bracket_types is not reused in other places. */
399 if (bracket_types) free(bracket_types);
400#endif
356 401
357 return bidi_props; 402 return bidi_props;
358 403
359/* Cleanup */ 404/* Cleanup */
360cleanup: 405cleanup:
361 if (char_types) free(char_types); 406 if (char_types) free(char_types);
407#if FRIBIDI_MAJOR_VERSION >= 1
408 if (bracket_types) free(bracket_types);
409#endif
362 if (embedding_levels) free(embedding_levels); 410 if (embedding_levels) free(embedding_levels);
363 if (base_ustr) free(base_ustr); 411 if (base_ustr) free(base_ustr);
364 if (bidi_props) evas_bidi_paragraph_props_unref(bidi_props); /* Clean up the bidi props */ 412 if (bidi_props) evas_bidi_paragraph_props_unref(bidi_props); /* Clean up the bidi props */
diff --git a/src/lib/evas/common/language/evas_bidi_utils.h b/src/lib/evas/common/language/evas_bidi_utils.h
index dfccec8166..9b4ea68d64 100644
--- a/src/lib/evas/common/language/evas_bidi_utils.h
+++ b/src/lib/evas/common/language/evas_bidi_utils.h
@@ -56,6 +56,9 @@ _EVAS_BIDI_TYPEDEF(ParType);
56_EVAS_BIDI_TYPEDEF(StrIndex); 56_EVAS_BIDI_TYPEDEF(StrIndex);
57_EVAS_BIDI_TYPEDEF(Level); 57_EVAS_BIDI_TYPEDEF(Level);
58_EVAS_BIDI_TYPEDEF(JoiningType); 58_EVAS_BIDI_TYPEDEF(JoiningType);
59#if FRIBIDI_MAJOR_VERSION >= 1
60_EVAS_BIDI_TYPEDEF(BracketType);
61#endif
59 62
60typedef struct _Evas_BiDi_Paragraph_Props Evas_BiDi_Paragraph_Props; 63typedef struct _Evas_BiDi_Paragraph_Props Evas_BiDi_Paragraph_Props;
61typedef struct _Evas_BiDi_Props Evas_BiDi_Props; 64typedef struct _Evas_BiDi_Props Evas_BiDi_Props;