Hi.
Let me
- share another trivial piece of code: changing webkit's text size, rather
than zooming the whole content, incl. images, table/div sizes, which
behaves bad on some pages.
- and ask a question: Does anybody know how to get the default font size
from webkit? Currently it is hardcoded to 12.
Or put a #define in config.h to let the user choose the size per compiled
instance?
cheers,
--
stanio_
diff -r c7c0e3c25efb config.def.h
--- a/config.def.h Tue May 18 14:20:24 2010 +0200
+++ b/config.def.h Sun May 23 13:37:59 2010 +0200
@@ -23,6 +23,9 @@
{ MODKEY|GDK_SHIFT_MASK,GDK_j, zoom, { .i = -1 } },
{ MODKEY|GDK_SHIFT_MASK,GDK_k, zoom, { .i = +1 } },
{ MODKEY|GDK_SHIFT_MASK,GDK_i, zoom, { .i = 0 } },
+{ MODKEY, GDK_0, zoomtext, { .i = 0 } },
+{ MODKEY, GDK_minus, zoomtext, { .i = -1 } },
+{ MODKEY, GDK_equal, zoomtext, { .i = +1 } },
{ MODKEY, GDK_l, navigate, { .i = +1 } },
{ MODKEY, GDK_h, navigate, { .i = -1 } },
{ MODKEY, GDK_j, scroll, { .i = +1 } },
diff -r c7c0e3c25efb surf.c
--- a/surf.cTue May 18 14:20:24 2010 +0200
+++ b/surf.cSun May 23 13:37:59 2010 +0200
@@ -110,6 +110,7 @@
static void usage(void);
static void windowobjectcleared(GtkWidget *w, WebKitWebFrame *frame,
JSContextRef js, JSObjectRef win, Client *c);
static void zoom(Client *c, const Arg *arg);
+static void zoomtext(Client *c, const Arg *arg);
/* configuration, allows nested code to access above variables */
#include "config.h"
@@ -805,6 +806,18 @@
}
}
+void
+zoomtext(Client *c, const Arg *arg) {
+ WebKitWebSettings *settings;
+ gint fontsize;
+
+ settings = webkit_web_view_get_settings(c->view);
+ g_object_get(G_OBJECT(settings), "default-font-size", &fontsize, NULL);
+ //default size according to webkit docs is 12; FIXME: figure out how to
get setting defaults
+ fontsize = (arg->i == 0 ? 12 : fontsize + arg->i);
+ g_object_set(G_OBJECT(settings), "default-font-size", fontsize, NULL);
+}
+
int
main(int argc, char *argv[]) {
int i;