summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJames Bursa <james@netsurf-browser.org>2004-02-13 23:07:42 +0000
committerJames Bursa <james@netsurf-browser.org>2004-02-13 23:07:42 +0000
commit765c02622b23acbfdf0ec426e1e9d5beb2158680 (patch)
tree20d47b0796a8fb28b73bfc51307d9eb5b7d6bd6b
parentb5fd9fb2977636b64e15abad3155a5513e29eae8 (diff)
downloadnetsurf-765c02622b23acbfdf0ec426e1e9d5beb2158680.tar.gz
netsurf-765c02622b23acbfdf0ec426e1e9d5beb2158680.tar.bz2
[project @ 2004-02-13 23:07:42 by bursa]
Add font size configuration and fix proxy options bug. svn path=/import/netsurf/; revision=538
-rw-r--r--!NetSurf/Resources/en/Templates,fecbin4160 -> 4528 bytes
-rw-r--r--css/css.c6
-rw-r--r--css/css.h4
-rw-r--r--desktop/options.c16
-rw-r--r--desktop/options.h2
-rw-r--r--render/box.c2
-rw-r--r--riscos/dialog.c55
-rw-r--r--riscos/font.c11
-rw-r--r--riscos/gui.h6
-rw-r--r--riscos/options.h12
10 files changed, 99 insertions, 15 deletions
diff --git a/!NetSurf/Resources/en/Templates,fec b/!NetSurf/Resources/en/Templates,fec
index 16d9d12b1..905fcdfed 100644
--- a/!NetSurf/Resources/en/Templates,fec
+++ b/!NetSurf/Resources/en/Templates,fec
Binary files differ
diff --git a/css/css.c b/css/css.c
index 3f967b548..e03e0c107 100644
--- a/css/css.c
+++ b/css/css.c
@@ -2,7 +2,7 @@
* This file is part of NetSurf, http://netsurf.sourceforge.net/
* Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license
- * Copyright 2003 James Bursa <bursa@users.sourceforge.net>
+ * Copyright 2004 James Bursa <bursa@users.sourceforge.net>
*/
#include <assert.h>
@@ -998,10 +998,10 @@ unsigned int css_hash(const char *s)
/**
- * convert a struct css_length to pixels
+ * Convert a struct css_length to pixels.
*/
-signed long len(struct css_length * length, struct css_style * style)
+float len(struct css_length * length, struct css_style * style)
{
assert(!((length->unit == CSS_UNIT_EM || length->unit == CSS_UNIT_EX) && style == 0));
switch (length->unit) {
diff --git a/css/css.h b/css/css.h
index 71caabfdd..0c5f6d899 100644
--- a/css/css.h
+++ b/css/css.h
@@ -2,7 +2,7 @@
* This file is part of NetSurf, http://netsurf.sourceforge.net/
* Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license
- * Copyright 2003 James Bursa <bursa@users.sourceforge.net>
+ * Copyright 2004 James Bursa <bursa@users.sourceforge.net>
*/
/** \file
@@ -293,6 +293,6 @@ colour named_colour(const char *name);
void css_dump_style(const struct css_style * const style);
void css_dump_stylesheet(const struct css_stylesheet * stylesheet);
-signed long len(struct css_length * length, struct css_style * style);
+float len(struct css_length * length, struct css_style * style);
#endif
diff --git a/desktop/options.c b/desktop/options.c
index 5b1981b6e..ca9cc9cde 100644
--- a/desktop/options.c
+++ b/desktop/options.c
@@ -35,6 +35,11 @@ bool option_http_proxy = false;
char *option_http_proxy_host = 0;
/** Proxy port. */
int option_http_proxy_port = 8080;
+/** Default font size / 0.1pt. */
+int option_font_size = 100;
+/** Minimum font size. */
+int option_font_min_size = 70;
+
EXTRA_OPTION_DEFINE
@@ -46,6 +51,8 @@ struct {
{ "http_proxy", OPTION_BOOL, &option_http_proxy },
{ "http_proxy_host", OPTION_STRING, &option_http_proxy_host },
{ "http_proxy_port", OPTION_INTEGER, &option_http_proxy_port },
+ { "font_size", OPTION_INTEGER, &option_font_size },
+ { "font_min_size", OPTION_INTEGER, &option_font_min_size },
EXTRA_OPTION_TABLE
};
@@ -111,6 +118,15 @@ void options_read(const char *path)
}
fclose(fp);
+
+ if (option_font_size < 50)
+ option_font_size = 50;
+ if (1000 < option_font_size)
+ option_font_size = 1000;
+ if (option_font_min_size < 10)
+ option_font_min_size = 10;
+ if (500 < option_font_min_size)
+ option_font_min_size = 500;
}
diff --git a/desktop/options.h b/desktop/options.h
index 3c2acced9..4f8653554 100644
--- a/desktop/options.h
+++ b/desktop/options.h
@@ -27,6 +27,8 @@
extern bool option_http_proxy;
extern char *option_http_proxy_host;
extern int option_http_proxy_port;
+extern int option_font_size;
+extern int option_font_min_size;
void options_read(const char *path);
void options_write(const char *path);
diff --git a/render/box.c b/render/box.c
index 4057ba181..cf51d5b99 100644
--- a/render/box.c
+++ b/render/box.c
@@ -17,6 +17,7 @@
#include "netsurf/utils/config.h"
#include "netsurf/content/content.h"
#include "netsurf/css/css.h"
+#include "netsurf/desktop/options.h"
#include "netsurf/render/box.h"
#include "netsurf/render/font.h"
#include "netsurf/render/form.h"
@@ -235,6 +236,7 @@ void xml_to_box(xmlNode *n, struct content *c)
c->data.html.style = xcalloc(1, sizeof(struct css_style));
memcpy(c->data.html.style, &css_base_style, sizeof(struct css_style));
+ c->data.html.style->font_size.value.length.value = option_font_size * 0.1;
c->data.html.fonts = font_new_set();
c->data.html.object_count = 0;
diff --git a/riscos/dialog.c b/riscos/dialog.c
index 6f6cf46d2..561f27d70 100644
--- a/riscos/dialog.c
+++ b/riscos/dialog.c
@@ -32,9 +32,13 @@ wimp_w dialog_info, dialog_saveas, dialog_config, dialog_config_br,
;
wimp_menu* theme_menu = NULL;
+static int font_size;
+static int font_min_size;
+
static void ro_gui_dialog_click_config(wimp_pointer *pointer);
static void ro_gui_dialog_click_config_br(wimp_pointer *pointer);
+static void ro_gui_dialog_update_config_br(void);
static void ro_gui_dialog_click_config_prox(wimp_pointer *pointer);
static void ro_gui_dialog_click_config_th(wimp_pointer *pointer);
static void set_browser_choices(void);
@@ -248,11 +252,55 @@ void ro_gui_dialog_click_config_br(wimp_pointer *pointer)
gui_window_show(bw->window);
browser_window_open_location(bw, GESTURES_URL);
break;
+ case ICON_CONFIG_BR_FONTSIZE_DEC:
+ if (font_size == 50)
+ break;
+ font_size--;
+ if (font_size < font_min_size)
+ font_min_size = font_size;
+ ro_gui_dialog_update_config_br();
+ break;
+ case ICON_CONFIG_BR_FONTSIZE_INC:
+ if (font_size == 1000)
+ break;
+ font_size++;
+ ro_gui_dialog_update_config_br();
+ break;
+ case ICON_CONFIG_BR_MINSIZE_DEC:
+ if (font_min_size == 10)
+ break;
+ font_min_size--;
+ ro_gui_dialog_update_config_br();
+ break;
+ case ICON_CONFIG_BR_MINSIZE_INC:
+ if (font_min_size == 500)
+ break;
+ font_min_size++;
+ if (font_size < font_min_size)
+ font_size = font_min_size;
+ ro_gui_dialog_update_config_br();
+ break;
}
}
/**
+ * Update font size icons in browser choices dialog.
+ */
+
+void ro_gui_dialog_update_config_br(void)
+{
+ char s[10];
+ sprintf(s, "%i.%ipt", font_size / 10, font_size % 10);
+ set_icon_string(dialog_config_br, ICON_CONFIG_BR_FONTSIZE, s);
+ sprintf(s, "%i.%ipt", font_min_size / 10, font_min_size % 10);
+ set_icon_string(dialog_config_br, ICON_CONFIG_BR_MINSIZE, s);
+ wimp_set_icon_state(dialog_config_br, ICON_CONFIG_BR_FONTSIZE, 0, 0);
+ wimp_set_icon_state(dialog_config_br, ICON_CONFIG_BR_MINSIZE, 0, 0);
+}
+
+
+/**
* Handle clicks in the Proxy Choices dialog.
*/
@@ -335,6 +383,9 @@ void set_browser_choices(void)
option_allow_text_selection);
set_icon_state(dialog_config_br, ICON_CONFIG_BR_TOOLBAR,
option_show_toolbar);
+ font_size = option_font_size;
+ font_min_size = option_font_min_size;
+ ro_gui_dialog_update_config_br();
}
@@ -350,6 +401,8 @@ void get_browser_choices(void)
ICON_CONFIG_BR_TEXT);
option_show_toolbar = get_icon_state(dialog_config_br,
ICON_CONFIG_BR_TOOLBAR);
+ option_font_size = font_size;
+ option_font_min_size = font_min_size;
}
@@ -362,7 +415,7 @@ void set_proxy_choices(void)
set_icon_state(dialog_config_prox, ICON_CONFIG_PROX_HTTP,
option_http_proxy);
set_icon_string(dialog_config_prox, ICON_CONFIG_PROX_HTTPHOST,
- option_http_proxy_host);
+ option_http_proxy_host ? "" : option_http_proxy_host);
set_icon_string_i(dialog_config_prox, ICON_CONFIG_PROX_HTTPPORT,
option_http_proxy_port);
}
diff --git a/riscos/font.c b/riscos/font.c
index 70dbea29f..46234031f 100644
--- a/riscos/font.c
+++ b/riscos/font.c
@@ -2,7 +2,7 @@
* This file is part of NetSurf, http://netsurf.sourceforge.net/
* Licensed under the GNU General Public License,
* http://www.opensource.org/licenses/gpl-license
- * Copyright 2003 James Bursa <bursa@users.sourceforge.net>
+ * Copyright 2004 James Bursa <bursa@users.sourceforge.net>
* Copyright 2003 Phil Mellor <monkeyson@users.sourceforge.net>
*/
@@ -132,7 +132,7 @@ struct font_set *font_new_set()
struct font_data *font_open(struct font_set *set, struct css_style *style)
{
struct font_data *data;
- unsigned int size = 16 * 11;
+ unsigned int size = option_font_size * 1.6;
unsigned int f = 0;
font_f handle;
os_error *error;
@@ -141,7 +141,12 @@ struct font_data *font_open(struct font_set *set, struct css_style *style)
assert(style);
if (style->font_size.size == CSS_FONT_SIZE_LENGTH)
- size = style->font_size.value.length.value * 16;
+ size = len(&style->font_size.value.length, style) *
+ 72.0 / 90.0 * 16;
+ if (size < option_font_min_size * 1.6)
+ size = option_font_min_size * 1.6;
+ if (1600 < size)
+ size = 1600;
switch (style->font_family) {
case CSS_FONT_FAMILY_SANS_SERIF:
diff --git a/riscos/gui.h b/riscos/gui.h
index 96c1e9fc0..c90e08e09 100644
--- a/riscos/gui.h
+++ b/riscos/gui.h
@@ -187,6 +187,12 @@ void ro_gui_history_click(wimp_pointer *pointer);
#define ICON_CONFIG_BR_GESTURES 3
#define ICON_CONFIG_BR_TEXT 4
#define ICON_CONFIG_BR_TOOLBAR 5
+#define ICON_CONFIG_BR_FONTSIZE 7
+#define ICON_CONFIG_BR_FONTSIZE_DEC 8
+#define ICON_CONFIG_BR_FONTSIZE_INC 9
+#define ICON_CONFIG_BR_MINSIZE 11
+#define ICON_CONFIG_BR_MINSIZE_DEC 12
+#define ICON_CONFIG_BR_MINSIZE_INC 13
#define ICON_CONFIG_PROX_OK 0
#define ICON_CONFIG_PROX_CANCEL 1
diff --git a/riscos/options.h b/riscos/options.h
index 368e1964c..965216170 100644
--- a/riscos/options.h
+++ b/riscos/options.h
@@ -15,15 +15,15 @@
#include "netsurf/desktop/options.h"
-extern int option_use_mouse_gestures;
-extern int option_allow_text_selection;
-extern int option_show_toolbar;
+extern bool option_use_mouse_gestures;
+extern bool option_allow_text_selection;
+extern bool option_show_toolbar;
extern char *option_theme;
#define EXTRA_OPTION_DEFINE \
-int option_use_mouse_gestures = false;\
-int option_allow_text_selection = true;\
-int option_show_toolbar = true;\
+bool option_use_mouse_gestures = false;\
+bool option_allow_text_selection = true;\
+bool option_show_toolbar = true;\
char *option_theme = 0;
#define EXTRA_OPTION_TABLE \