Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

hinting_font_size option #138

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion hinting.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ THE SOFTWARE.
function Hints() {
var config = {
maxAllowedHints: 500,
hintCss: "z-index:100000;font-family:monospace;font-size:10px;"
hintCss: "z-index:100000;font-family:monospace;font-size:%%%HINTING_FONT_SIZE_PLACEHOLDER%%%px;"
+ "font-weight:bold;color:white;background-color:red;"
+ "padding:0px 1px;position:absolute;",
hintClass: "hinting_mode_hint",
Expand Down
12 changes: 12 additions & 0 deletions settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ int edit_mode = XT_EM_HYBRID;
char *include_config = NULL;
int anonymize_headers = 0;
int tabless = 0; /* allow only 1 tab */
int hinting_font_size = 10; /* 10 px by default */

/* runtime settings */
int show_tabs = XT_DS_SHOW_TABS; /* show tabs on notebook */
Expand Down Expand Up @@ -293,6 +294,7 @@ int check_statusbar_font(char **);
int check_statusbar_style(char **);
int check_tab_style(char **);
int check_tabless(char **);
int check_hinting_font_size(char **);
int check_tabbar_font(char **);
int check_url_regex(char **);
int check_userstyle(char **);
Expand Down Expand Up @@ -577,6 +579,7 @@ struct settings rs[] = {
{ "tab_style", XT_S_STR, 0, NULL, NULL,&s_tab_style, NULL, set_tab_style_rt, check_tab_style, TT_TAB_STYLE },
{ "tabbar_font", XT_S_STR, 0, NULL, &tabbar_font_name, NULL, NULL, set_tabbar_font, check_tabbar_font, TT_TABBAR_FONT },
{ "tabless", XT_S_BOOL, 0, &tabless, NULL, NULL, NULL, NULL, check_tabless, TT_TABLESS },
{ "hinting_font_size", XT_S_INT, 0, &hinting_font_size, NULL, NULL, NULL, NULL, check_hinting_font_size, TT_HINTING_FONT_SIZE },
{ "url_regex", XT_S_STR, 0, NULL, &url_regex, NULL, NULL, set_url_regex, check_url_regex, TT_URL_REGEX },
{ "userstyle", XT_S_STR, 0, NULL, NULL,&s_userstyle, NULL, set_userstyle_rt, check_userstyle, TT_USERSTYLE },
{ "userstyle_global", XT_S_BOOL, 0, &userstyle_global, NULL, NULL, NULL, set_userstyle_global, check_userstyle_global, TT_USERSTYLE_GLOBAL },
Expand Down Expand Up @@ -3444,6 +3447,15 @@ check_window_width(char **tt)
return (window_width != 1024);
}


int
check_hinting_font_size(char **tt)
{
*tt = g_strdup_printf("Default: %d", 10);
return (hinting_font_size != 10);
}


int
check_work_dir(char **tt)
{
Expand Down
3 changes: 3 additions & 0 deletions xombrero.1
Original file line number Diff line number Diff line change
Expand Up @@ -1689,6 +1689,9 @@ Set the work directory where all
scratch files are stored.
Default is
.Cm ~/.xombrero .
.It Cm hinting_font_size
Sets the size, in pixels, of font used for numbers prefixing the
links when hinting is active. Default is 10.
.El
.Sh HISTORY
.Nm
Expand Down
30 changes: 28 additions & 2 deletions xombrero.c
Original file line number Diff line number Diff line change
Expand Up @@ -1079,6 +1079,9 @@ js_ref_to_string(JSContextRef context, JSValueRef ref)
#define XT_JS_INSERT ("insert;")
#define XT_JS_INSERT_LEN (strlen(XT_JS_INSERT))

static char *JS_HINTING_PARSED = NULL;
#define JS_HINTING_ACTUAL (JS_HINTING_PARSED?JS_HINTING_PARSED:JS_HINTING)

int
run_script(struct tab *t, char *s)
{
Expand All @@ -1089,7 +1092,7 @@ run_script(struct tab *t, char *s)
char *es;

DNPRINTF(XT_D_JS, "%s: tab %d %s\n", __func__,
t->tab_id, s == (char *)JS_HINTING ? "JS_HINTING" : s);
t->tab_id, s == (char *)JS_HINTING_ACTUAL ? "JS_HINTING" : s);

frame = webkit_web_view_get_main_frame(t->wv);
ctx = webkit_web_frame_get_global_context(frame);
Expand Down Expand Up @@ -4250,7 +4253,9 @@ notify_load_status_cb(WebKitWebView* wview, GParamSpec* pspec, struct tab *t)
}

show_ca_status(t, uri);
run_script(t, JS_HINTING);


run_script(t, JS_HINTING_ACTUAL);
if (enable_autoscroll)
run_script(t, JS_AUTOSCROLL);
break;
Expand Down Expand Up @@ -8477,6 +8482,25 @@ welcome(void)
"wiki page</a><p>");
}


void
setup_hinting(void)
{
const char *magic = "%%%HINTING_FONT_SIZE_PLACEHOLDER%%%";
size_t n_magic = strlen(magic);
size_t n_max = 0;

if(!(JS_HINTING)) return;

char *magic_ptr = strstr(JS_HINTING, magic);
if(!magic_ptr) return;

JS_HINTING_PARSED = malloc((n_max = strlen(JS_HINTING))+1);
char *rest = stpncpy(JS_HINTING_PARSED, JS_HINTING, magic_ptr-JS_HINTING);
snprintf(rest, n_max - (rest-JS_HINTING_PARSED), "%d%s",
hinting_font_size, magic_ptr + n_magic);
}

int
main(int argc, char **argv)
{
Expand Down Expand Up @@ -8914,6 +8938,8 @@ main(int argc, char **argv)
setup_css();
#endif

setup_hinting();

gtk_main();

gnutls_global_deinit();
Expand Down
2 changes: 2 additions & 0 deletions xombrero.h
Original file line number Diff line number Diff line change
Expand Up @@ -882,6 +882,8 @@ extern int browser_mode;
extern int enable_localstorage;
extern char *statusbar_elems;

extern int hinting_font_size;

#if SOUP_CHECK_VERSION(2, 42, 2)
extern GProxyResolver *proxy_uri;
extern gchar *proxy_exclude[];
Expand Down