forked from enlightenment/efl
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
This commit is contained in:
parent
6b12ae1e03
commit
d15d91e0da
|
@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
/**
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in New Issue