summaryrefslogtreecommitdiff
path: root/riscos
diff options
context:
space:
mode:
authorJohn Mark Bell <jmb@netsurf-browser.org>2004-09-13 23:56:18 +0000
committerJohn Mark Bell <jmb@netsurf-browser.org>2004-09-13 23:56:18 +0000
commitc358b80cc51146b49a73bc33a58f4040d6258ce1 (patch)
tree4782334ff22894bf1a2c349e846ccae91e3ba4f4 /riscos
parent8e0b3d8136587ce645f2498da85a308a35887d85 (diff)
downloadnetsurf-c358b80cc51146b49a73bc33a58f4040d6258ce1.tar.gz
netsurf-c358b80cc51146b49a73bc33a58f4040d6258ce1.tar.bz2
[project @ 2004-09-13 23:56:18 by jmb]
Make fonts user-configurable. This loses font-style support, though it shouldn't be hard to put it back again. svn path=/import/netsurf/; revision=1274
Diffstat (limited to 'riscos')
-rw-r--r--riscos/dialog.c349
-rw-r--r--riscos/font.c125
-rw-r--r--riscos/gui.c6
-rw-r--r--riscos/gui.h52
-rw-r--r--riscos/menus.c102
-rw-r--r--riscos/options.h28
6 files changed, 524 insertions, 138 deletions
diff --git a/riscos/dialog.c b/riscos/dialog.c
index 923d019f7..47b587945 100644
--- a/riscos/dialog.c
+++ b/riscos/dialog.c
@@ -20,6 +20,7 @@
#include "oslib/wimp.h"
#include "netsurf/utils/config.h"
#include "netsurf/desktop/netsurf.h"
+#include "netsurf/render/font.h"
#include "netsurf/riscos/gui.h"
#include "netsurf/riscos/options.h"
#include "netsurf/riscos/theme.h"
@@ -41,10 +42,12 @@ wimp_w dialog_info, dialog_saveas, dialog_config, dialog_config_br,
#endif
dialog_zoom, dialog_pageinfo, dialog_objinfo, dialog_tooltip,
dialog_warning, dialog_config_th_pane, dialog_debug,
- dialog_folder, dialog_entry, dialog_search, dialog_print;
+ dialog_folder, dialog_entry, dialog_search, dialog_print,
+ dialog_config_font;
static int ro_gui_choices_font_size;
static int ro_gui_choices_font_min_size;
+static int config_font_icon = -1;
static bool ro_gui_choices_http_proxy;
static int ro_gui_choices_http_proxy_auth;
static int config_br_icon = -1;
@@ -84,11 +87,12 @@ static void ro_gui_dialog_config_prepare(void);
static void ro_gui_dialog_config_set(void);
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_config_proxy_update(void);
static void ro_gui_dialog_click_config_th(wimp_pointer *pointer);
static void ro_gui_dialog_click_config_th_pane(wimp_pointer *pointer);
+static void ro_gui_dialog_update_config_font(void);
+static void ro_gui_dialog_click_config_font(wimp_pointer *pointer);
static void ro_gui_dialog_click_zoom(wimp_pointer *pointer);
static void ro_gui_dialog_reset_zoom(void);
static void ro_gui_dialog_click_warning(wimp_pointer *pointer);
@@ -124,6 +128,7 @@ void ro_gui_dialog_init(void)
dialog_entry = ro_gui_dialog_create("new_entry");
dialog_search = ro_gui_dialog_create("search");
dialog_print = ro_gui_dialog_create("print");
+ dialog_config_font = ro_gui_dialog_create("config_font");
}
@@ -436,6 +441,8 @@ void ro_gui_dialog_click(wimp_pointer *pointer)
else if (pointer->w == dialog_print)
ro_gui_print_click(pointer);
#endif
+ else if (pointer->w == dialog_config_font)
+ ro_gui_dialog_click_config_font(pointer);
}
@@ -452,6 +459,8 @@ void ro_gui_dialog_open_config(void)
false);
ro_gui_set_icon_selected_state(dialog_config, ICON_CONFIG_THEME,
false);
+ ro_gui_set_icon_selected_state(dialog_config, ICON_CONFIG_FONT,
+ false);
ro_gui_dialog_open(dialog_config);
ro_gui_open_pane(dialog_config, dialog_config_br, 0);
}
@@ -464,9 +473,6 @@ void ro_gui_dialog_open_config(void)
void ro_gui_dialog_config_prepare(void)
{
/* browser pane */
- ro_gui_choices_font_size = option_font_size;
- ro_gui_choices_font_min_size = option_font_min_size;
- ro_gui_dialog_update_config_br();
ro_gui_set_icon_string(dialog_config_br, ICON_CONFIG_BR_LANG,
language_name(option_language ?
option_language : "en"));
@@ -478,6 +484,12 @@ void ro_gui_dialog_config_prepare(void)
ro_gui_set_icon_selected_state(dialog_config_br,
ICON_CONFIG_BR_OPENBROWSER,
option_open_browser_at_startup);
+ ro_gui_set_icon_selected_state(dialog_config_br,
+ ICON_CONFIG_BR_BLOCKADS,
+ option_block_ads);
+ ro_gui_set_icon_selected_state(dialog_config_br,
+ ICON_CONFIG_BR_PLUGINS,
+ option_no_plugins);
/* proxy pane */
ro_gui_choices_http_proxy = option_http_proxy;
@@ -504,6 +516,31 @@ void ro_gui_dialog_config_prepare(void)
/* themes pane */
ro_gui_dialog_load_themes();
theme_choice = ro_gui_theme_find(option_theme);
+
+ /* font pane */
+ ro_gui_choices_font_size = option_font_size;
+ ro_gui_choices_font_min_size = option_font_min_size;
+ ro_gui_dialog_update_config_font();
+ ro_gui_set_icon_string(dialog_config_font, ICON_CONFIG_FONT_SANS,
+ option_font_sans ? option_font_sans :
+ "Homerton.Medium");
+ ro_gui_set_icon_string(dialog_config_font, ICON_CONFIG_FONT_SERIF,
+ option_font_serif ? option_font_serif :
+ "Trinity.Medium");
+ ro_gui_set_icon_string(dialog_config_font, ICON_CONFIG_FONT_MONO,
+ option_font_mono ? option_font_mono :
+ "Corpus.Medium");
+ ro_gui_set_icon_string(dialog_config_font, ICON_CONFIG_FONT_CURS,
+ option_font_cursive ? option_font_cursive :
+ "Homerton.Medium");
+ ro_gui_set_icon_string(dialog_config_font, ICON_CONFIG_FONT_FANT,
+ option_font_fantasy ? option_font_fantasy :
+ "Homerton.Medium");
+ ro_gui_set_icon_string(dialog_config_font, ICON_CONFIG_FONT_DEF,
+ option_font_default ? option_font_default :
+ "Homerton.Medium");
+ ro_gui_set_icon_selected_state(dialog_config_font,
+ ICON_CONFIG_FONT_USE_UFONT, option_font_ufont);
}
@@ -513,13 +550,19 @@ void ro_gui_dialog_config_prepare(void)
void ro_gui_dialog_config_set(void) {
/* browser pane */
- option_font_size = ro_gui_choices_font_size;
- option_font_min_size = ro_gui_choices_font_min_size;
+ if (option_homepage_url)
+ free(option_homepage_url);
option_homepage_url = strdup(ro_gui_get_icon_string(dialog_config_br,
ICON_CONFIG_BR_HOMEPAGE));
option_open_browser_at_startup = ro_gui_get_icon_selected_state(
dialog_config_br,
ICON_CONFIG_BR_OPENBROWSER);
+ option_block_ads = ro_gui_get_icon_selected_state(
+ dialog_config_br,
+ ICON_CONFIG_BR_BLOCKADS);
+ option_no_plugins = ro_gui_get_icon_selected_state(
+ dialog_config_br,
+ ICON_CONFIG_BR_PLUGINS);
if (ro_gui_choices_lang) {
free(option_language);
option_language = strdup(ro_gui_choices_lang);
@@ -533,18 +576,21 @@ void ro_gui_dialog_config_set(void) {
/* proxy pane */
option_http_proxy = ro_gui_choices_http_proxy;
- free(option_http_proxy_host);
+ if (option_http_proxy_host)
+ free(option_http_proxy_host);
option_http_proxy_host = strdup(ro_gui_get_icon_string(
dialog_config_prox,
ICON_CONFIG_PROX_HTTPHOST));
option_http_proxy_port = atoi(ro_gui_get_icon_string(dialog_config_prox,
ICON_CONFIG_PROX_HTTPPORT));
option_http_proxy_auth = ro_gui_choices_http_proxy_auth;
- free(option_http_proxy_auth_user);
+ if (option_http_proxy_auth_user)
+ free(option_http_proxy_auth_user);
option_http_proxy_auth_user = strdup(ro_gui_get_icon_string(
dialog_config_prox,
ICON_CONFIG_PROX_AUTHUSER));
- free(option_http_proxy_auth_pass);
+ if (option_http_proxy_auth_pass)
+ free(option_http_proxy_auth_pass);
option_http_proxy_auth_pass = strdup(ro_gui_get_icon_string(
dialog_config_prox,
ICON_CONFIG_PROX_AUTHPASS));
@@ -558,6 +604,36 @@ void ro_gui_dialog_config_set(void) {
option_theme = strdup(theme_choice->filename);
ro_gui_theme_apply(theme_choice);
}
+
+ /* font pane */
+ option_font_size = ro_gui_choices_font_size;
+ option_font_min_size = ro_gui_choices_font_min_size;
+ if (option_font_sans)
+ free(option_font_sans);
+ option_font_sans = strdup(ro_gui_get_icon_string(dialog_config_font,
+ ICON_CONFIG_FONT_SANS));
+ if (option_font_serif)
+ free(option_font_serif);
+ option_font_serif = strdup(ro_gui_get_icon_string(dialog_config_font,
+ ICON_CONFIG_FONT_SERIF));
+ if (option_font_mono)
+ free(option_font_mono);
+ option_font_mono = strdup(ro_gui_get_icon_string(dialog_config_font,
+ ICON_CONFIG_FONT_MONO));
+ if (option_font_cursive)
+ free(option_font_cursive);
+ option_font_cursive = strdup(ro_gui_get_icon_string(
+ dialog_config_font, ICON_CONFIG_FONT_CURS));
+ if (option_font_fantasy)
+ free(option_font_fantasy);
+ option_font_fantasy = strdup(ro_gui_get_icon_string(
+ dialog_config_font, ICON_CONFIG_FONT_FANT));
+ if (option_font_default)
+ free(option_font_default);
+ option_font_default = strdup(ro_gui_get_icon_string(
+ dialog_config_font, ICON_CONFIG_FONT_DEF));
+ option_font_ufont = ro_gui_get_icon_selected_state(
+ dialog_config_font, ICON_CONFIG_FONT_USE_UFONT);
}
@@ -625,6 +701,12 @@ void ro_gui_dialog_click_config(wimp_pointer *pointer)
wimp_CHILD_LINKS_PARENT_VISIBLE_TOP_OR_RIGHT
<< wimp_CHILD_TS_EDGE_SHIFT);
break;
+ case ICON_CONFIG_FONT:
+ if (pointer->buttons == wimp_CLICK_ADJUST)
+ ro_gui_set_icon_selected_state(dialog_config,
+ ICON_CONFIG_FONT, true);
+ ro_gui_open_pane(dialog_config, dialog_config_font, 0);
+ break;
}
}
@@ -635,6 +717,7 @@ void ro_gui_dialog_click_config(wimp_pointer *pointer)
void ro_gui_save_options(void)
{
+ nsfont_fill_nametable();
/* NCOS doesnt have the fancy Universal Boot vars; so select
* the path to the choices file based on the build options */
#ifndef NCOS
@@ -655,54 +738,7 @@ void ro_gui_save_options(void)
void ro_gui_dialog_click_config_br(wimp_pointer *pointer)
{
- int stepping = 1;
-
- if (pointer->buttons == wimp_CLICK_ADJUST)
- stepping = -stepping;
-
switch (pointer->i) {
- case ICON_CONFIG_BR_FONTSIZE_DEC:
- ro_gui_choices_font_size -= stepping;
- if (ro_gui_choices_font_size < 50)
- ro_gui_choices_font_size = 50;
- if (ro_gui_choices_font_size > 1000)
- ro_gui_choices_font_size = 1000;
-
- if (ro_gui_choices_font_size <
- ro_gui_choices_font_min_size)
- ro_gui_choices_font_min_size =
- ro_gui_choices_font_size;
- ro_gui_dialog_update_config_br();
- break;
- case ICON_CONFIG_BR_FONTSIZE_INC:
- ro_gui_choices_font_size += stepping;
- if (ro_gui_choices_font_size < 50)
- ro_gui_choices_font_size = 50;
- if (ro_gui_choices_font_size > 1000)
- ro_gui_choices_font_size = 1000;
- ro_gui_dialog_update_config_br();
- break;
- case ICON_CONFIG_BR_MINSIZE_DEC:
- ro_gui_choices_font_min_size -= stepping;
- if (ro_gui_choices_font_min_size < 10)
- ro_gui_choices_font_min_size = 10;
- if (ro_gui_choices_font_min_size > 500)
- ro_gui_choices_font_min_size = 500;
- ro_gui_dialog_update_config_br();
- break;
- case ICON_CONFIG_BR_MINSIZE_INC:
- ro_gui_choices_font_min_size += stepping;
- if (ro_gui_choices_font_min_size < 10)
- ro_gui_choices_font_min_size = 10;
- if (ro_gui_choices_font_min_size > 500)
- ro_gui_choices_font_min_size = 500;
-
- if (ro_gui_choices_font_size <
- ro_gui_choices_font_min_size)
- ro_gui_choices_font_size =
- ro_gui_choices_font_min_size;
- ro_gui_dialog_update_config_br();
- break;
case ICON_CONFIG_BR_LANG_PICK:
/* drop through */
case ICON_CONFIG_BR_ALANG_PICK:
@@ -746,23 +782,6 @@ void ro_gui_dialog_languages_menu_selection(char *lang)
/* invalidate icon number and update window */
config_br_icon = -1;
- ro_gui_dialog_update_config_br();
-}
-
-
-/**
- * Update font size icons in browser choices pane.
- */
-
-void ro_gui_dialog_update_config_br(void)
-{
- char s[10];
- sprintf(s, "%i.%ipt", ro_gui_choices_font_size / 10,
- ro_gui_choices_font_size % 10);
- ro_gui_set_icon_string(dialog_config_br, ICON_CONFIG_BR_FONTSIZE, s);
- sprintf(s, "%i.%ipt", ro_gui_choices_font_min_size / 10,
- ro_gui_choices_font_min_size % 10);
- ro_gui_set_icon_string(dialog_config_br, ICON_CONFIG_BR_MINSIZE, s);
}
@@ -864,10 +883,166 @@ void ro_gui_dialog_click_config_th_pane(wimp_pointer *pointer) {
ro_gui_set_icon_selected_state(dialog_config_th_pane,
link->icon_number, false);
}
- link = link->next;
+ link = link->next;
}
}
+/**
+ * Update font size icons in font choices pane.
+ */
+
+void ro_gui_dialog_update_config_font(void)
+{
+ char s[10];
+ sprintf(s, "%i.%ipt", ro_gui_choices_font_size / 10,
+ ro_gui_choices_font_size % 10);
+ ro_gui_set_icon_string(dialog_config_font,
+ ICON_CONFIG_FONT_FONTSIZE, s);
+ sprintf(s, "%i.%ipt", ro_gui_choices_font_min_size / 10,
+ ro_gui_choices_font_min_size % 10);
+ ro_gui_set_icon_string(dialog_config_font,
+ ICON_CONFIG_FONT_MINSIZE, s);
+}
+
+/**
+ * Handle clicks in the font choices pane
+ */
+void ro_gui_dialog_click_config_font(wimp_pointer *pointer)
+{
+ int stepping = 1;
+
+ if (pointer->buttons == wimp_CLICK_ADJUST)
+ stepping = -stepping;
+
+ switch (pointer->i) {
+ case ICON_CONFIG_FONT_FONTSIZE_DEC:
+ ro_gui_choices_font_size -= stepping;
+ if (ro_gui_choices_font_size < 50)
+ ro_gui_choices_font_size = 50;
+ if (ro_gui_choices_font_size > 1000)
+ ro_gui_choices_font_size = 1000;
+
+ if (ro_gui_choices_font_size <
+ ro_gui_choices_font_min_size)
+ ro_gui_choices_font_min_size =
+ ro_gui_choices_font_size;
+ ro_gui_dialog_update_config_font();
+ break;
+ case ICON_CONFIG_FONT_FONTSIZE_INC:
+ ro_gui_choices_font_size += stepping;
+ if (ro_gui_choices_font_size < 50)
+ ro_gui_choices_font_size = 50;
+ if (ro_gui_choices_font_size > 1000)
+ ro_gui_choices_font_size = 1000;
+ ro_gui_dialog_update_config_font();
+ break;
+ case ICON_CONFIG_FONT_MINSIZE_DEC:
+ ro_gui_choices_font_min_size -= stepping;
+ if (ro_gui_choices_font_min_size < 10)
+ ro_gui_choices_font_min_size = 10;
+ if (ro_gui_choices_font_min_size > 500)
+ ro_gui_choices_font_min_size = 500;
+ ro_gui_dialog_update_config_font();
+ break;
+ case ICON_CONFIG_FONT_MINSIZE_INC:
+ ro_gui_choices_font_min_size += stepping;
+ if (ro_gui_choices_font_min_size < 10)
+ ro_gui_choices_font_min_size = 10;
+ if (ro_gui_choices_font_min_size > 500)
+ ro_gui_choices_font_min_size = 500;
+
+ if (ro_gui_choices_font_size <
+ ro_gui_choices_font_min_size)
+ ro_gui_choices_font_size =
+ ro_gui_choices_font_min_size;
+ ro_gui_dialog_update_config_font();
+ break;
+ case ICON_CONFIG_FONT_SANS_PICK:
+ case ICON_CONFIG_FONT_SERIF_PICK:
+ case ICON_CONFIG_FONT_MONO_PICK:
+ case ICON_CONFIG_FONT_CURS_PICK:
+ case ICON_CONFIG_FONT_FANT_PICK:
+ case ICON_CONFIG_FONT_DEF_PICK:
+ config_font_icon = pointer->i - 1;
+ ro_gui_display_font_menu(ro_gui_get_icon_string(
+ dialog_config_font, pointer->i - 1),
+ dialog_config_font, pointer->i);
+ break;
+ }
+}
+
+/**
+ * Handle font menu selections
+ */
+void ro_gui_dialog_font_menu_selection(char *name)
+{
+ char *n, *fn;
+ int len;
+
+ if (strlen(name) <= 3 || config_font_icon < 0)
+ return;
+
+ n = name + 2; /* \F */
+
+ len = strcspn(n, "\\");
+
+ fn = calloc(len+1, sizeof(char));
+ if (!fn) {
+ LOG(("malloc failed"));
+ return;
+ }
+
+ strncpy(fn, n, len);
+
+ switch (config_font_icon) {
+ case ICON_CONFIG_FONT_SANS:
+ if (option_font_sans)
+ free(option_font_sans);
+ option_font_sans = strdup(fn);
+ ro_gui_set_icon_string(dialog_config_font,
+ config_font_icon, fn);
+ break;
+ case ICON_CONFIG_FONT_SERIF:
+ if (option_font_serif)
+ free(option_font_serif);
+ option_font_serif = strdup(fn);
+ ro_gui_set_icon_string(dialog_config_font,
+ config_font_icon, fn);
+ break;
+ case ICON_CONFIG_FONT_MONO:
+ if (option_font_mono)
+ free(option_font_mono);
+ option_font_mono = strdup(fn);
+ ro_gui_set_icon_string(dialog_config_font,
+ config_font_icon, fn);
+ break;
+ case ICON_CONFIG_FONT_CURS:
+ if (option_font_cursive)
+ free(option_font_cursive);
+ option_font_cursive = strdup(fn);
+ ro_gui_set_icon_string(dialog_config_font,
+ config_font_icon, fn);
+ break;
+ case ICON_CONFIG_FONT_FANT:
+ if (option_font_fantasy)
+ free(option_font_fantasy);
+ option_font_fantasy = strdup(fn);
+ ro_gui_set_icon_string(dialog_config_font,
+ config_font_icon, fn);
+ break;
+ case ICON_CONFIG_FONT_DEF:
+ if (option_font_default)
+ free(option_font_default);
+ option_font_default = strdup(fn);
+ ro_gui_set_icon_string(dialog_config_font,
+ config_font_icon, fn);
+ break;
+ }
+
+ free(fn);
+
+ config_font_icon = -1;
+}
/**
* Handle clicks in the Scale view dialog.
@@ -1020,14 +1195,14 @@ void ro_gui_dialog_load_themes(void) {
wimp_window_state state;
int parent_width, nested_y, min_extent, base_extent;
int item_height;
-
+
/* Delete our old list and get/open a new one
*/
ro_gui_dialog_free_themes();
theme_list = ro_gui_theme_get_available();
ro_gui_theme_open(theme_list, true);
theme_choice = ro_gui_theme_find(option_theme);
-
+
/* Create toolbars for each theme
*/
theme_count = 0;
@@ -1056,7 +1231,7 @@ void ro_gui_dialog_load_themes(void) {
}
descriptor = descriptor->next;
}
-
+
/* Nest the toolbars
*/
state.w = dialog_config_th_pane;
@@ -1074,7 +1249,7 @@ void ro_gui_dialog_load_themes(void) {
extent.x1 = parent_width;
link = toolbars;
new_icon.w = dialog_config_th_pane;
- new_icon.icon.flags = wimp_ICON_TEXT | wimp_ICON_INDIRECTED |
+ new_icon.icon.flags = wimp_ICON_TEXT | wimp_ICON_INDIRECTED |
wimp_ICON_VCENTRED |
(wimp_COLOUR_BLACK << wimp_ICON_FG_COLOUR_SHIFT) |
(wimp_COLOUR_VERY_LIGHT_GREY << wimp_ICON_BG_COLOUR_SHIFT) |
@@ -1089,7 +1264,7 @@ void ro_gui_dialog_load_themes(void) {
if (link->next) extent.y0 -= 16;
if (extent.y0 > min_extent) extent.y0 = min_extent;
xwimp_set_extent(dialog_config_th_pane, &extent);
-
+
/* Create the descriptor icons and separator line
*/
new_icon.icon.extent.x0 = 8;
@@ -1130,7 +1305,7 @@ void ro_gui_dialog_load_themes(void) {
strlen(link->descriptor->filename) + 1;
xwimp_create_icon(&new_icon, 0);
}
-
+
/* Nest the toolbar window
*/
state.w = link->toolbar->toolbar_handle;
@@ -1140,22 +1315,22 @@ void ro_gui_dialog_load_themes(void) {
xwimp_open_window_nested((wimp_open *)&state, dialog_config_th_pane,
wimp_CHILD_LINKS_PARENT_WORK_AREA
<< wimp_CHILD_BS_EDGE_SHIFT |
- wimp_CHILD_LINKS_PARENT_WORK_AREA
+ wimp_CHILD_LINKS_PARENT_WORK_AREA
<< wimp_CHILD_TS_EDGE_SHIFT);
-
+
/* Continue processing
*/
nested_y -= link->toolbar->height + item_height;
link = link->next;
}
-
+
/* Set the current theme as selected
*/
link = toolbars;
while (link) {
ro_gui_set_icon_selected_state(dialog_config_th_pane,
link->icon_number, (link->descriptor == theme_choice));
- link = link->next;
+ link = link->next;
}
xwimp_force_redraw(dialog_config_th_pane, 0, -16384, 16384, 16384);
}
@@ -1167,7 +1342,7 @@ void ro_gui_dialog_load_themes(void) {
void ro_gui_dialog_free_themes(void) {
struct toolbar_display *toolbar;
struct toolbar_display *next_toolbar;
-
+
/* Free all our toolbars
*/
next_toolbar = toolbars;
@@ -1181,7 +1356,7 @@ void ro_gui_dialog_free_themes(void) {
free(toolbar);
}
toolbars = NULL;
-
+
/* Close all our themes
*/
if (theme_list) ro_gui_theme_close(theme_list, true);
diff --git a/riscos/font.c b/riscos/font.c
index 54b124921..f1b9c46ad 100644
--- a/riscos/font.c
+++ b/riscos/font.c
@@ -26,7 +26,9 @@
#include "netsurf/utils/log.h"
#include "netsurf/utils/utils.h"
-#define FONT_FAMILIES 5 /* Number of families */
+#define FONT_MAX_NAME 128 /* max length of a font name */
+
+#define FONT_FAMILIES 6 /* Number of families */
#define FONT_FACES 8 /* Number of faces */
/* Font Variants */
@@ -37,11 +39,12 @@
#define FONT_SLANTED 1
/* Font families */
-#define FONT_SANS_SERIF (0 * FONT_FACES)
-#define FONT_SERIF (1 * FONT_FACES)
-#define FONT_MONOSPACE (2 * FONT_FACES)
-#define FONT_CURSIVE (3 * FONT_FACES)
-#define FONT_FANTASY (4 * FONT_FACES)
+#define FONT_DEFAULT (0 * FONT_FACES)
+#define FONT_SANS_SERIF (1 * FONT_FACES)
+#define FONT_SERIF (2 * FONT_FACES)
+#define FONT_MONOSPACE (3 * FONT_FACES)
+#define FONT_CURSIVE (4 * FONT_FACES)
+#define FONT_FANTASY (5 * FONT_FACES)
/* a font_set is just a linked list of font_data for each face for now */
struct font_set {
@@ -55,13 +58,13 @@ static os_error *nsfont_open_standard(const char *fontNameP, const char *fbFontN
*
* font id = font family * 8 + smallcaps * 4 + bold * 2 + slanted
*
- * font family: 0 = sans-serif, 1 = serif, 2 = monospace, 3 = cursive,
- * 4 = fantasy.
+ * font family: 1 = sans-serif, 2 = serif, 3 = monospace, 4 = cursive,
+ * 5 = fantasy.
* Font family 0 must be available as it is the replacement font when
* the other font families can not be found.
*/
-static const char * const ufont_table[FONT_FAMILIES * FONT_FACES] = {
- /* sans-serif */
+static char ufont_table[FONT_FAMILIES * FONT_FACES][FONT_MAX_NAME] = {
+ /* default */
/*0*/ "Homerton.Medium",
/*1*/ "Homerton.Medium.Oblique",
/*2*/ "Homerton.Bold",
@@ -70,44 +73,54 @@ static const char * const ufont_table[FONT_FAMILIES * FONT_FACES] = {
"Homerton.Medium.Oblique.SmallCaps",
"Homerton.Bold.SmallCaps",
"Homerton.Bold.Oblique.SmallCaps",
+ /* sans-serif */
+/*8*/ "Homerton.Medium",
+/*9*/ "Homerton.Medium.Oblique",
+/*10*/ "Homerton.Bold",
+/*11*/ "Homerton.Bold.Oblique",
+ "Homerton.Medium.SmallCaps",
+ "Homerton.Medium.Oblique.SmallCaps",
+ "Homerton.Bold.SmallCaps",
+ "Homerton.Bold.Oblique.SmallCaps",
/* serif */
-/*8*/ "Trinity.Medium",
-/*9*/ "Trinity.Medium.Italic",
-/*10*/ "Trinity.Bold",
-/*11*/ "Trinity.Bold.Italic",
+/*16*/ "Trinity.Medium",
+/*17*/ "Trinity.Medium.Italic",
+/*18*/ "Trinity.Bold",
+/*19*/ "Trinity.Bold.Italic",
"Trinity.Medium.SmallCaps",
"Trinity.Medium.Italic.SmallCaps",
"Trinity.Bold.SmallCaps",
"Trinity.Bold.Italic.SmallCaps",
/* monospace */
-/*16*/ "Corpus.Medium",
-/*17*/ "Corpus.Medium.Oblique",
-/*18*/ "Corpus.Bold",
-/*19*/ "Corpus.Bold.Oblique",
+/*24*/ "Corpus.Medium",
+/*25*/ "Corpus.Medium.Oblique",
+/*26*/ "Corpus.Bold",
+/*27*/ "Corpus.Bold.Oblique",
"Corpus.Medium.SmallCaps",
"Corpus.Medium.Oblique.SmallCaps",
"Corpus.Bold.SmallCaps",
"Corpus.Bold.Oblique.SmallCaps",
/* cursive */
-/*24*/ "Churchill.Medium",
-/*25*/ "Churchill.Medium.Oblique",
-/*26*/ "Churchill.Bold",
-/*27*/ "Churchill.Bold.Oblique",
+/*32*/ "Churchill.Medium",
+/*33*/ "Churchill.Medium.Oblique",
+/*34*/ "Churchill.Bold",
+/*35*/ "Churchill.Bold.Oblique",
"Churchill.Medium.SmallCaps",
"Churchill.Medium.Oblique.SmallCaps",
"Churchill.Bold.SmallCaps",
"Churchill.Bold.Oblique.SmallCaps",
/* fantasy */
-/*32*/ "Sassoon.Primary",
-/*33*/ "Sassoon.Primary.Oblique",
-/*34*/ "Sassoon.Primary.Bold",
-/*35*/ "Sassoon.Primary.Bold.Oblique",
+/*40*/ "Sassoon.Primary",
+/*41*/ "Sassoon.Primary.Oblique",
+/*42*/ "Sassoon.Primary.Bold",
+/*43*/ "Sassoon.Primary.Bold.Oblique",
"Sassoon.Primary.SmallCaps",
"Sassoon.Primary.Oblique.SmallCaps",
"Sassoon.Primary.Bold.SmallCaps",
"Sassoon.Primary.Bold.Oblique.SmallCaps",
};
+#if 0
/** Table of Latin1 encoded font names for a pre-UTF-8 capable FontManager.
*
* font id = font family * 8 + smallcaps * 4 + bold * 2 + slanted
@@ -164,6 +177,7 @@ static const char * const font_table[FONT_FAMILIES * FONT_FACES] = {
"Sassoon.Primary.Bold.SmallCaps\\ELatin1",
"Sassoon.Primary.Bold.SmallCaps\\ELatin1\\M65536 0 13930 65536 0 0",
};
+#endif
/**
* Create an empty font_set.
@@ -279,8 +293,9 @@ struct font_data *nsfont_open(struct font_set *set, struct css_style *style)
* If this still fails, we repeat the previous step but now using
* the Latin 1 encoding.
*/
- if ((error = nsfont_open_ufont(ufont_table[f], ufont_table[f % 4], (int)size, &fhandle, &using_fb)) != NULL) {
- char fontName1[128], fontName2[128];
+ if (!option_font_ufont || (error = nsfont_open_ufont(ufont_table[f], ufont_table[f % 4], (int)size, &fhandle, &using_fb)) != NULL) {
+ char fontName1[FONT_MAX_NAME+10];
+ char fontName2[FONT_MAX_NAME+10];
/* Go for the UTF-8 encoding with standard FontManager */
strcpy(fontName1, ufont_table[f]);
strcat(fontName1, "\\EUTF8");
@@ -288,7 +303,11 @@ struct font_data *nsfont_open(struct font_set *set, struct css_style *style)
strcat(fontName2, "\\EUTF8");
if ((error = nsfont_open_standard(fontName1, fontName2, (int)size, &fhandle, &using_fb)) != NULL) {
/* All UTF-8 font methods failed, only support Latin 1 */
- if ((error = nsfont_open_standard(font_table[f], font_table[f % 4], (int)size, &fhandle, &using_fb)) != NULL) {
+ strcpy(fontName1, ufont_table[f]);
+ strcat(fontName1, "\\ELatin1");
+ strcpy(fontName2, ufont_table[f % 4]);
+ strcat(fontName2, "\\ELatin1");
+ if ((error = nsfont_open_standard(fontName1, fontName2, (int)size, &fhandle, &using_fb)) != NULL) {
LOG(("(u)font_find_font failed : %s\n", error->errmess));
die("(u)font_find_font failed");
}
@@ -465,7 +484,7 @@ unsigned long nsfont_width(struct font_data *font, const char *text,
break;
}
if (error != NULL) {
- LOG(("(u)font_scan_string failed : %s\n", error->errmess));
+ LOG(("(u)font_scan_string failed : %s", error->errmess));
die("nsfont_width: (u)font_scan_string failed");
}
@@ -635,7 +654,7 @@ char *nsfont_split(struct font_data *font, const char *text,
die("nsfont_split: (u)font_scan_string failed");
}
- assert(split == &text[length] || *split == ' ');
+ assert(split == &text[length] || *split == ' ' || *split == '\t');
*used_width = *used_width / 2 / 400;
@@ -739,6 +758,8 @@ void nsfont_txtenum(struct font_data *font, const char *text,
size_t *rolength,
size_t *consumed)
{
+ static char *fontname[FONT_MAX_NAME]; /** /todo: not nice */
+
assert(font != NULL && text != NULL && rofontname != NULL && rotext != NULL && rolength != NULL && consumed != NULL);
*rotext = *rofontname = NULL;
@@ -763,7 +784,6 @@ void nsfont_txtenum(struct font_data *font, const char *text,
*width /= 800;
break;
case FONTTYPE_STANDARD_UTF8ENC: {
- static char *fontname[128]; /** /todo: not nice */
int rowidth;
os_error *error;
@@ -809,7 +829,9 @@ void nsfont_txtenum(struct font_data *font, const char *text,
return;
}
*rolength = strlen(*rotext);
- *rofontname = font_table[font->id];
+ strcpy(fontname, ufont_table[font->id]);
+ strcat(fontname, "\\ELatin1");
+ *rofontname = fontname;
*consumed = length;
*width = (unsigned int)rowidth / 800;
break;
@@ -819,3 +841,40 @@ void nsfont_txtenum(struct font_data *font, const char *text,
break;
}
}
+
+/**
+ * Fill in the font_table, based on the user's options
+ */
+void nsfont_fill_nametable(void)
+{
+ int i, j;
+ char *name = NULL;
+
+ for (i = 0; i != FONT_FAMILIES; i++) {
+ switch (i) {
+ case FONT_DEFAULT/FONT_FACES:
+ name = option_font_default;
+ break;
+ case FONT_SANS_SERIF/FONT_FACES:
+ name = option_font_sans;
+ break;
+ case FONT_SERIF/FONT_FACES:
+ name = option_font_serif;
+ break;
+ case FONT_MONOSPACE/FONT_FACES:
+ name = option_font_mono;
+ break;
+ case FONT_CURSIVE/FONT_FACES:
+ name = option_font_cursive;
+ break;
+ case FONT_FANTASY/FONT_FACES:
+ name = option_font_fantasy;
+ break;
+ }
+ for (j = 0; j != FONT_FACES; j++) {
+ /**\todo Bold, italic, smallcaps */
+ strncpy(ufont_table[FONT_FACES*i+j],
+ name, FONT_MAX_NAME);
+ }
+ }
+}
diff --git a/riscos/gui.c b/riscos/gui.c
index 0d7d34d5f..1cfc7690a 100644
--- a/riscos/gui.c
+++ b/riscos/gui.c
@@ -176,7 +176,9 @@ void gui_init(int argc, char** argv)
xhourglass_start(1);
+#ifdef WITH_SAVE_COMPLETE
save_complete_init();
+#endif
/* We don't have the universal boot sequence on NCOS */
#ifndef ncos
@@ -215,6 +217,8 @@ void gui_init(int argc, char** argv)
#ifndef ncos
ro_gui_check_fonts();
#endif
+ nsfont_fill_nametable();
+
/* Issue a *Desktop to poke AcornURI into life */
if (getenv("NetSurf$Start_URI_Handler"))
xwimp_start_task("Desktop", 0);
@@ -1434,8 +1438,10 @@ void ro_gui_view_source(struct content *content)
void gui_launch_url(const char *url)
{
+#ifdef WITH_URL
/* Try ant broadcast first */
ro_url_broadcast(url);
+#endif
}
diff --git a/riscos/gui.h b/riscos/gui.h
index f3457ce8f..006f46805 100644
--- a/riscos/gui.h
+++ b/riscos/gui.h
@@ -26,8 +26,9 @@ struct toolbar;
extern wimp_w dialog_info, dialog_saveas, dialog_config, dialog_config_br,
dialog_config_prox, dialog_config_th, dialog_zoom, dialog_pageinfo,
- dialog_objinfo, dialog_tooltip, dialog_warning, dialog_config_th_pane,
- dialog_debug, dialog_folder, dialog_entry, dialog_search, dialog_print;
+ dialog_objinfo, dialog_tooltip, dialog_warning,
+ dialog_config_th_pane, dialog_debug, dialog_folder, dialog_entry,
+ dialog_search, dialog_print, dialog_config_font;
extern wimp_w history_window;
extern wimp_w hotlist_window;
extern wimp_menu *iconbar_menu, *browser_menu, *combo_menu, *hotlist_menu,
@@ -117,6 +118,7 @@ void ro_gui_menu_warning(wimp_message_menu_warning *warning);
void ro_gui_prepare_navigate(struct gui_window *gui);
void ro_gui_menu_prepare_scale(void);
void ro_gui_menu_prepare_pageinfo(void);
+void ro_gui_display_font_menu(const char *tick, wimp_w w, wimp_i i);
/* in dialog.c */
void ro_gui_dialog_init(void);
@@ -133,6 +135,7 @@ void ro_gui_menu_prepare_hotlist(void);
void ro_gui_dialog_open_config(void);
void ro_gui_dialog_proxyauth_menu_selection(int item);
void ro_gui_dialog_languages_menu_selection(char *lang);
+void ro_gui_dialog_font_menu_selection(char *name);
/* in download.c */
void ro_gui_download_init(void);
@@ -284,19 +287,16 @@ bool ro_gui_print_keypress(wimp_key *key);
#define ICON_CONFIG_BROWSER 3
#define ICON_CONFIG_PROXY 4
#define ICON_CONFIG_THEME 5
+#define ICON_CONFIG_FONT 7
-#define ICON_CONFIG_BR_FONTSIZE 1
-#define ICON_CONFIG_BR_FONTSIZE_DEC 2
-#define ICON_CONFIG_BR_FONTSIZE_INC 3
-#define ICON_CONFIG_BR_MINSIZE 5
-#define ICON_CONFIG_BR_MINSIZE_DEC 6
-#define ICON_CONFIG_BR_MINSIZE_INC 7
-#define ICON_CONFIG_BR_LANG 9
-#define ICON_CONFIG_BR_LANG_PICK 10
-#define ICON_CONFIG_BR_ALANG 13
-#define ICON_CONFIG_BR_ALANG_PICK 14
-#define ICON_CONFIG_BR_HOMEPAGE 16
-#define ICON_CONFIG_BR_OPENBROWSER 17
+#define ICON_CONFIG_BR_LANG 1
+#define ICON_CONFIG_BR_LANG_PICK 2
+#define ICON_CONFIG_BR_ALANG 5
+#define ICON_CONFIG_BR_ALANG_PICK 6
+#define ICON_CONFIG_BR_HOMEPAGE 8
+#define ICON_CONFIG_BR_OPENBROWSER 9
+#define ICON_CONFIG_BR_BLOCKADS 10
+#define ICON_CONFIG_BR_PLUGINS 11
#define ICON_CONFIG_PROX_HTTP 0
#define ICON_CONFIG_PROX_HTTPHOST 1
@@ -309,6 +309,30 @@ bool ro_gui_print_keypress(wimp_key *key);
#define ICON_CONFIG_TH_GET 0
#define ICON_CONFIG_TH_MANAGE 1
+/* Note: The display icon numbers for font names *must* be ONE less
+ * than the icon number of the corresponding pick icon.
+ * This is assumed by ro_gui_dialog_click_font.
+ */
+#define ICON_CONFIG_FONT_SANS 2
+#define ICON_CONFIG_FONT_SANS_PICK 3
+#define ICON_CONFIG_FONT_SERIF 4
+#define ICON_CONFIG_FONT_SERIF_PICK 5
+#define ICON_CONFIG_FONT_MONO 6
+#define ICON_CONFIG_FONT_MONO_PICK 7
+#define ICON_CONFIG_FONT_CURS 8
+#define ICON_CONFIG_FONT_CURS_PICK 9
+#define ICON_CONFIG_FONT_FANT 10
+#define ICON_CONFIG_FONT_FANT_PICK 11
+#define ICON_CONFIG_FONT_DEF 12
+#define ICON_CONFIG_FONT_DEF_PICK 13
+#define ICON_CONFIG_FONT_FONTSIZE 14
+#define ICON_CONFIG_FONT_FONTSIZE_DEC 15
+#define ICON_CONFIG_FONT_FONTSIZE_INC 16
+#define ICON_CONFIG_FONT_MINSIZE 17
+#define ICON_CONFIG_FONT_MINSIZE_DEC 18
+#define ICON_CONFIG_FONT_MINSIZE_INC 19
+#define ICON_CONFIG_FONT_USE_UFONT 20
+
#define ICON_DOWNLOAD_ICON 0
#define ICON_DOWNLOAD_URL 1
#define ICON_DOWNLOAD_PATH 2
diff --git a/riscos/menus.c b/riscos/menus.c
index 250db9ae7..2fc45c7b5 100644
--- a/riscos/menus.c
+++ b/riscos/menus.c
@@ -14,6 +14,7 @@
#include <stdlib.h>
#include <string.h>
+#include "oslib/font.h"
#include "oslib/os.h"
#include "oslib/osgbpb.h"
#include "oslib/wimp.h"
@@ -55,6 +56,7 @@ static void ro_gui_menu_objectinfo(wimp_message_menu_warning *warning);
static void ro_gui_menu_object_reload(void);
static void ro_gui_menu_browser_warning(wimp_message_menu_warning *warning);
static void ro_gui_menu_hotlist_warning(wimp_message_menu_warning *warning);
+static void ro_gui_font_menu_selection(wimp_selection *selection);
struct gui_window *current_gui;
wimp_menu *current_menu;
@@ -402,6 +404,11 @@ wimp_menu *proxyauth_menu = (wimp_menu *) &proxy_menu;
*/
wimp_menu *languages_menu = NULL;
+/* Font popup menu (used in font choices dialog)
+*/
+static wimp_menu *font_menu = NULL;
+static byte *font_menu_data = NULL;
+
static wimp_menu *browser_page_menu = (wimp_menu *)&page_menu;
static wimp_menu *browser_export_menu = (wimp_menu *)&export_menu;
static wimp_menu *browser_object_menu = (wimp_menu *)&object_menu;
@@ -975,6 +982,8 @@ void ro_gui_menu_selection(wimp_selection *selection)
} else if (current_menu == languages_menu) {
ro_gui_dialog_languages_menu_selection(languages_menu->entries[selection->items[0]].data.indirected_text.text);
+ } else if (current_menu == font_menu) {
+ ro_gui_font_menu_selection(selection);
}
if (pointer.buttons == wimp_CLICK_ADJUST) {
@@ -1077,8 +1086,10 @@ void ro_gui_menu_browser_warning(wimp_message_menu_warning *warning)
break;
case 5: /* Print -> */
+#ifdef WITH_PRINT
ro_gui_print_open(current_gui, warning->pos.x,
warning->pos.y, true, false);
+#endif
break;
}
break;
@@ -1154,7 +1165,7 @@ void ro_gui_menu_browser_warning(wimp_message_menu_warning *warning)
view_menu.entries[2].icon_flags &= ~wimp_ICON_SHADED;
} else {
view_menu.entries[2].icon_flags |= wimp_ICON_SHADED;
- }
+ }
error = xwimp_create_sub_menu((wimp_menu *) browser_view_menu,
warning->pos.x, warning->pos.y);
break;
@@ -1193,11 +1204,13 @@ void ro_gui_menu_browser_warning(wimp_message_menu_warning *warning)
warning->pos.x, warning->pos.y);
break;
case 2: /* Find text -> */
+#ifdef WITH_SEARCH
ro_gui_search_open(current_gui,
warning->pos.x,
warning->pos.y,
true,
false);
+#endif
break;
}
break;
@@ -1792,3 +1805,90 @@ void gui_create_form_select_menu(struct browser_window *bw,
ro_gui_create_menu(gui_form_select_menu,
pointer.pos.x, pointer.pos.y, bw->window);
}
+
+/**
+ * Create and display a menu listing all fonts present in the system.
+ *
+ * \param tick The name of the currently selected font
+ * \param w The dialog containing the clicked icon
+ * \param i The clicked icon.
+ */
+void ro_gui_display_font_menu(const char *tick, wimp_w w, wimp_i i)
+{
+ int size1, size2;
+ os_error *error;
+
+ error = xfont_list_fonts(0, font_RETURN_FONT_MENU | font_GIVEN_TICK,
+ 0, 0, 0, tick, 0, &size1, &size2);
+ if (error) {
+ LOG(("xfont_list_fonts: 0x%x: %s",
+ error->errnum, error->errmess));
+ return;
+ }
+
+ /* free previous menu */
+ if (font_menu)
+ free(font_menu);
+ if (font_menu_data)
+ free(font_menu_data);
+
+ font_menu = calloc(size1, sizeof(byte));
+ if (!font_menu) {
+ LOG(("malloc failed"));
+ return;
+ }
+ font_menu_data = calloc(size2, sizeof(byte));
+ if (!font_menu_data) {
+ LOG(("malloc failed"));
+ return;
+ }
+
+ error = xfont_list_fonts((byte*)font_menu,
+ font_RETURN_FONT_MENU | font_GIVEN_TICK,
+ size1, font_menu_data, size2, tick, 0, 0, 0);
+ if (error) {
+ LOG(("xfont_list_fonts: 0x%x: %s",
+ error->errnum, error->errmess));
+ return;
+ }
+
+ ro_gui_popup_menu(font_menu, w, i);
+}
+
+/**
+ * Handle a selection in the font menu
+ *
+ * \param selection The selection block
+ */
+void ro_gui_font_menu_selection(wimp_selection *selection)
+{
+ int buf_size;
+ char *buf;
+ os_error *error;
+
+ error = xfont_decode_menu(0, (byte*)font_menu, (byte*)selection,
+ 0, 0, 0, &buf_size);
+ if (error) {
+ LOG(("xfont_decode_menu: 0x%x: %s",
+ error->errnum, error->errmess));
+ return;
+ }
+
+ buf = calloc(buf_size, sizeof(char));
+ if (!buf) {
+ LOG(("malloc failed"));
+ return;
+ }
+
+ error = xfont_decode_menu(0, (byte*)font_menu, (byte*)selection,
+ buf, buf_size, 0, 0);
+ if (error) {
+ LOG(("xfont_decode_menu: 0x%x: %s",
+ error->errnum, error->errmess));
+ return;
+ }
+
+ ro_gui_dialog_font_menu_selection(buf);
+
+ free(buf);
+}
diff --git a/riscos/options.h b/riscos/options.h
index 7ea9c3560..d653a6c4b 100644
--- a/riscos/options.h
+++ b/riscos/options.h
@@ -47,7 +47,14 @@ extern bool option_buffer_animations;
extern bool option_buffer_everything;
extern char *option_homepage_url;
extern bool option_open_browser_at_startup;
-extern bool option_plugins;
+extern bool option_no_plugins;
+extern char *option_font_sans;
+extern char *option_font_serif;
+extern char *option_font_mono;
+extern char *option_font_cursive;
+extern char *option_font_fantasy;
+extern char *option_font_default;
+extern bool option_font_ufont;
#define EXTRA_OPTION_DEFINE \
bool option_use_mouse_gestures = false;\
@@ -81,7 +88,14 @@ bool option_buffer_animations = true; \
bool option_buffer_everything = false; \
char *option_homepage_url = 0; \
bool option_open_browser_at_startup = false; \
-bool option_plugins = false;
+bool option_no_plugins = true; \
+char *option_font_sans = 0; \
+char *option_font_serif = 0; \
+char *option_font_mono = 0; \
+char *option_font_cursive = 0; \
+char *option_font_fantasy = 0; \
+char *option_font_default = 0; \
+bool option_font_ufont = false;
#define EXTRA_OPTION_TABLE \
{ "use_mouse_gestures", OPTION_BOOL, &option_use_mouse_gestures },\
@@ -115,5 +129,13 @@ bool option_plugins = false;
{ "buffer_everything", OPTION_BOOL, &option_buffer_everything }, \
{ "homepage_url", OPTION_STRING, &option_homepage_url }, \
{ "open_browser_at_startup",OPTION_BOOL, &option_open_browser_at_startup }, \
-{ "plugins", OPTION_BOOL, &option_plugins }
+{ "no_plugins", OPTION_BOOL, &option_no_plugins }, \
+{ "font_sans", OPTION_STRING, &option_font_sans }, \
+{ "font_serif", OPTION_STRING, &option_font_serif }, \
+{ "font_mono", OPTION_STRING, &option_font_mono }, \
+{ "font_cursive", OPTION_STRING, &option_font_cursive }, \
+{ "font_fantasy", OPTION_STRING, &option_font_fantasy }, \
+{ "font_default", OPTION_STRING, &option_font_default }, \
+{ "font_ufont", OPTION_BOOL, &option_font_ufont}
+
#endif