wlt: add some --font-* options

Copy the options from kmscon which are font-* engine, size, dpi and name.

Signed-off-by: David Herrmann <dh.herrmann@googlemail.com>
This commit is contained in:
David Herrmann committed 2012-09-27 12:36:10 +02:00
1 parent 2c328b2300
commit 3f4e8a498b
3 files changed
+34 -5

No files matched your search

+15 -1
View File
@@ -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 <engine> [pango]\n"
"\t Font engine\n"
"\t --font-size <points> [15]\n"
"\t Font size in points\n"
"\t --font-name <name> [monospace]\n"
"\t Font name\n"
"\t --font-dpi <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)
+9
View File
@@ -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;
+10 -4
View File
@@ -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;