forked from enlightenment/efl
evas_textblock/evas_text/evas_textgrid: pick textrun fonts
Summary: Picking font on textrun, will now give priority into font picked by the user, regardless of script type. picking font due script can cause many inconvenient results Example of wrong results: (User font is **NotoColorEmoji**) {F3847118} -> add 'a' at the end (notice how text render is wrong) {F3847119} -> add tab before 'a' (text rendering now is right) {F3847120} After Change results: (User font is **NotoColorEmoji**) {F3847118} -> add 'a' at the end -> {F3847122}-> add tab before 'a' -> {F3847123} Also now the following lines will be shown exactly the same, regardless of characters order ``` "가123A321" "A321가123" "123가A321" "A가123321" ``` Test Plan: ``` #include <Elementary.h> /* gcc -o example test.c `pkg-config --cflags --libs elementary` */ EAPI_MAIN int elm_main(int argc EINA_UNUSED, char **argv EINA_UNUSED) { Evas_Object *win, *en; elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED); win = elm_win_util_standard_add("", ""); elm_win_autodel_set(win, EINA_TRUE); en = elm_entry_add(win); elm_entry_scrollable_set(en, EINA_TRUE); evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(en, EVAS_HINT_FILL, EVAS_HINT_FILL); elm_entry_text_style_user_push(en,"DEFAULT='font=NotoColorEmoji font_size=30 color=red'"); elm_object_text_set(en, "☪123456a"); evas_object_show(en); elm_object_content_set(win, en); evas_object_resize(win, 400, 200); evas_object_show(win); elm_run(); return 0; } ELM_MAIN() ``` Reviewers: woohyun, bowonryu, tasn, raster, cedric Reviewed By: tasn Subscribers: cedric, #reviewers, #committers Tags: #efl Maniphest Tasks: T8556 Differential Revision: https://phab.enlightenment.org/D11302
This commit is contained in:
parent
c58f8db132
commit
3283a11a88
|
@ -17,7 +17,7 @@
|
|||
* @return length of the run found.
|
||||
*/
|
||||
EAPI int
|
||||
evas_common_font_query_run_font_end_get(RGBA_Font *fn, RGBA_Font_Int **script_fi, RGBA_Font_Int **cur_fi, Evas_Script_Type script, const Eina_Unicode *text, int run_len)
|
||||
evas_common_font_query_run_font_end_get(RGBA_Font *fn, RGBA_Font_Int **script_fi, RGBA_Font_Int **cur_fi, Evas_Script_Type script EINA_UNUSED, const Eina_Unicode *text, int run_len)
|
||||
{
|
||||
RGBA_Font_Int *fi = NULL;
|
||||
const Eina_Unicode *run_end = text + run_len;
|
||||
|
@ -26,38 +26,7 @@ evas_common_font_query_run_font_end_get(RGBA_Font *fn, RGBA_Font_Int **script_fi
|
|||
/* If there's no current script_fi, find it first */
|
||||
if (!*script_fi)
|
||||
{
|
||||
const Eina_Unicode *base_char = NULL;
|
||||
/* Skip common chars */
|
||||
for (base_char = text ;
|
||||
(base_char < run_end) &&
|
||||
(evas_common_language_char_script_get(*base_char) != script) ;
|
||||
base_char++)
|
||||
;
|
||||
/* If counter reach variation sequence it is safe to pick default font */
|
||||
if(VAR_SEQ_SAFE(base_char) || (base_char != run_end && VAR_SEQ_SAFE((base_char+1)))) goto get_top_font;
|
||||
|
||||
if (base_char == run_end) base_char = text;
|
||||
|
||||
/* Find the first renderable char */
|
||||
while (base_char < run_end)
|
||||
{
|
||||
/* 0x1F is the last ASCII contral char, just a hack in
|
||||
* the meanwhile. */
|
||||
if ((*base_char > 0x1F) &&
|
||||
evas_common_font_glyph_search(fn, &fi, *base_char, 0, EVAS_FONT_SEARCH_OPTION_NONE))
|
||||
break;
|
||||
base_char++;
|
||||
}
|
||||
|
||||
|
||||
/* If everything else fails, at least try to find a font for the
|
||||
* replacement char */
|
||||
if (base_char == run_end)
|
||||
evas_common_font_glyph_search(fn, &fi, REPLACEMENT_CHAR, 0, EVAS_FONT_SEARCH_OPTION_NONE);
|
||||
get_top_font:
|
||||
|
||||
if (!fi)
|
||||
fi = fn->fonts->data;
|
||||
fi = fn->fonts->data;
|
||||
|
||||
*script_fi = fi;
|
||||
}
|
||||
|
|
|
@ -4184,6 +4184,27 @@ EFL_START_TEST(evas_textblock_fit)
|
|||
}
|
||||
EFL_END_TEST;
|
||||
|
||||
EFL_START_TEST(evas_textblock_textrun_font)
|
||||
{
|
||||
START_TB_TEST();
|
||||
int w1, h1, w2, h2;
|
||||
|
||||
evas_object_resize(tb, 300, 300);
|
||||
evas_object_textblock_text_markup_set(tb, "가123A321");
|
||||
evas_object_textblock_size_native_get(tb, &w1, &h1);
|
||||
evas_object_textblock_text_markup_set(tb, "A321가123");
|
||||
evas_object_textblock_size_native_get(tb, &w2, &h2);
|
||||
ck_assert(w1==w2 && h1==h2);
|
||||
evas_object_textblock_text_markup_set(tb, "123가A321");
|
||||
evas_object_textblock_size_native_get(tb, &w2, &h2);
|
||||
ck_assert(w1==w2 && h1==h2);
|
||||
evas_object_textblock_text_markup_set(tb, "A가123321");
|
||||
evas_object_textblock_size_native_get(tb, &w2, &h2);
|
||||
ck_assert(w1==w2 && h1==h2);
|
||||
END_TB_TEST();
|
||||
}
|
||||
EFL_END_TEST;
|
||||
|
||||
#ifdef HAVE_HYPHEN
|
||||
static void
|
||||
_hyphenation_width_stress(Evas_Object *tb, Evas_Textblock_Cursor *cur)
|
||||
|
@ -5055,6 +5076,7 @@ void evas_test_textblock(TCase *tc)
|
|||
tcase_add_test(tc, evas_textblock_delete);
|
||||
tcase_add_test(tc, evas_textblock_obstacle);
|
||||
tcase_add_test(tc, evas_textblock_fit);
|
||||
tcase_add_test(tc, evas_textblock_textrun_font);
|
||||
#ifdef HAVE_HYPHEN
|
||||
tcase_add_test(tc, evas_textblock_hyphenation);
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue