summaryrefslogtreecommitdiff
path: root/src/lib/evas/common
diff options
context:
space:
mode:
authorYoungbok Shin <youngb.shin@samsung.com>2015-11-19 11:37:07 +0000
committerTom Hacohen <tom@stosb.com>2015-11-19 11:43:39 +0000
commita9b4be11e1e7525d98c08a5bb04b1f29ea8b0d4f (patch)
treec35b457299d4fc6d71a3144f957eae774fd656d8 /src/lib/evas/common
parent618558f8ecba4d78f230245f2853523e95e12dfc (diff)
Evas object: Add paragraph_direciton APIs
Summary: It adds evas_object_paragraph_direction_set, get APIs. The APIs set or get paragraph direction to/from the given object. It changes BiDi calculations and affect the direction and aligning of text. It doesn't have any effect to text without Fribidi library. The default paragraph direction is EVAS_BIDI_DIRECTION_INHERIT. If dir is EVAS_BIDI_DIRECTION_INHERIT, paragraph direction is changed according to smart parent object. If there is no smart parent object, paragraph direction works as EVAS_BIDI_DIRECTION_NEUTRAL. @feature Test Plan: Test cases included to the following files. - evas_test_textblock.c - evas_test_text.c - evas_test_object_smart.c Run "make check". Reviewers: woohyun, raster, herdsman, tasn Subscribers: c, raster, cedric Differential Revision: https://phab.enlightenment.org/D1690
Diffstat (limited to 'src/lib/evas/common')
-rw-r--r--src/lib/evas/common/language/evas_bidi_utils.c13
-rw-r--r--src/lib/evas/common/language/evas_bidi_utils.h2
2 files changed, 9 insertions, 6 deletions
diff --git a/src/lib/evas/common/language/evas_bidi_utils.c b/src/lib/evas/common/language/evas_bidi_utils.c
index e3ae361..f04c825 100644
--- a/src/lib/evas/common/language/evas_bidi_utils.c
+++ b/src/lib/evas/common/language/evas_bidi_utils.c
@@ -222,11 +222,12 @@ evas_bidi_segment_idxs_get(const Eina_Unicode *str, const char *delim)
222 * @param ustr The string to update according to. 222 * @param ustr The string to update according to.
223 * @param len The length of the string 223 * @param len The length of the string
224 * @param segment_idxs A -1 terminated array of points to start a new bidi analysis at (used for section high level bidi overrides). - NULL means none. 224 * @param segment_idxs A -1 terminated array of points to start a new bidi analysis at (used for section high level bidi overrides). - NULL means none.
225 * @param base_bidi The base BiDi direction of paragraph.
225 * @return returns allocated paragraph props on success, NULL otherwise. 226 * @return returns allocated paragraph props on success, NULL otherwise.
226 */ 227 */
227Evas_BiDi_Paragraph_Props * 228Evas_BiDi_Paragraph_Props *
228evas_bidi_paragraph_props_get(const Eina_Unicode *eina_ustr, size_t len, 229evas_bidi_paragraph_props_get(const Eina_Unicode *eina_ustr, size_t len,
229 int *segment_idxs) 230 int *segment_idxs, EvasBiDiParType base_bidi)
230{ 231{
231 Evas_BiDi_Paragraph_Props *bidi_props = NULL; 232 Evas_BiDi_Paragraph_Props *bidi_props = NULL;
232 EvasBiDiCharType *char_types = NULL; 233 EvasBiDiCharType *char_types = NULL;
@@ -237,8 +238,9 @@ evas_bidi_paragraph_props_get(const Eina_Unicode *eina_ustr, size_t len,
237 if (!eina_ustr) 238 if (!eina_ustr)
238 return NULL; 239 return NULL;
239 240
240 241 /* No need to handle bidi */
241 if (!evas_bidi_is_rtl_str(eina_ustr)) /* No need to handle bidi */ 242 if (!evas_bidi_is_rtl_str(eina_ustr) &&
243 (base_bidi != EVAS_BIDI_PARAGRAPH_RTL))
242 { 244 {
243 len = -1; 245 len = -1;
244 goto cleanup; 246 goto cleanup;
@@ -255,6 +257,7 @@ evas_bidi_paragraph_props_get(const Eina_Unicode *eina_ustr, size_t len,
255#endif 257#endif
256 258
257 bidi_props = evas_bidi_paragraph_props_new(); 259 bidi_props = evas_bidi_paragraph_props_new();
260 bidi_props->direction = base_bidi;
258 261
259 /* Prep work for reordering */ 262 /* Prep work for reordering */
260 char_types = (EvasBiDiCharType *) malloc(sizeof(EvasBiDiCharType) * len); 263 char_types = (EvasBiDiCharType *) malloc(sizeof(EvasBiDiCharType) * len);
@@ -281,7 +284,7 @@ evas_bidi_paragraph_props_get(const Eina_Unicode *eina_ustr, size_t len,
281 284
282 for (itr = segment_idxs ; *itr > 0 ; itr++) 285 for (itr = segment_idxs ; *itr > 0 ; itr++)
283 { 286 {
284 direction = EVAS_BIDI_PARAGRAPH_NEUTRAL; 287 direction = base_bidi;
285 if (!fribidi_get_par_embedding_levels(char_types + pos, 288 if (!fribidi_get_par_embedding_levels(char_types + pos,
286 *itr - pos, 289 *itr - pos,
287 &direction, 290 &direction,
@@ -308,7 +311,7 @@ evas_bidi_paragraph_props_get(const Eina_Unicode *eina_ustr, size_t len,
308 pos = *itr + 1; 311 pos = *itr + 1;
309 } 312 }
310 313
311 direction = EVAS_BIDI_PARAGRAPH_NEUTRAL; 314 direction = base_bidi;
312 if (!fribidi_get_par_embedding_levels(char_types + pos, 315 if (!fribidi_get_par_embedding_levels(char_types + pos,
313 len - pos, 316 len - pos,
314 &direction, 317 &direction,
diff --git a/src/lib/evas/common/language/evas_bidi_utils.h b/src/lib/evas/common/language/evas_bidi_utils.h
index 37a4e65..dfccec8 100644
--- a/src/lib/evas/common/language/evas_bidi_utils.h
+++ b/src/lib/evas/common/language/evas_bidi_utils.h
@@ -143,7 +143,7 @@ Eina_Bool
143evas_bidi_props_reorder_line(Eina_Unicode *eina_ustr, size_t start, size_t len, const Evas_BiDi_Paragraph_Props *props, EvasBiDiStrIndex **_v_to_l); 143evas_bidi_props_reorder_line(Eina_Unicode *eina_ustr, size_t start, size_t len, const Evas_BiDi_Paragraph_Props *props, EvasBiDiStrIndex **_v_to_l);
144 144
145Evas_BiDi_Paragraph_Props * 145Evas_BiDi_Paragraph_Props *
146evas_bidi_paragraph_props_get(const Eina_Unicode *eina_ustr, size_t len, int *segment_idxs) EINA_ARG_NONNULL(1) EINA_MALLOC EINA_WARN_UNUSED_RESULT; 146evas_bidi_paragraph_props_get(const Eina_Unicode *eina_ustr, size_t len, int *segment_idxs, EvasBiDiParType base_bidi) EINA_ARG_NONNULL(1) EINA_MALLOC EINA_WARN_UNUSED_RESULT;
147 147
148void 148void
149evas_bidi_props_copy_and_ref(const Evas_BiDi_Props *src, Evas_BiDi_Props *dst); 149evas_bidi_props_copy_and_ref(const Evas_BiDi_Props *src, Evas_BiDi_Props *dst);