Enlightenment CVS committal Author : kwo Project : e17 Module : libs/imlib2
Dir : e17/libs/imlib2/src/lib Modified Files: font.h font_load.c Log Message: Add support for TrueType Collections (suggested by Arne Goetje, bug 487). The font specifier format is now "font_name[:faceidx]/size" where faceidx is an optional face index. =================================================================== RCS file: /cvs/e/e17/libs/imlib2/src/lib/font.h,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- font.h 4 Nov 2007 09:47:53 -0000 1.6 +++ font.h 1 Jun 2008 21:34:26 -0000 1.7 @@ -77,7 +77,6 @@ char **imlib_font_list_fonts(int *num_ret); ImlibFont *imlib_font_load_joined(const char *name); -ImlibFont *imlib_font_load(const char *name, int size); void imlib_font_free(ImlibFont * fn); int imlib_font_insert_into_fallback_chain_imp(ImlibFont * fn, ImlibFont * fallback); =================================================================== RCS file: /cvs/e/e17/libs/imlib2/src/lib/font_load.c,v retrieving revision 1.6 retrieving revision 1.7 diff -u -3 -r1.6 -r1.7 --- font_load.c 27 Jul 2007 18:46:11 -0000 1.6 +++ font_load.c 1 Jun 2008 21:34:26 -0000 1.7 @@ -23,6 +23,7 @@ static int fpath_num = 0; static Imlib_Object_List *fonts = NULL; +static ImlibFont *imlib_font_load(const char *name, int faceidx, int size); static int font_modify_cache_cb(Imlib_Hash * hash, const char *key, void *data, void *fdata); static int font_flush_free_glyph_cb(Imlib_Hash * hash, const char *key, @@ -34,17 +35,31 @@ ImlibFont * imlib_font_load_joined(const char *fontname) { - int j, size; + int j, k, size, faceidx; char *name = NULL, *file = NULL, *tmp = NULL; ImlibFont *fn; - /* split font name (in format name/size) */ + /* split font name (in format name[:faceidx]/size) */ for (j = strlen(fontname) - 1; (j >= 0) && (fontname[j] != '/'); j--); /* no "/" in font after the first char */ if (j <= 0) return NULL; /* get size */ size = atoi(&(fontname[j + 1])); + /* split font faceidx index (in format name[:faceidx]/size) */ + faceidx = 0; + for (k = j - 1; k > 0; k--) + { + if (fontname[k] >= '0' && fontname[k] <= '9') + continue; + if (fontname[k] != ':') + break; + faceidx = atoi(&(fontname[k + 1])); + if (faceidx < 0) + faceidx = 0; + j = k; + break; + } /* split name in front off */ name = malloc((j + 1) * sizeof(char)); memcpy(name, fontname, j); @@ -107,13 +122,13 @@ /* didnt find a file? abort */ if (!file) return NULL; - fn = imlib_font_load(file, size); + fn = imlib_font_load(file, faceidx, size); free(file); return fn; } -ImlibFont * -imlib_font_load(const char *name, int size) +static ImlibFont * +imlib_font_load(const char *name, int faceidx, int size) { int error; ImlibFont *fn; @@ -128,7 +143,7 @@ fn = malloc(sizeof(ImlibFont)); file = (char *)name; - error = FT_New_Face(ft_lib, file, 0, &(fn->ft.face)); + error = FT_New_Face(ft_lib, file, faceidx, &(fn->ft.face)); if (error) { free(fn); ------------------------------------------------------------------------- This SF.net email is sponsored by: Microsoft Defy all challenges. Microsoft(R) Visual Studio 2008. http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ _______________________________________________ enlightenment-cvs mailing list enlightenment-cvs@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs