summaryrefslogtreecommitdiff
path: root/src/lib/evas
diff options
context:
space:
mode:
authorali <ali198724@gmail.com>2019-07-29 20:18:37 +0000
committerCedric BAIL <cedric.bail@free.fr>2019-07-31 10:54:55 -0700
commit32cffb4494c46fa3705062c8e43294bf8f5eca87 (patch)
treeaf920b99b04ae43933f10f98d5b841523edc80eb /src/lib/evas
parent6d0f51412626b13e495a3eed559880b1266403f7 (diff)
evas_textblock: change font-size/font-family only using EFL.Text.Font Interface
Currently: User cannot change font size only, he needs to set both font and font size with (**efl_text_font_font_set**) To change size only, you need to make two calls, one to get font (**efl_text_font_font_get**) , then pass it again with new size to (**efl_text_font_font_set**). New Behaviour: If user want to change size only, then he passes NULL as font argument to keep same font. If user want to change font only, then he passes 0 as font-size argument, to keep same font-size. Notes: This is not best solution, but it better than current behaviour. I think best solution to have separate function to set font size, but It might break current api or duplicate functions. Reviewed-by: Cedric BAIL <cedric.bail@free.fr> Differential Revision: https://phab.enlightenment.org/D9158
Diffstat (limited to 'src/lib/evas')
-rw-r--r--src/lib/evas/canvas/evas_object_text.c42
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c4
2 files changed, 25 insertions, 21 deletions
diff --git a/src/lib/evas/canvas/evas_object_text.c b/src/lib/evas/canvas/evas_object_text.c
index 40277e2..1f8f340 100644
--- a/src/lib/evas/canvas/evas_object_text.c
+++ b/src/lib/evas/canvas/evas_object_text.c
@@ -455,34 +455,38 @@ _evas_text_efl_text_font_font_set(Eo *eo_obj, Evas_Text_Data *o, const char *fon
455 Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS); 455 Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
456 Evas_Font_Description *fdesc; 456 Evas_Font_Description *fdesc;
457 457
458 if ((!font) || (size <= 0)) return; 458 if (!font && size <= 0) return;
459 459
460 evas_object_async_block(obj); 460 evas_object_async_block(obj);
461 if ((size == o->cur.size) && 461 if ((size == o->cur.size) &&
462 (o->cur.font && !strcmp(font, o->cur.font))) return; 462 (o->cur.font && !strcmp(font, o->cur.font))) return;
463 463
464 /* We can't assume the given font is same with current fdesc by comparing string. 464 if (font)
465 Since Evas starts to supporting "auto" for language, 465 {
466 the given font string should be parsed once before comparing it. */ 466 /* We can't assume the given font is same with current fdesc by comparing string.
467 fdesc = evas_font_desc_new(); 467 Since Evas starts to supporting "auto" for language,
468 the given font string should be parsed once before comparing it. */
469 fdesc = evas_font_desc_new();
468 470
469 /* Set default language according to locale. */ 471 /* Set default language according to locale. */
470 eina_stringshare_replace(&(fdesc->lang), evas_font_lang_normalize("auto")); 472 eina_stringshare_replace(&(fdesc->lang), evas_font_lang_normalize("auto"));
471 evas_font_name_parse(fdesc, font); 473 evas_font_name_parse(fdesc, font);
472 474
473 if (o->cur.fdesc && !evas_font_desc_cmp(fdesc, o->cur.fdesc) && 475 if (o->cur.fdesc && !evas_font_desc_cmp(fdesc, o->cur.fdesc) &&
474 (size == o->cur.size)) 476 (size == o->cur.size))
475 { 477 {
476 evas_font_desc_unref(fdesc); 478 evas_font_desc_unref(fdesc);
477 return; 479 return;
478 } 480 }
479 481
480 if (o->cur.fdesc) evas_font_desc_unref(o->cur.fdesc); 482 if (o->cur.fdesc) evas_font_desc_unref(o->cur.fdesc);
481 o->cur.fdesc = fdesc; 483 o->cur.fdesc = fdesc;
484 eina_stringshare_replace(&o->cur.font, font);
485 o->prev.font = NULL;
486 }
482 487
483 o->cur.size = size; 488 if ( size > 0 )
484 eina_stringshare_replace(&o->cur.font, font); 489 o->cur.size = size;
485 o->prev.font = NULL;
486 490
487 _evas_text_font_reload(eo_obj, o); 491 _evas_text_font_reload(eo_obj, o);
488} 492}
diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c
index 510f6ce..1135527 100644
--- a/src/lib/evas/canvas/evas_object_textblock.c
+++ b/src/lib/evas/canvas/evas_object_textblock.c
@@ -15808,13 +15808,13 @@ _efl_canvas_text_efl_text_font_font_set(Eo *obj EINA_UNUSED, Efl_Canvas_Text_Dat
15808 15808
15809 Eina_Stringshare *nfont; 15809 Eina_Stringshare *nfont;
15810 15810
15811 if (o->default_format.info.size != size) 15811 if (size > 0 && o->default_format.info.size != size)
15812 { 15812 {
15813 o->default_format.info.size = size; 15813 o->default_format.info.size = size;
15814 changed = EINA_TRUE; 15814 changed = EINA_TRUE;
15815 } 15815 }
15816 15816
15817 if (o->default_format.info.font != font) 15817 if (font && o->default_format.info.font != font)
15818 { 15818 {
15819 nfont = eina_stringshare_add(font); 15819 nfont = eina_stringshare_add(font);
15820 if (nfont == _FMT_INFO(font)) 15820 if (nfont == _FMT_INFO(font))