Enlightenment CVS committal Author : stffrdhrn Project : e17 Module : libs/evas
Dir : e17/libs/evas/src/lib/canvas Modified Files: evas_font_dir.c evas_object_text.c Log Message: Add fontconfig to evas for finding fonts * This can be disabled with --enable-fontconfig=no * Test in e17 with "enlightenment_remote -font-default-set title_bar Serif 12" * This is just the beginning: TODO: style searching, language reorder bypass =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/evas/src/lib/canvas/evas_font_dir.c,v retrieving revision 1.15 retrieving revision 1.16 diff -u -3 -r1.15 -r1.16 --- evas_font_dir.c 1 Mar 2006 03:48:02 -0000 1.15 +++ evas_font_dir.c 19 Mar 2006 04:29:57 -0000 1.16 @@ -3,6 +3,9 @@ #ifdef BUILD_FONT_LOADER_EET #include <Eet.h> #endif +#ifdef HAVE_FONTCONFIG +#include <fontconfig/fontconfig.h> +#endif /* font dir cache */ static Evas_Hash *font_dirs = NULL; @@ -136,7 +139,7 @@ Fndat *fd; if (!name) return NULL; - + for (l = fonts_cache; l; l = l->next) { fd = l->data; @@ -174,15 +177,15 @@ } } fonts = evas_font_set_get(name); - for (l = fonts; l; l = l->next) + for (l = fonts; l; l = l->next) /* Load each font in append */ { char *nm; nm = l->data; - if ((l == fonts) || (!font)) + if ((l == fonts) || (!font)) /* First iteration OR no font */ { #ifdef BUILD_FONT_LOADER_EET - if (source) + if (source) /* Load Font from "eet" source */ { Eet_File *ef; char *fake_name; @@ -191,7 +194,7 @@ if (fake_name) { font = evas->engine.func->font_load(evas->engine.data.output, fake_name, size); - if (!font) + if (!font) /* Load from fake name failed, probably not cached */ { /* read original!!! */ ef = eet_open(source, EET_FILE_MODE_READ); @@ -212,12 +215,12 @@ free(fake_name); } } - if (!font) + if (!font) /* Source load failed */ { #endif - if (evas_file_path_is_full_path((char *)nm)) + if (evas_file_path_is_full_path((char *)nm)) /* Try filename */ font = evas->engine.func->font_load(evas->engine.data.output, (char *)nm, size); - else + else /* search font path */ { Evas_List *l; @@ -236,8 +239,45 @@ #ifdef BUILD_FONT_LOADER_EET } #endif +#ifdef HAVE_FONTCONFIG + if (!font) /* Search using fontconfig */ + { + FcPattern *p_nm = NULL; + FcFontSet *set; + FcResult res; + int i; + + p_nm = FcNameParse(nm); + FcConfigSubstitute(NULL, p_nm, FcMatchPattern); + FcDefaultSubstitute(p_nm); + + /* do matching */ + set = FcFontSort(NULL, p_nm, FcTrue, NULL, &res); + + /* Do loading for all in family */ + for (i = 0; i < set->nfont; i++) + { + FcValue filename; + + FcPatternGet(set->fonts[i], FC_FILE, 0, &filename); + + if (font) + evas->engine.func->font_add(evas->engine.data.output, font, filename.u.s, size); + else + font = evas->engine.func->font_load(evas->engine.data.output, filename.u.s, size); + } + + FcFontSetDestroy(set); + FcPatternDestroy(p_nm); + + if (font) + { + break; + } + } +#endif } - else + else /* Base font loaded, append others */ { void *ok = NULL; =================================================================== RCS file: /cvsroot/enlightenment/e17/libs/evas/src/lib/canvas/evas_object_text.c,v retrieving revision 1.54 retrieving revision 1.55 diff -u -3 -r1.54 -r1.55 --- evas_object_text.c 1 Mar 2006 03:48:02 -0000 1.54 +++ evas_object_text.c 19 Mar 2006 04:29:57 -0000 1.55 @@ -105,6 +105,7 @@ MAGIC_CHECK(o, Evas_Object_Text, MAGIC_OBJ_TEXT); return; MAGIC_CHECK_END(); + if ((o->cur.source) && (font_source) && (!strcmp(o->cur.source, font_source))) return; @@ -157,6 +158,7 @@ MAGIC_CHECK(o, Evas_Object_Text, MAGIC_OBJ_TEXT); return; MAGIC_CHECK_END(); + if ((o->cur.font) && (font) && (!strcmp(o->cur.font, font))) { same_font = 1; @@ -935,6 +937,7 @@ return; MAGIC_CHECK_END(); if (!path) return; + e->font_path = evas_list_append(e->font_path, evas_stringshare_add(path)); } @@ -950,6 +953,7 @@ MAGIC_CHECK(e, Evas, MAGIC_EVAS); return; MAGIC_CHECK_END(); + if (!path) return; e->font_path = evas_list_prepend(e->font_path, evas_stringshare_add(path)); } ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642 _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs