2 * Copyright (C) 2004-2009 Kim Woelders
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to
6 * deal in the Software without restriction, including without limitation the
7 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 * sell copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies of the Software, its documentation and marketing & publicity
13 * materials, and acknowledgment shall be given in the documentation, materials
14 * and software packages that this Software was used.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24 #include "e16-ecore_list.h"
31 static Ecore_List *font_list = NULL;
34 _FontAliasDestroy(void *data)
36 FontAlias *fa = (FontAlias *) data;
47 FontAliasCreate(const char *name, const char *font)
51 fa = EMALLOC(FontAlias, 1);
55 fa->name = Estrdup(name);
56 fa->font = Estrdup(font);
60 font_list = ecore_list_new();
61 ecore_list_free_cb_set(font_list, _FontAliasDestroy);
63 ecore_list_prepend(font_list, fa);
69 _FontMatchName(const void *data, const void *match)
71 return strcmp(((const FontAlias *)data)->name, (const char *)match);
75 FontLookup(const char *name)
79 fa = (FontAlias *) ecore_list_find(font_list, _FontMatchName, name);
81 return (fa) ? fa->font : NULL;
89 _FontConfigLoad(FILE * fs)
93 char s[FILEPATH_LEN_MAX];
97 while (GetLine(s, sizeof(s), fs))
101 sscanf(s, "%120s %n", s1, &i2);
107 if (strncmp(s, "font-", 5))
109 fa = FontAliasCreate(s1, p2);
116 _FontConfigLoad1(const char *cfg, int look_in_theme_too)
120 path = (look_in_theme_too) ? Mode.theme.path : NULL;
122 return ConfigFileLoad(cfg, path, _FontConfigLoad, 0);
128 /* First check explicitly specified configuration (not in theme dir) */
129 if (Conf.theme.use_alt_font_cfg && Conf.theme.font_cfg)
131 if (!_FontConfigLoad1(Conf.theme.font_cfg, 0))
135 /* If using theme font is specified look for that */
136 if (Conf.theme.use_theme_font_cfg)
138 if (!_FontConfigLoad1("fonts.theme.cfg", 1))
142 /* Look in user config dir (not in theme dir) */
143 _FontConfigLoad1("fonts.cfg", 0);
146 if (!_FontConfigLoad1("fonts.pango.cfg", 1))
150 if (!_FontConfigLoad1("fonts.xft.cfg", 1))
153 _FontConfigLoad1("fonts.cfg", 1);
157 FontConfigUnload(void)
159 ecore_list_destroy(font_list);