summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/lib/efl/interfaces/efl_text_font.eo3
-rw-r--r--src/lib/evas/canvas/evas_object_text.c42
-rw-r--r--src/lib/evas/canvas/evas_object_textblock.c4
-rw-r--r--src/tests/evas/evas_test_textblock.c30
4 files changed, 58 insertions, 21 deletions
diff --git a/src/lib/efl/interfaces/efl_text_font.eo b/src/lib/efl/interfaces/efl_text_font.eo
index 27d32d6..31ded3e 100644
--- a/src/lib/efl/interfaces/efl_text_font.eo
+++ b/src/lib/efl/interfaces/efl_text_font.eo
@@ -63,6 +63,9 @@ interface @beta Efl.Text_Font {
63 to get an idea). Alternatively, youe can use the full path to a font 63 to get an idea). Alternatively, youe can use the full path to a font
64 file. 64 file.
65 65
66 To skip changing font family pass null as font family.
67 To skip changing font size pass 0 as font size.
68
66 See also @.font.get, @.font_source.get. 69 See also @.font.get, @.font_source.get.
67 ]] 70 ]]
68 } 71 }
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))
diff --git a/src/tests/evas/evas_test_textblock.c b/src/tests/evas/evas_test_textblock.c
index dc3f22d..ef81ae3 100644
--- a/src/tests/evas/evas_test_textblock.c
+++ b/src/tests/evas/evas_test_textblock.c
@@ -4654,6 +4654,35 @@ EFL_START_TEST(efl_canvas_text_markup)
4654} 4654}
4655EFL_END_TEST 4655EFL_END_TEST
4656 4656
4657EFL_START_TEST(efl_text_font)
4658{
4659 START_EFL_CANVAS_TEXT_TEST();
4660
4661 efl_text_set(txt, "\n\n\n");
4662
4663 const char * font;
4664 int font_size;
4665 efl_text_font_set(txt, "Sans", 20);
4666 efl_text_font_set(txt, NULL, 0);
4667
4668 efl_text_font_get(txt, &font, &font_size);
4669 fail_if(20 != font_size);
4670 fail_if(strcmp(font,"Sans"));
4671
4672 efl_text_font_set(txt, NULL, 30);
4673 efl_text_font_get(txt, &font, &font_size);
4674 fail_if(30 != font_size);
4675 fail_if(strcmp(font,"Sans"));
4676
4677 efl_text_font_set(txt, "arial", 0);
4678 efl_text_font_get(txt, &font, &font_size);
4679 fail_if(30 != font_size);
4680 fail_if(strcmp(font,"arial"));
4681
4682 END_EFL_CANVAS_TEXT_TEST();
4683}
4684EFL_END_TEST
4685
4657void evas_test_textblock(TCase *tc) 4686void evas_test_textblock(TCase *tc)
4658{ 4687{
4659 tcase_add_test(tc, evas_textblock_simple); 4688 tcase_add_test(tc, evas_textblock_simple);
@@ -4686,5 +4715,6 @@ void evas_test_textblock(TCase *tc)
4686 tcase_add_test(tc, efl_text); 4715 tcase_add_test(tc, efl_text);
4687 tcase_add_test(tc, efl_canvas_text_cursor); 4716 tcase_add_test(tc, efl_canvas_text_cursor);
4688 tcase_add_test(tc, efl_canvas_text_markup); 4717 tcase_add_test(tc, efl_canvas_text_markup);
4718 tcase_add_test(tc, efl_text_font);
4689} 4719}
4690 4720