diff options
author | Youngbok Shin <youngb.shin@samsung.com> | 2016-01-26 10:48:42 +0000 |
---|---|---|
committer | Tom Hacohen <tom@stosb.com> | 2016-02-02 10:22:09 +0000 |
commit | d15d91e0da48fc589a6e38dfb9f8bca35846de70 (patch) | |
tree | 4b3a55bf009f7746cf381eb88c4b301daf0ca9be /src/lib/evas | |
parent | 6b12ae1e03e93a10b0120aa15d1ff40b022ec189 (diff) | |
download | efl-d15d91e0da48fc589a6e38dfb9f8bca35846de70.tar.gz |
Evas Text/Textblock: Use locale for lang as default.
Summary:
The configuration files for Fontconfig can describe
how font list is made according to language information.
EFL also set the language for each Evas textblock styles
and used for loading font list.
But, this is inconvenient to use if we want to apply language
for loading font list according to system-wide locale information.
This patch will apply locale information for font list if there is
no specific language in description.
And it also add [lang=auto] for Evas Textblock.
auto - It loads locale for language.
none - It disables language.
@feature
Test Plan: N/A
Reviewers: woohyun, herdsman, tasn
Subscribers: jpeg, cedric
Differential Revision: https://phab.enlightenment.org/D3344
Diffstat (limited to 'src/lib/evas')
-rw-r--r-- | src/lib/evas/canvas/evas_font_dir.c | 12 | ||||
-rw-r--r-- | src/lib/evas/canvas/evas_object_text.c | 3 | ||||
-rw-r--r-- | src/lib/evas/canvas/evas_object_textblock.c | 10 | ||||
-rw-r--r-- | src/lib/evas/include/evas_private.h | 1 |
4 files changed, 25 insertions, 1 deletions
diff --git a/src/lib/evas/canvas/evas_font_dir.c b/src/lib/evas/canvas/evas_font_dir.c index ffb4423fde..d357ce87fe 100644 --- a/src/lib/evas/canvas/evas_font_dir.c +++ b/src/lib/evas/canvas/evas_font_dir.c @@ -469,6 +469,17 @@ evas_font_desc_cmp(const Evas_Font_Description *a, (a->spacing == b->spacing) && (a->lang == b->lang)); } +const char * +evas_font_lang_normalize(const char *lang) +{ + if (!lang || !strcmp(lang, "none")) return NULL; + + if (!strcmp(lang, "auto")) + return evas_common_language_from_locale_full_get(); + + return lang; +} + void evas_font_name_parse(Evas_Font_Description *fdesc, const char *name) { @@ -520,6 +531,7 @@ evas_font_name_parse(Evas_Font_Description *fdesc, const char *name) { const char *tmp = name + 6; eina_stringshare_replace_length(&(fdesc->lang), tmp, tend - tmp); + eina_stringshare_replace(&(fdesc->lang), evas_font_lang_normalize(fdesc->lang)); } } } diff --git a/src/lib/evas/canvas/evas_object_text.c b/src/lib/evas/canvas/evas_object_text.c index 355c8f8db8..0402781caa 100644 --- a/src/lib/evas/canvas/evas_object_text.c +++ b/src/lib/evas/canvas/evas_object_text.c @@ -423,6 +423,9 @@ _evas_text_efl_text_properties_font_set(Eo *eo_obj, Evas_Text_Data *o, const cha if (!(o->cur.font && !strcmp(font, o->cur.font))) { 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); } else diff --git a/src/lib/evas/canvas/evas_object_textblock.c b/src/lib/evas/canvas/evas_object_textblock.c index 70a9e3ae33..2c7472a400 100644 --- a/src/lib/evas/canvas/evas_object_textblock.c +++ b/src/lib/evas/canvas/evas_object_textblock.c @@ -1357,6 +1357,10 @@ _format_command(Evas_Object *eo_obj, Evas_Object_Textblock_Format *fmt, const ch if (!fmt->font.fdesc) { fmt->font.fdesc = evas_font_desc_new(); + + /* Set default language according to locale. */ + eina_stringshare_replace(&(fmt->font.fdesc->lang), + evas_font_lang_normalize("auto")); } else if (!fmt->font.fdesc->is_new) { @@ -1515,11 +1519,15 @@ _format_command(Evas_Object *eo_obj, Evas_Object_Textblock_Format *fmt, const ch * @subsection evas_textblock_style_lang Language * * Sets the language of the text for FontConfig. + * The value can either be a language text or one of presets: + * @li "auto" - Respects system locale settings as language + * @li "none" - Disable language support * @code * lang=<language> * @endcode */ - eina_stringshare_replace(&(fmt->font.fdesc->lang), param); + eina_stringshare_replace(&(fmt->font.fdesc->lang), + evas_font_lang_normalize(param)); } else if (cmd == colorstr) /** diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h index ac814ba3c9..664c144c18 100644 --- a/src/lib/evas/include/evas_private.h +++ b/src/lib/evas/include/evas_private.h @@ -1591,6 +1591,7 @@ Evas_Font_Description *evas_font_desc_dup(const Evas_Font_Description *fdesc); void evas_font_desc_unref(Evas_Font_Description *fdesc); int evas_font_desc_cmp(const Evas_Font_Description *a, const Evas_Font_Description *b); Evas_Font_Description *evas_font_desc_ref(Evas_Font_Description *fdesc); +const char *evas_font_lang_normalize(const char *lang); void * evas_font_load(Evas *evas, Evas_Font_Description *fdesc, const char *source, Evas_Font_Size size); void evas_font_load_hinting_set(Evas *evas, void *font, int hinting); void evas_object_smart_member_cache_invalidate(Evas_Object *obj, Eina_Bool pass_events, Eina_Bool freeze_events, Eina_Bool sourve_invisible); |