Allow a comma-separated list of fonts to be specified in font_unicode_list

to provide more preferred fonts.  eg. if a user has dedicated Japanese
and Korean fonts available they might want a config like:
font_unicode:Japanese
font_unicode_list:Korean,Code2000
This will scan Japanese and Korean fonts first, then fill in any blanks
with Code2000 (followed by alphabetically all other fonts installed)

svn path=/trunk/netsurf/; revision=13917
This commit is contained in:
Chris Young 2012-05-09 22:23:10 +00:00
parent 722a75bdf5
commit 560d5d2035
3 changed files with 22 additions and 2 deletions

View File

@ -432,7 +432,7 @@ void ami_font_scan_init(const char *filename, bool force_scan, bool save,
ULONG i, found = 0, entries = 0;
struct MinList *list;
struct nsObject *node;
char *unicode_font;
char *unicode_font, *csv;
struct ami_font_scan_window *win = NULL;
/* Ensure array zeroed */
@ -453,6 +453,23 @@ void ami_font_scan_init(const char *filename, bool force_scan, bool save,
entries = 1;
}
/* add preferred fonts list */
if(nsoption_charp(font_unicode_list) &&
(csv = strdup(nsoption_charp(font_unicode_list))))
{
char *p;
while(p = strsep(&csv, ",")) {
asprintf(&unicode_font, "%s.font", p);
if(unicode_font != NULL) {
node = AddObject(list, AMINS_UNKNOWN);
if(node) node->dtz_Node.ln_Name = unicode_font;
entries++;
}
}
free(csv);
}
if(nsoption_bool(font_unicode_only) == false)
entries += ami_font_scan_list(list);

View File

@ -438,7 +438,7 @@ void ami_set_options(void)
search_engines_file_location = nsoption_charp(search_engines_file);
sprintf(temp, "%s/UnicodeFontCache", current_user_dir);
sprintf(temp, "%s/FontGlyphCache", current_user_dir);
nsoption_setnull_charp(font_unicode_file,
(char *)strdup(temp));

View File

@ -55,6 +55,7 @@
bool close_no_quit; \
bool hide_docky_icon; \
char *font_unicode; \
char *font_unicode_list; \
char *font_unicode_file; \
bool font_unicode_only; \
bool drag_save_icons; \
@ -113,6 +114,7 @@
.close_no_quit = false, \
.hide_docky_icon = false, \
.font_unicode = NULL, \
.font_unicode_list = NULL, \
.font_unicode_file = NULL, \
.font_unicode_only = false, \
.drag_save_icons = true, \
@ -170,6 +172,7 @@
{ "close_no_quit", OPTION_BOOL, &nsoptions.close_no_quit}, \
{ "hide_docky_icon", OPTION_BOOL, &nsoptions.hide_docky_icon}, \
{ "font_unicode", OPTION_STRING, &nsoptions.font_unicode }, \
{ "font_unicode_list", OPTION_STRING, &nsoptions.font_unicode_list }, \
{ "font_unicode_file", OPTION_STRING, &nsoptions.font_unicode_file }, \
{ "font_unicode_only", OPTION_BOOL, &nsoptions.font_unicode_only }, \
{ "drag_save_icons", OPTION_BOOL, &nsoptions.drag_save_icons}, \