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


SVN revision: 21394
This commit is contained in:
stffrdhrn 2006-03-19 04:29:57 +00:00 committed by stffrdhrn
parent 46a61a67b7
commit ec8cd4cc08
6 changed files with 97 additions and 14 deletions

View File

@ -124,6 +124,40 @@ AC_PATH_GENERIC(freetype, 9.5.0,
[ AC_MSG_ERROR(Freetype isn't installed) ]
)
#######################################
## FontConfig
AC_MSG_CHECKING(whether fontconfig searching is to be built)
AC_ARG_ENABLE(fontconfig, [ --enable-fontconfig enable fontconfig for finding fonts], [
if test x"$enableval" = x"yes" ; then
have_fontconfig="yes"
else
have_fontconfig="no"
fi
], [
have_fontconfig="yes"
]
)
if test "x$have_fontconfig" = "xyes"; then
# Check if really available
PKG_CHECK_MODULES(FONTCONFIG, fontconfig,
[
have_fontconfig="yes"
AC_DEFINE(HAVE_FONTCONFIG, 1, [have fontconfig searching capabilities])
AC_MSG_RESULT(yes)
],
[
have_fontconfig="no"
AC_MSG_RESULT(no)
]
)
else
AC_MSG_RESULT(no)
fi
###############
## dlopen
dlopen_libs=""
AC_CHECK_FUNCS(dlopen, res=yes, res=no)
if test "x$res" = "xyes"; then
@ -1748,6 +1782,9 @@ echo " EDB.....................: $have_edb"
echo
echo "Font Sourcing Systems:"
echo " EET.....................: $have_eet_fonts"
echo
echo "Font Searching Systems:"
echo " FontConfig..............: $have_fontconfig"
# FIXME: add non freetype2 font engine support
# FIXME: make freetype2 optional
echo

View File

@ -7,8 +7,9 @@ AUTOMAKE_OPTIONS = 1.4 foreign
INCLUDES = -I. \
-I$(top_srcdir)/src/lib \
-I$(top_srcdir)/src/lib/include \
@FREETYPE_CFLAGS@
@eet_cflags@
@FREETYPE_CFLAGS@ \
@eet_cflags@ \
@FONTCONFIG_CFLAGS@
lib_LTLIBRARIES = libevas.la
@ -27,7 +28,8 @@ libevas_la_LIBADD = \
-lm \
@dlopen_libs@ \
@FREETYPE_LIBS@ \
@eet_libs@
@eet_libs@ \
@FONTCONFIG_LIBS@
libevas_la_DEPENDENCIES = \
$(top_builddir)/config.h \

View File

@ -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 @@ evas_font_load(Evas *evas, const char *name, const char *source, int size)
Fndat *fd;
if (!name) return NULL;
for (l = fonts_cache; l; l = l->next)
{
fd = l->data;
@ -174,15 +177,15 @@ evas_font_load(Evas *evas, const char *name, const char *source, int size)
}
}
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 @@ evas_font_load(Evas *evas, const char *name, const char *source, int size)
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 @@ evas_font_load(Evas *evas, const char *name, const char *source, int size)
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;
@ -235,9 +238,46 @@ evas_font_load(Evas *evas, const char *name, const char *source, int size)
}
#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;

View File

@ -105,6 +105,7 @@ evas_object_text_font_source_set(Evas_Object *obj, const char *font_source)
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 @@ evas_object_text_font_set(Evas_Object *obj, const char *font, Evas_Font_Size siz
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 @@ evas_font_path_append(Evas *e, const char *path)
return;
MAGIC_CHECK_END();
if (!path) return;
e->font_path = evas_list_append(e->font_path, evas_stringshare_add(path));
}
@ -950,6 +953,7 @@ evas_font_path_prepend(Evas *e, const char *path)
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));
}

View File

@ -227,7 +227,7 @@ evas_common_font_memory_load(const char *name, int size, const void *data, int d
{
RGBA_Font *fn;
RGBA_Font_Int *fi;
fi = evas_common_font_int_memory_load(name, size, data, data_size);
if (!fi) return NULL;
fn = calloc(1, sizeof(RGBA_Font));

View File

@ -107,7 +107,7 @@ int
evas_common_font_utf8_get_next(unsigned char *buf, int *iindex)
{
/* Reads UTF8 bytes from @buf, starting at *@index and returns
* the decoded code point at iindex offset, and advances iidnex
* the decoded code point at iindex offset, and advances iindex
* to the next code point after this.
*
* Returns 0 to indicate an error (e.g. invalid UTF8)