From ec496289debf2722626406daa3c34d35d35dd567 Mon Sep 17 00:00:00 2001 From: Daniel Friesel Date: Wed, 16 Jun 2010 12:34:17 +0200 Subject: Make --font set the global default font --- src/imlib.c | 24 ++++++++++++++++++++---- src/index.c | 6 +++++- src/options.c | 4 ++-- src/thumbnail.c | 6 +++++- 4 files changed, 32 insertions(+), 8 deletions(-) (limited to 'src') diff --git a/src/imlib.c b/src/imlib.c index c8aaf82..eedab6a 100644 --- a/src/imlib.c +++ b/src/imlib.c @@ -552,9 +552,11 @@ void feh_draw_zoom(winwidget w) if (!w->im) return; + if (opt.font) + fn = gib_imlib_load_font(opt.font); + if (!fn) { fn = gib_imlib_load_font(DEFAULT_FONT); - memset(atab, 0, sizeof(atab)); } if (!fn) { @@ -562,6 +564,8 @@ void feh_draw_zoom(winwidget w) return; } + memset(atab, 0, sizeof(atab)); + snprintf(buf, sizeof(buf), "%.0f%%, %dx%d", w->zoom * 100, (int) (w->im_w * w->zoom), (int) (w->im_h * w->zoom)); @@ -598,8 +602,10 @@ void feh_draw_filename(winwidget w) || (!FEH_FILE(w->file->data)->filename)) return; + if (opt.font) + fn = gib_imlib_load_font(opt.font); + if (!fn) { - memset(atab, 0, sizeof(atab)); if (w->full_screen) fn = gib_imlib_load_font(DEFAULT_FONT_BIG); else @@ -611,6 +617,8 @@ void feh_draw_filename(winwidget w) return; } + memset(atab, 0, sizeof(atab)); + /* Work out how high the font is */ gib_imlib_get_text_size(fn, FEH_FILE(w->file->data)->filename, NULL, &tw, &th, IMLIB_TEXT_TO_RIGHT); @@ -730,8 +738,10 @@ void feh_draw_caption(winwidget w) caption_style->bits = gib_list_add_front(caption_style->bits, gib_style_bit_new(1, 1, 0, 0, 0, 255)); + if (opt.font) + fn = gib_imlib_load_font(opt.font); + if (!fn) { - memset(atab, 0, sizeof(atab)); if (w->full_screen) fn = gib_imlib_load_font(DEFAULT_FONT_BIG); else @@ -743,6 +753,8 @@ void feh_draw_caption(winwidget w) return; } + memset(atab, 0, sizeof(atab)); + if (*(file->caption) == '\0') { p = estrdup("Caption entry mode - Hit ESC to cancel"); lines = feh_wrap_string(p, w->w, fn, NULL); @@ -1035,8 +1047,10 @@ void feh_draw_actions(winwidget w) || (!FEH_FILE(w->file->data)->filename)) return; + if (opt.font) + fn = gib_imlib_load_font(opt.font); + if (!fn) { - memset(atab, 0, sizeof(atab)); if (w->full_screen) fn = gib_imlib_load_font(DEFAULT_FONT_BIG); else @@ -1048,6 +1062,8 @@ void feh_draw_actions(winwidget w) return; } + memset(atab, 0, sizeof(atab)); + gib_imlib_get_text_size(fn, "defined actions:", NULL, &tw, &th, IMLIB_TEXT_TO_RIGHT); /* Check for the widest line */ max_tw = tw; diff --git a/src/index.c b/src/index.c index 8321185..e611ba6 100644 --- a/src/index.c +++ b/src/index.c @@ -68,7 +68,11 @@ void init_index_mode(void) mode = "index"; } - fn = gib_imlib_load_font(opt.font); + if (opt.font) + fn = gib_imlib_load_font(opt.font); + + if (!fn) + fn = gib_imlib_load_font(DEFAULT_FONT); if (opt.title_font) { int fh, fw; diff --git a/src/options.c b/src/options.c index b7deb12..e2e9c05 100644 --- a/src/options.c +++ b/src/options.c @@ -55,7 +55,7 @@ void init_parse_options(int argc, char **argv) opt.thumb_h = 60; opt.thumb_redraw = 10; opt.menu_font = estrdup(DEFAULT_MENU_FONT); - opt.font = estrdup(DEFAULT_FONT); + opt.font = NULL; opt.image_bg = estrdup("default"); opt.menu_bg = estrdup(PREFIX "/share/feh/images/menubg_default.png"); opt.menu_style = estrdup(PREFIX "/share/feh/fonts/menu.style"); @@ -1081,10 +1081,10 @@ static void show_usage(void) " -o, --output FILE Save the created montage to FILE\n" " -O, --output-only FILE Just save the created montage to FILE\n" " WITHOUT displaying it (use in scripts)\n" -" INDEX MODE OPTIONS\n" " -e, --font FONT Use FONT to print the information under each\n" " thumbnail. FONT should be defined in the form\n" " fontname/size(points). eg -e myfont/12\n" +" INDEX MODE OPTIONS\n" " -@, --title-font FONT Use FONT to print a title on the index, if no\n" " font is specified, a title will not be printed\n" " SLIDESHOW KEYS\n" diff --git a/src/thumbnail.c b/src/thumbnail.c index c104cb8..74cc033 100644 --- a/src/thumbnail.c +++ b/src/thumbnail.c @@ -92,7 +92,11 @@ void init_thumbnail_mode(void) mode = "thumbnail"; - td.font_main = gib_imlib_load_font(opt.font); + if (opt.font) + td.font_main = gib_imlib_load_font(opt.font); + + if (!td.font_main) + td.font_main = gib_imlib_load_font(DEFAULT_FONT); if (opt.title_font) { int fh, fw; -- cgit v1.2.3