From 3f4e8a498b71ca9ee71664aa75b72e4e343b7486 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Thu, 27 Sep 2012 12:36:10 +0200 Subject: [PATCH] wlt: add some --font-* options Copy the options from kmscon which are font-* engine, size, dpi and name. Signed-off-by: David Herrmann --- src/wlt_main.c | 16 +++++++++++++++- src/wlt_main.h | 9 +++++++++ src/wlt_terminal.c | 14 ++++++++++---- 3 files changed, 34 insertions(+), 5 deletions(-) diff --git a/src/wlt_main.c b/src/wlt_main.c index be2ea27..fdb05b0 100644 --- a/src/wlt_main.c +++ b/src/wlt_main.c @@ -187,7 +187,17 @@ static void print_help() "\t-h, --help [off] Print this help and exit\n" "\t-v, --verbose [off] Print verbose messages\n" "\t --debug [off] Enable debug mode\n" - "\t --silent [off] Suppress notices and warnings\n", + "\t --silent [off] Suppress notices and warnings\n" + "\n" + "Font Options:\n" + "\t --font-engine [pango]\n" + "\t Font engine\n" + "\t --font-size [15]\n" + "\t Font size in points\n" + "\t --font-name [monospace]\n" + "\t Font name\n" + "\t --font-dpi [96]\n" + "\t Force DPI value for all fonts\n", "wlterm"); /* * 80 char line: @@ -226,6 +236,10 @@ struct conf_option options[] = { CONF_OPTION_BOOL('v', "verbose", NULL, &wlt_conf.verbose, false), CONF_OPTION_BOOL(0, "debug", aftercheck_debug, &wlt_conf.debug, false), CONF_OPTION_BOOL(0, "silent", NULL, &wlt_conf.silent, false), + CONF_OPTION_STRING(0, "font-engine", NULL, &wlt_conf.font_engine, "pango"), + CONF_OPTION_UINT(0, "font-size", NULL, &wlt_conf.font_size, 12), + CONF_OPTION_STRING(0, "font-name", NULL, &wlt_conf.font_name, "monospace"), + CONF_OPTION_UINT(0, "font-dpi", NULL, &wlt_conf.font_ppi, 96), }; int main(int argc, char **argv) diff --git a/src/wlt_main.h b/src/wlt_main.h index cf624a2..fad8d44 100644 --- a/src/wlt_main.h +++ b/src/wlt_main.h @@ -44,6 +44,15 @@ struct wlt_conf_t { bool verbose; /* disable notices and warnings */ bool silent; + + /* font engine */ + char *font_engine; + /* font size */ + unsigned int font_size; + /* font name */ + char *font_name; + /* font ppi (overrides per monitor PPI) */ + unsigned int font_ppi; }; extern struct wlt_conf_t wlt_conf; diff --git a/src/wlt_terminal.c b/src/wlt_terminal.c index fc013e8..8fe95c3 100644 --- a/src/wlt_terminal.c +++ b/src/wlt_terminal.c @@ -39,6 +39,7 @@ #include "tsm_unicode.h" #include "tsm_screen.h" #include "tsm_vte.h" +#include "wlt_main.h" #include "wlt_toolkit.h" #define LOG_SUBSYSTEM "wlt_terminal" @@ -108,7 +109,7 @@ static int draw_cell(struct tsm_screen *scr, tmp = x + buf->width; if (tmp < x || x >= term->buffer.width) - return -EINVAL; + return 0; if (tmp > term->buffer.width) width = term->buffer.width - x; else @@ -116,7 +117,7 @@ static int draw_cell(struct tsm_screen *scr, tmp = y + buf->height; if (tmp < y || y >= term->buffer.height) - return -EINVAL; + return 0; if (tmp > term->buffer.height) height = term->buffer.height - y; else @@ -268,7 +269,7 @@ int wlt_terminal_new(struct wlt_terminal **out, struct wlt_window *wnd) { struct wlt_terminal *term; int ret; - const struct kmscon_font_attr attr = { "", 0, 20, false, false, 0, 0 }; + struct kmscon_font_attr attr = { "", 0, 20, false, false, 0, 0 }; if (!out || !wnd) return -EINVAL; @@ -280,7 +281,12 @@ int wlt_terminal_new(struct wlt_terminal **out, struct wlt_window *wnd) term->wnd = wnd; term->eloop = wlt_window_get_eloop(wnd); - ret = kmscon_font_find(&term->font_normal, &attr, NULL); + attr.ppi = wlt_conf.font_ppi; + attr.points = wlt_conf.font_size; + strncpy(attr.name, wlt_conf.font_name, KMSCON_FONT_MAX_NAME - 1); + attr.name[KMSCON_FONT_MAX_NAME - 1] = 0; + + ret = kmscon_font_find(&term->font_normal, &attr, wlt_conf.font_engine); if (ret) { log_error("cannot create font"); goto err_free; -- 2.7.4