to get an idea). Alternatively, youe can use the full path to a font
file.
+ To skip changing font family pass null as font family.
+ To skip changing font size pass 0 as font size.
+
See also @.font.get, @.font_source.get.
]]
}
Evas_Object_Protected_Data *obj = efl_data_scope_get(eo_obj, EFL_CANVAS_OBJECT_CLASS);
Evas_Font_Description *fdesc;
- if ((!font) || (size <= 0)) return;
+ if (!font && size <= 0) return;
evas_object_async_block(obj);
if ((size == o->cur.size) &&
(o->cur.font && !strcmp(font, o->cur.font))) return;
- /* We can't assume the given font is same with current fdesc by comparing string.
- Since Evas starts to supporting "auto" for language,
- the given font string should be parsed once before comparing it. */
- fdesc = evas_font_desc_new();
+ if (font)
+ {
+ /* We can't assume the given font is same with current fdesc by comparing string.
+ Since Evas starts to supporting "auto" for language,
+ the given font string should be parsed once before comparing it. */
+ fdesc = evas_font_desc_new();
- /* Set default language according to locale. */
- eina_stringshare_replace(&(fdesc->lang), evas_font_lang_normalize("auto"));
- evas_font_name_parse(fdesc, font);
+ /* Set default language according to locale. */
+ eina_stringshare_replace(&(fdesc->lang), evas_font_lang_normalize("auto"));
+ evas_font_name_parse(fdesc, font);
- if (o->cur.fdesc && !evas_font_desc_cmp(fdesc, o->cur.fdesc) &&
- (size == o->cur.size))
- {
- evas_font_desc_unref(fdesc);
- return;
- }
+ if (o->cur.fdesc && !evas_font_desc_cmp(fdesc, o->cur.fdesc) &&
+ (size == o->cur.size))
+ {
+ evas_font_desc_unref(fdesc);
+ return;
+ }
- if (o->cur.fdesc) evas_font_desc_unref(o->cur.fdesc);
- o->cur.fdesc = fdesc;
+ if (o->cur.fdesc) evas_font_desc_unref(o->cur.fdesc);
+ o->cur.fdesc = fdesc;
+ eina_stringshare_replace(&o->cur.font, font);
+ o->prev.font = NULL;
+ }
- o->cur.size = size;
- eina_stringshare_replace(&o->cur.font, font);
- o->prev.font = NULL;
+ if ( size > 0 )
+ o->cur.size = size;
_evas_text_font_reload(eo_obj, o);
}
Eina_Stringshare *nfont;
- if (o->default_format.info.size != size)
+ if (size > 0 && o->default_format.info.size != size)
{
o->default_format.info.size = size;
changed = EINA_TRUE;
}
- if (o->default_format.info.font != font)
+ if (font && o->default_format.info.font != font)
{
nfont = eina_stringshare_add(font);
if (nfont == _FMT_INFO(font))
}
EFL_END_TEST
+EFL_START_TEST(efl_text_font)
+{
+ START_EFL_CANVAS_TEXT_TEST();
+
+ efl_text_set(txt, "\n\n\n");
+
+ const char * font;
+ int font_size;
+ efl_text_font_set(txt, "Sans", 20);
+ efl_text_font_set(txt, NULL, 0);
+
+ efl_text_font_get(txt, &font, &font_size);
+ fail_if(20 != font_size);
+ fail_if(strcmp(font,"Sans"));
+
+ efl_text_font_set(txt, NULL, 30);
+ efl_text_font_get(txt, &font, &font_size);
+ fail_if(30 != font_size);
+ fail_if(strcmp(font,"Sans"));
+
+ efl_text_font_set(txt, "arial", 0);
+ efl_text_font_get(txt, &font, &font_size);
+ fail_if(30 != font_size);
+ fail_if(strcmp(font,"arial"));
+
+ END_EFL_CANVAS_TEXT_TEST();
+}
+EFL_END_TEST
+
void evas_test_textblock(TCase *tc)
{
tcase_add_test(tc, evas_textblock_simple);
tcase_add_test(tc, efl_text);
tcase_add_test(tc, efl_canvas_text_cursor);
tcase_add_test(tc, efl_canvas_text_markup);
+ tcase_add_test(tc, efl_text_font);
}